From 622e7da4c6f6fa425a1ba6cf21a7bc70d8d946e6 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 19 May 2026 14:41:36 +0530 Subject: [PATCH 1/2] chore: update Web SDK to 26.0.0 --- CHANGELOG.md | 9 + README.md | 2 +- .../account/create-mfa-authenticator.md | 2 +- docs/examples/account/create-mfa-challenge.md | 2 +- .../account/create-mfa-recovery-codes.md | 2 +- .../account/delete-mfa-authenticator.md | 2 +- .../account/get-mfa-recovery-codes.md | 2 +- docs/examples/account/list-mfa-factors.md | 2 +- .../account/update-mfa-authenticator.md | 2 +- docs/examples/account/update-mfa-challenge.md | 2 +- .../account/update-mfa-recovery-codes.md | 2 +- .../get-event.md} | 8 +- docs/examples/activities/list-events.md | 15 + docs/examples/advisor/delete-report.md | 15 + docs/examples/advisor/get-insight.md | 16 + docs/examples/advisor/get-report.md | 15 + docs/examples/advisor/list-insights.md | 17 + docs/examples/advisor/list-reports.md | 16 + docs/examples/backups/create-archive.md | 16 + docs/examples/backups/create-policy.md | 21 + docs/examples/backups/create-restoration.md | 18 + docs/examples/backups/delete-archive.md | 15 + docs/examples/backups/delete-policy.md | 15 + docs/examples/backups/get-archive.md | 15 + docs/examples/backups/get-policy.md | 15 + docs/examples/backups/get-restoration.md | 15 + docs/examples/backups/list-archives.md | 15 + docs/examples/backups/list-policies.md | 15 + docs/examples/backups/list-restorations.md | 15 + docs/examples/backups/update-policy.md | 19 + .../databases/create-big-int-attribute.md | 22 + .../databases/create-boolean-attribute.md | 20 + docs/examples/databases/create-collection.md | 22 + .../databases/create-datetime-attribute.md | 20 + docs/examples/databases/create-document.md | 5 +- .../databases/create-email-attribute.md | 20 + .../databases/create-enum-attribute.md | 21 + .../databases/create-float-attribute.md | 22 + docs/examples/databases/create-index.md | 21 + .../databases/create-integer-attribute.md | 22 + .../examples/databases/create-ip-attribute.md | 20 + .../databases/create-line-attribute.md | 19 + .../databases/create-longtext-attribute.md | 21 + .../databases/create-mediumtext-attribute.md | 21 + .../databases/create-point-attribute.md | 19 + .../databases/create-polygon-attribute.md | 19 + .../create-relationship-attribute.md | 22 + .../databases/create-string-attribute.md | 22 + .../databases/create-text-attribute.md | 21 + .../databases/create-url-attribute.md | 20 + .../databases/create-varchar-attribute.md | 22 + docs/examples/databases/create.md | 17 + docs/examples/databases/delete-attribute.md | 17 + docs/examples/databases/delete-collection.md | 16 + docs/examples/databases/delete-documents.md | 18 + docs/examples/databases/delete-index.md | 17 + docs/examples/databases/delete.md | 15 + docs/examples/databases/get-attribute.md | 17 + docs/examples/databases/get-collection.md | 16 + docs/examples/databases/get-index.md | 17 + docs/examples/databases/get.md | 15 + docs/examples/databases/list-attributes.md | 18 + docs/examples/databases/list-collections.md | 18 + docs/examples/databases/list-indexes.md | 18 + docs/examples/databases/list.md | 17 + .../databases/update-big-int-attribute.md | 22 + .../databases/update-boolean-attribute.md | 20 + docs/examples/databases/update-collection.md | 21 + .../databases/update-datetime-attribute.md | 20 + docs/examples/databases/update-documents.md | 25 + .../databases/update-email-attribute.md | 20 + .../databases/update-enum-attribute.md | 21 + .../databases/update-float-attribute.md | 22 + .../databases/update-integer-attribute.md | 22 + .../examples/databases/update-ip-attribute.md | 20 + .../databases/update-line-attribute.md | 20 + .../databases/update-longtext-attribute.md | 20 + .../databases/update-mediumtext-attribute.md | 20 + .../databases/update-point-attribute.md | 20 + .../databases/update-polygon-attribute.md | 20 + .../update-relationship-attribute.md | 19 + .../databases/update-string-attribute.md | 21 + .../databases/update-text-attribute.md | 20 + .../databases/update-url-attribute.md | 20 + .../databases/update-varchar-attribute.md | 21 + docs/examples/databases/update.md | 17 + docs/examples/databases/upsert-documents.md | 18 + docs/examples/functions/create-deployment.md | 19 + .../functions/create-duplicate-deployment.md | 17 + .../functions/create-template-deployment.md | 21 + docs/examples/functions/create-variable.md | 19 + .../functions/create-vcs-deployment.md | 18 + docs/examples/functions/create.md | 34 + docs/examples/functions/delete-deployment.md | 16 + docs/examples/functions/delete-execution.md | 16 + docs/examples/functions/delete-variable.md | 16 + docs/examples/functions/delete.md | 15 + .../functions/get-deployment-download.md | 17 + docs/examples/functions/get-deployment.md | 16 + docs/examples/functions/get-variable.md | 16 + docs/examples/functions/get.md | 15 + docs/examples/functions/list-deployments.md | 18 + docs/examples/functions/list-runtimes.md | 13 + .../examples/functions/list-specifications.md | 13 + docs/examples/functions/list-variables.md | 17 + docs/examples/functions/list.md | 17 + .../functions/update-deployment-status.md | 16 + .../functions/update-function-deployment.md | 16 + docs/examples/functions/update-variable.md | 19 + docs/examples/functions/update.md | 34 + docs/examples/health/get-antivirus.md | 13 + docs/examples/health/get-cache.md | 13 + docs/examples/health/get-certificate.md | 15 + docs/examples/health/get-console-pausing.md | 16 + docs/examples/health/get-db.md | 13 + docs/examples/health/get-failed-jobs.md | 16 + docs/examples/health/get-pub-sub.md | 13 + docs/examples/health/get-queue-audits.md | 15 + docs/examples/health/get-queue-builds.md | 15 + .../examples/health/get-queue-certificates.md | 15 + docs/examples/health/get-queue-databases.md | 16 + docs/examples/health/get-queue-deletes.md | 15 + docs/examples/health/get-queue-functions.md | 15 + docs/examples/health/get-queue-logs.md | 15 + docs/examples/health/get-queue-mails.md | 15 + docs/examples/health/get-queue-messaging.md | 15 + docs/examples/health/get-queue-migrations.md | 15 + .../health/get-queue-stats-resources.md | 15 + docs/examples/health/get-queue-usage.md | 15 + docs/examples/health/get-queue-webhooks.md | 15 + docs/examples/health/get-storage-local.md | 13 + docs/examples/health/get-storage.md | 13 + docs/examples/health/get-time.md | 13 + docs/examples/health/get.md | 13 + .../messaging/create-apns-provider.md | 22 + docs/examples/messaging/create-email.md | 26 + .../examples/messaging/create-fcm-provider.md | 18 + .../messaging/create-mailgun-provider.md | 24 + .../messaging/create-msg-91-provider.md | 20 + docs/examples/messaging/create-push.md | 33 + .../messaging/create-resend-provider.md | 22 + .../messaging/create-sendgrid-provider.md | 22 + docs/examples/messaging/create-sms.md | 21 + .../messaging/create-smtp-provider.md | 28 + .../messaging/create-telesign-provider.md | 20 + .../messaging/create-textmagic-provider.md | 20 + docs/examples/messaging/create-topic.md | 17 + .../messaging/create-twilio-provider.md | 20 + .../messaging/create-vonage-provider.md | 20 + docs/examples/messaging/delete-provider.md | 15 + docs/examples/messaging/delete-topic.md | 15 + docs/examples/messaging/delete.md | 15 + docs/examples/messaging/get-message.md | 15 + docs/examples/messaging/get-provider.md | 15 + docs/examples/messaging/get-subscriber.md | 16 + docs/examples/messaging/get-topic.md | 15 + docs/examples/messaging/list-message-logs.md | 17 + docs/examples/messaging/list-messages.md | 17 + docs/examples/messaging/list-provider-logs.md | 17 + docs/examples/messaging/list-providers.md | 17 + .../messaging/list-subscriber-logs.md | 17 + docs/examples/messaging/list-subscribers.md | 18 + docs/examples/messaging/list-targets.md | 17 + docs/examples/messaging/list-topic-logs.md | 17 + docs/examples/messaging/list-topics.md | 17 + .../messaging/update-apns-provider.md | 22 + docs/examples/messaging/update-email.md | 26 + .../examples/messaging/update-fcm-provider.md | 18 + .../messaging/update-mailgun-provider.md | 24 + .../messaging/update-msg-91-provider.md | 20 + docs/examples/messaging/update-push.md | 33 + .../messaging/update-resend-provider.md | 22 + .../messaging/update-sendgrid-provider.md | 22 + docs/examples/messaging/update-sms.md | 21 + .../messaging/update-smtp-provider.md | 28 + .../messaging/update-telesign-provider.md | 20 + .../messaging/update-textmagic-provider.md | 20 + docs/examples/messaging/update-topic.md | 17 + .../messaging/update-twilio-provider.md | 20 + .../messaging/update-vonage-provider.md | 20 + docs/examples/presences/update.md | 1 + docs/examples/presences/upsert.md | 1 + .../project/create-android-platform.md | 17 + .../examples/project/create-apple-platform.md | 17 + docs/examples/project/create-ephemeral-key.md | 16 + docs/examples/project/create-key.md | 18 + .../examples/project/create-linux-platform.md | 17 + docs/examples/project/create-mock-phone.md | 16 + docs/examples/project/create-smtp-test.md | 15 + docs/examples/project/create-variable.md | 18 + docs/examples/project/create-web-platform.md | 17 + .../project/create-windows-platform.md | 17 + docs/examples/project/delete-key.md | 15 + docs/examples/project/delete-mock-phone.md | 15 + docs/examples/project/delete-platform.md | 15 + docs/examples/project/delete-variable.md | 15 + docs/examples/project/delete.md | 13 + docs/examples/project/get-email-template.md | 16 + docs/examples/project/get-key.md | 15 + docs/examples/project/get-mock-phone.md | 15 + .../examples/project/get-o-auth-2-provider.md | 15 + docs/examples/project/get-platform.md | 15 + docs/examples/project/get-policy.md | 15 + docs/examples/project/get-variable.md | 15 + docs/examples/project/get.md | 13 + docs/examples/project/list-email-templates.md | 16 + docs/examples/project/list-keys.md | 16 + docs/examples/project/list-mock-phones.md | 16 + .../project/list-o-auth-2-providers.md | 16 + docs/examples/project/list-platforms.md | 16 + docs/examples/project/list-policies.md | 16 + docs/examples/project/list-variables.md | 16 + .../project/update-android-platform.md | 17 + .../examples/project/update-apple-platform.md | 17 + docs/examples/project/update-auth-method.md | 16 + .../update-deny-aliased-email-policy.md | 15 + .../update-deny-disposable-email-policy.md | 15 + .../project/update-deny-free-email-policy.md | 15 + .../examples/project/update-email-template.md | 22 + docs/examples/project/update-key.md | 18 + docs/examples/project/update-labels.md | 15 + .../examples/project/update-linux-platform.md | 17 + .../update-membership-privacy-policy.md | 19 + docs/examples/project/update-mock-phone.md | 16 + .../project/update-o-auth-2-amazon.md | 17 + .../examples/project/update-o-auth-2-apple.md | 19 + .../project/update-o-auth-2-auth-0.md | 18 + .../project/update-o-auth-2-authentik.md | 18 + .../project/update-o-auth-2-autodesk.md | 17 + .../project/update-o-auth-2-bitbucket.md | 17 + .../examples/project/update-o-auth-2-bitly.md | 17 + docs/examples/project/update-o-auth-2-box.md | 17 + .../project/update-o-auth-2-dailymotion.md | 17 + .../project/update-o-auth-2-discord.md | 17 + .../project/update-o-auth-2-disqus.md | 17 + .../project/update-o-auth-2-dropbox.md | 17 + docs/examples/project/update-o-auth-2-etsy.md | 17 + .../project/update-o-auth-2-facebook.md | 17 + .../examples/project/update-o-auth-2-figma.md | 17 + .../project/update-o-auth-2-fusion-auth.md | 18 + .../project/update-o-auth-2-git-hub.md | 17 + .../project/update-o-auth-2-gitlab.md | 18 + .../project/update-o-auth-2-google.md | 18 + .../project/update-o-auth-2-keycloak.md | 19 + docs/examples/project/update-o-auth-2-kick.md | 17 + .../project/update-o-auth-2-linkedin.md | 17 + .../project/update-o-auth-2-microsoft.md | 18 + .../project/update-o-auth-2-notion.md | 17 + docs/examples/project/update-o-auth-2-oidc.md | 21 + docs/examples/project/update-o-auth-2-okta.md | 19 + .../project/update-o-auth-2-paypal-sandbox.md | 17 + .../project/update-o-auth-2-paypal.md | 17 + .../examples/project/update-o-auth-2-podio.md | 17 + .../project/update-o-auth-2-salesforce.md | 17 + .../examples/project/update-o-auth-2-slack.md | 17 + .../project/update-o-auth-2-spotify.md | 17 + .../project/update-o-auth-2-stripe.md | 17 + .../update-o-auth-2-tradeshift-sandbox.md | 17 + .../project/update-o-auth-2-tradeshift.md | 17 + .../project/update-o-auth-2-twitch.md | 17 + .../project/update-o-auth-2-word-press.md | 17 + .../examples/project/update-o-auth-2-yahoo.md | 17 + .../project/update-o-auth-2-yandex.md | 17 + docs/examples/project/update-o-auth-2-zoho.md | 17 + docs/examples/project/update-o-auth-2-zoom.md | 17 + docs/examples/project/update-o-auth-2x.md | 17 + .../update-password-dictionary-policy.md | 15 + .../project/update-password-history-policy.md | 15 + .../update-password-personal-data-policy.md | 15 + docs/examples/project/update-protocol.md | 16 + docs/examples/project/update-service.md | 16 + .../project/update-session-alert-policy.md | 15 + .../project/update-session-duration-policy.md | 15 + .../update-session-invalidation-policy.md | 15 + .../project/update-session-limit-policy.md | 15 + docs/examples/project/update-smtp.md | 24 + .../project/update-user-limit-policy.md | 15 + docs/examples/project/update-variable.md | 18 + docs/examples/project/update-web-platform.md | 17 + .../project/update-windows-platform.md | 17 + docs/examples/proxy/create-api-rule.md | 15 + docs/examples/proxy/create-function-rule.md | 17 + docs/examples/proxy/create-redirect-rule.md | 19 + docs/examples/proxy/create-site-rule.md | 17 + docs/examples/proxy/delete-rule.md | 15 + docs/examples/proxy/get-rule.md | 15 + docs/examples/proxy/list-rules.md | 16 + docs/examples/proxy/update-rule-status.md | 15 + docs/examples/sites/create-deployment.md | 20 + .../sites/create-duplicate-deployment.md | 16 + .../sites/create-template-deployment.md | 21 + docs/examples/sites/create-variable.md | 19 + docs/examples/sites/create-vcs-deployment.md | 18 + docs/examples/sites/create.md | 35 + docs/examples/sites/delete-deployment.md | 16 + docs/examples/sites/delete-log.md | 16 + docs/examples/sites/delete-variable.md | 16 + docs/examples/sites/delete.md | 15 + .../examples/sites/get-deployment-download.md | 17 + docs/examples/sites/get-deployment.md | 16 + docs/examples/sites/get-log.md | 16 + docs/examples/sites/get-variable.md | 16 + docs/examples/sites/get.md | 15 + docs/examples/sites/list-deployments.md | 18 + docs/examples/sites/list-frameworks.md | 13 + docs/examples/sites/list-logs.md | 17 + docs/examples/sites/list-specifications.md | 13 + docs/examples/sites/list-variables.md | 17 + docs/examples/sites/list.md | 17 + .../sites/update-deployment-status.md | 16 + docs/examples/sites/update-site-deployment.md | 16 + docs/examples/sites/update-variable.md | 19 + docs/examples/sites/update.md | 35 + docs/examples/storage/create-bucket.md | 25 + docs/examples/storage/delete-bucket.md | 15 + docs/examples/storage/get-bucket.md | 15 + docs/examples/storage/list-buckets.md | 17 + docs/examples/storage/update-bucket.md | 25 + .../tablesdb/create-big-int-column.md | 22 + .../tablesdb/create-boolean-column.md | 20 + .../tablesdb/create-datetime-column.md | 20 + docs/examples/tablesdb/create-email-column.md | 20 + docs/examples/tablesdb/create-enum-column.md | 21 + docs/examples/tablesdb/create-float-column.md | 22 + docs/examples/tablesdb/create-index.md | 21 + .../tablesdb/create-integer-column.md | 22 + docs/examples/tablesdb/create-ip-column.md | 20 + docs/examples/tablesdb/create-line-column.md | 19 + .../tablesdb/create-longtext-column.md | 21 + .../tablesdb/create-mediumtext-column.md | 21 + docs/examples/tablesdb/create-point-column.md | 19 + .../tablesdb/create-polygon-column.md | 19 + .../tablesdb/create-relationship-column.md | 22 + docs/examples/tablesdb/create-row.md | 5 +- .../examples/tablesdb/create-string-column.md | 22 + docs/examples/tablesdb/create-table.md | 22 + docs/examples/tablesdb/create-text-column.md | 21 + docs/examples/tablesdb/create-url-column.md | 20 + .../tablesdb/create-varchar-column.md | 22 + docs/examples/tablesdb/create.md | 17 + docs/examples/tablesdb/delete-column.md | 17 + docs/examples/tablesdb/delete-index.md | 17 + docs/examples/tablesdb/delete-rows.md | 18 + docs/examples/tablesdb/delete-table.md | 16 + docs/examples/tablesdb/delete.md | 15 + docs/examples/tablesdb/get-column.md | 17 + docs/examples/tablesdb/get-index.md | 17 + docs/examples/tablesdb/get-table.md | 16 + docs/examples/tablesdb/get.md | 15 + docs/examples/tablesdb/list-columns.md | 18 + docs/examples/tablesdb/list-indexes.md | 18 + docs/examples/tablesdb/list-tables.md | 18 + docs/examples/tablesdb/list.md | 17 + .../tablesdb/update-big-int-column.md | 22 + .../tablesdb/update-boolean-column.md | 20 + .../tablesdb/update-datetime-column.md | 20 + docs/examples/tablesdb/update-email-column.md | 20 + docs/examples/tablesdb/update-enum-column.md | 21 + docs/examples/tablesdb/update-float-column.md | 22 + .../tablesdb/update-integer-column.md | 22 + docs/examples/tablesdb/update-ip-column.md | 20 + docs/examples/tablesdb/update-line-column.md | 20 + .../tablesdb/update-longtext-column.md | 20 + .../tablesdb/update-mediumtext-column.md | 20 + docs/examples/tablesdb/update-point-column.md | 20 + .../tablesdb/update-polygon-column.md | 20 + .../tablesdb/update-relationship-column.md | 19 + docs/examples/tablesdb/update-rows.md | 25 + .../examples/tablesdb/update-string-column.md | 21 + docs/examples/tablesdb/update-table.md | 21 + docs/examples/tablesdb/update-text-column.md | 20 + docs/examples/tablesdb/update-url-column.md | 20 + .../tablesdb/update-varchar-column.md | 21 + docs/examples/tablesdb/update.md | 17 + docs/examples/tablesdb/upsert-rows.md | 18 + docs/examples/tokens/create-file-token.md | 17 + docs/examples/tokens/delete.md | 15 + docs/examples/tokens/get.md | 15 + docs/examples/tokens/list.md | 18 + docs/examples/tokens/update.md | 16 + docs/examples/usage/list-events.md | 16 + docs/examples/usage/list-gauges.md | 16 + docs/examples/users/create-argon-2-user.md | 18 + docs/examples/users/create-bcrypt-user.md | 18 + docs/examples/users/create-jwt.md | 17 + docs/examples/users/create-md-5-user.md | 18 + .../users/create-mfa-recovery-codes.md | 15 + docs/examples/users/create-ph-pass-user.md | 18 + .../users/create-scrypt-modified-user.md | 21 + docs/examples/users/create-scrypt-user.md | 23 + docs/examples/users/create-session.md | 15 + docs/examples/users/create-sha-user.md | 19 + docs/examples/users/create-target.md | 20 + docs/examples/users/create-token.md | 17 + docs/examples/users/create.md | 19 + docs/examples/users/delete-identity.md | 15 + .../users/delete-mfa-authenticator.md | 16 + .../delete-session.md} | 8 +- docs/examples/users/delete-sessions.md | 15 + docs/examples/users/delete-target.md | 16 + docs/examples/users/delete.md | 15 + docs/examples/users/get-mfa-recovery-codes.md | 15 + docs/examples/users/get-prefs.md | 15 + docs/examples/users/get-target.md | 16 + docs/examples/users/get.md | 15 + docs/examples/users/list-identities.md | 17 + docs/examples/users/list-logs.md | 17 + docs/examples/users/list-memberships.md | 18 + docs/examples/users/list-mfa-factors.md | 15 + docs/examples/users/list-sessions.md | 16 + docs/examples/users/list-targets.md | 17 + docs/examples/users/list.md | 17 + .../users/update-email-verification.md | 16 + docs/examples/users/update-email.md | 16 + docs/examples/users/update-impersonator.md | 16 + docs/examples/users/update-labels.md | 16 + .../users/update-mfa-recovery-codes.md | 15 + docs/examples/users/update-mfa.md | 16 + docs/examples/users/update-name.md | 16 + docs/examples/users/update-password.md | 16 + .../users/update-phone-verification.md | 16 + docs/examples/users/update-phone.md | 16 + docs/examples/users/update-prefs.md | 16 + docs/examples/users/update-status.md | 16 + docs/examples/users/update-target.md | 19 + docs/examples/webhooks/create.md | 23 + docs/examples/webhooks/delete.md | 15 + docs/examples/webhooks/get.md | 15 + docs/examples/webhooks/list.md | 16 + docs/examples/webhooks/update-secret.md | 16 + docs/examples/webhooks/update.md | 22 + package-lock.json | 4 +- package.json | 2 +- src/client.ts | 388 +- src/enums/adapter.ts | 4 + src/enums/attribute-status.ts | 7 + src/enums/backup-services.ts | 8 + src/enums/build-runtime.ts | 91 + src/enums/column-status.ts | 7 + src/enums/compression.ts | 5 + src/enums/database-type.ts | 6 + src/enums/databases-index-type.ts | 6 + src/enums/deployment-download-type.ts | 4 + src/enums/deployment-status.ts | 8 + src/enums/framework.ts | 17 + src/enums/health-antivirus-status.ts | 5 + src/enums/health-check-status.ts | 4 + src/enums/index-status.ts | 7 + src/enums/message-priority.ts | 4 + src/enums/message-status.ts | 7 + src/enums/messaging-provider-type.ts | 5 + src/enums/name.ts | 15 + src/enums/o-auth-2-google-prompt.ts | 5 + src/enums/order-by.ts | 4 + src/enums/password-hash.ts | 13 + src/enums/platform-type.ts | 7 + src/enums/project-auth-method-id.ts | 9 + src/enums/project-email-template-id.ts | 9 + src/enums/project-email-template-locale.ts | 133 + src/enums/project-key-scopes.ts | 96 + src/enums/project-o-auth-2-google-prompt.ts | 5 + src/enums/project-o-auth-provider-id.ts | 47 + src/enums/project-policy-id.ts | 11 + src/enums/project-protocol-id.ts | 5 + src/enums/project-service-id.ts | 20 + src/enums/project-smtp-secure.ts | 4 + src/enums/proxy-resource-type.ts | 4 + .../proxy-rule-deployment-resource-type.ts | 4 + src/enums/proxy-rule-status.ts | 5 + src/enums/relation-mutate.ts | 5 + src/enums/relationship-type.ts | 6 + src/enums/runtime.ts | 91 + src/enums/scopes.ts | 96 + src/enums/smtp-encryption.ts | 5 + src/enums/status-code.ts | 6 + src/enums/tables-db-index-type.ts | 6 + src/enums/template-reference-type.ts | 5 + src/enums/vcs-reference-type.ts | 5 + src/index.ts | 57 +- src/models.ts | 6951 +++++++++++++++-- src/services/account.ts | 539 +- src/services/activities.ts | 123 + src/services/advisor.ts | 316 + src/services/avatars.ts | 40 +- src/services/backups.ts | 761 ++ src/services/databases.ts | 5280 ++++++++++++- src/services/functions.ts | 1965 ++++- src/services/graphql.ts | 25 +- src/services/health.ts | 1050 +++ src/services/locale.ts | 25 +- src/services/messaging.ts | 4215 +++++++++- src/services/presences.ts | 79 +- src/services/project.ts | 6466 +++++++++++++++ src/services/proxy.ts | 548 ++ src/services/realtime.ts | 34 +- src/services/sites.ts | 1924 +++++ src/services/storage.ts | 455 +- src/services/tables-db.ts | 5166 +++++++++++- src/services/teams.ts | 25 +- src/services/tokens.ts | 322 + src/services/usage.ts | 137 + src/services/users.ts | 2948 +++++++ src/services/webhooks.ts | 473 ++ 503 files changed, 46998 insertions(+), 1608 deletions(-) rename docs/examples/{account/create-verification.md => activities/get-event.md} (56%) create mode 100644 docs/examples/activities/list-events.md create mode 100644 docs/examples/advisor/delete-report.md create mode 100644 docs/examples/advisor/get-insight.md create mode 100644 docs/examples/advisor/get-report.md create mode 100644 docs/examples/advisor/list-insights.md create mode 100644 docs/examples/advisor/list-reports.md create mode 100644 docs/examples/backups/create-archive.md create mode 100644 docs/examples/backups/create-policy.md create mode 100644 docs/examples/backups/create-restoration.md create mode 100644 docs/examples/backups/delete-archive.md create mode 100644 docs/examples/backups/delete-policy.md create mode 100644 docs/examples/backups/get-archive.md create mode 100644 docs/examples/backups/get-policy.md create mode 100644 docs/examples/backups/get-restoration.md create mode 100644 docs/examples/backups/list-archives.md create mode 100644 docs/examples/backups/list-policies.md create mode 100644 docs/examples/backups/list-restorations.md create mode 100644 docs/examples/backups/update-policy.md create mode 100644 docs/examples/databases/create-big-int-attribute.md create mode 100644 docs/examples/databases/create-boolean-attribute.md create mode 100644 docs/examples/databases/create-collection.md create mode 100644 docs/examples/databases/create-datetime-attribute.md create mode 100644 docs/examples/databases/create-email-attribute.md create mode 100644 docs/examples/databases/create-enum-attribute.md create mode 100644 docs/examples/databases/create-float-attribute.md create mode 100644 docs/examples/databases/create-index.md create mode 100644 docs/examples/databases/create-integer-attribute.md create mode 100644 docs/examples/databases/create-ip-attribute.md create mode 100644 docs/examples/databases/create-line-attribute.md create mode 100644 docs/examples/databases/create-longtext-attribute.md create mode 100644 docs/examples/databases/create-mediumtext-attribute.md create mode 100644 docs/examples/databases/create-point-attribute.md create mode 100644 docs/examples/databases/create-polygon-attribute.md create mode 100644 docs/examples/databases/create-relationship-attribute.md create mode 100644 docs/examples/databases/create-string-attribute.md create mode 100644 docs/examples/databases/create-text-attribute.md create mode 100644 docs/examples/databases/create-url-attribute.md create mode 100644 docs/examples/databases/create-varchar-attribute.md create mode 100644 docs/examples/databases/create.md create mode 100644 docs/examples/databases/delete-attribute.md create mode 100644 docs/examples/databases/delete-collection.md create mode 100644 docs/examples/databases/delete-documents.md create mode 100644 docs/examples/databases/delete-index.md create mode 100644 docs/examples/databases/delete.md create mode 100644 docs/examples/databases/get-attribute.md create mode 100644 docs/examples/databases/get-collection.md create mode 100644 docs/examples/databases/get-index.md create mode 100644 docs/examples/databases/get.md create mode 100644 docs/examples/databases/list-attributes.md create mode 100644 docs/examples/databases/list-collections.md create mode 100644 docs/examples/databases/list-indexes.md create mode 100644 docs/examples/databases/list.md create mode 100644 docs/examples/databases/update-big-int-attribute.md create mode 100644 docs/examples/databases/update-boolean-attribute.md create mode 100644 docs/examples/databases/update-collection.md create mode 100644 docs/examples/databases/update-datetime-attribute.md create mode 100644 docs/examples/databases/update-documents.md create mode 100644 docs/examples/databases/update-email-attribute.md create mode 100644 docs/examples/databases/update-enum-attribute.md create mode 100644 docs/examples/databases/update-float-attribute.md create mode 100644 docs/examples/databases/update-integer-attribute.md create mode 100644 docs/examples/databases/update-ip-attribute.md create mode 100644 docs/examples/databases/update-line-attribute.md create mode 100644 docs/examples/databases/update-longtext-attribute.md create mode 100644 docs/examples/databases/update-mediumtext-attribute.md create mode 100644 docs/examples/databases/update-point-attribute.md create mode 100644 docs/examples/databases/update-polygon-attribute.md create mode 100644 docs/examples/databases/update-relationship-attribute.md create mode 100644 docs/examples/databases/update-string-attribute.md create mode 100644 docs/examples/databases/update-text-attribute.md create mode 100644 docs/examples/databases/update-url-attribute.md create mode 100644 docs/examples/databases/update-varchar-attribute.md create mode 100644 docs/examples/databases/update.md create mode 100644 docs/examples/databases/upsert-documents.md create mode 100644 docs/examples/functions/create-deployment.md create mode 100644 docs/examples/functions/create-duplicate-deployment.md create mode 100644 docs/examples/functions/create-template-deployment.md create mode 100644 docs/examples/functions/create-variable.md create mode 100644 docs/examples/functions/create-vcs-deployment.md create mode 100644 docs/examples/functions/create.md create mode 100644 docs/examples/functions/delete-deployment.md create mode 100644 docs/examples/functions/delete-execution.md create mode 100644 docs/examples/functions/delete-variable.md create mode 100644 docs/examples/functions/delete.md create mode 100644 docs/examples/functions/get-deployment-download.md create mode 100644 docs/examples/functions/get-deployment.md create mode 100644 docs/examples/functions/get-variable.md create mode 100644 docs/examples/functions/get.md create mode 100644 docs/examples/functions/list-deployments.md create mode 100644 docs/examples/functions/list-runtimes.md create mode 100644 docs/examples/functions/list-specifications.md create mode 100644 docs/examples/functions/list-variables.md create mode 100644 docs/examples/functions/list.md create mode 100644 docs/examples/functions/update-deployment-status.md create mode 100644 docs/examples/functions/update-function-deployment.md create mode 100644 docs/examples/functions/update-variable.md create mode 100644 docs/examples/functions/update.md create mode 100644 docs/examples/health/get-antivirus.md create mode 100644 docs/examples/health/get-cache.md create mode 100644 docs/examples/health/get-certificate.md create mode 100644 docs/examples/health/get-console-pausing.md create mode 100644 docs/examples/health/get-db.md create mode 100644 docs/examples/health/get-failed-jobs.md create mode 100644 docs/examples/health/get-pub-sub.md create mode 100644 docs/examples/health/get-queue-audits.md create mode 100644 docs/examples/health/get-queue-builds.md create mode 100644 docs/examples/health/get-queue-certificates.md create mode 100644 docs/examples/health/get-queue-databases.md create mode 100644 docs/examples/health/get-queue-deletes.md create mode 100644 docs/examples/health/get-queue-functions.md create mode 100644 docs/examples/health/get-queue-logs.md create mode 100644 docs/examples/health/get-queue-mails.md create mode 100644 docs/examples/health/get-queue-messaging.md create mode 100644 docs/examples/health/get-queue-migrations.md create mode 100644 docs/examples/health/get-queue-stats-resources.md create mode 100644 docs/examples/health/get-queue-usage.md create mode 100644 docs/examples/health/get-queue-webhooks.md create mode 100644 docs/examples/health/get-storage-local.md create mode 100644 docs/examples/health/get-storage.md create mode 100644 docs/examples/health/get-time.md create mode 100644 docs/examples/health/get.md create mode 100644 docs/examples/messaging/create-apns-provider.md create mode 100644 docs/examples/messaging/create-email.md create mode 100644 docs/examples/messaging/create-fcm-provider.md create mode 100644 docs/examples/messaging/create-mailgun-provider.md create mode 100644 docs/examples/messaging/create-msg-91-provider.md create mode 100644 docs/examples/messaging/create-push.md create mode 100644 docs/examples/messaging/create-resend-provider.md create mode 100644 docs/examples/messaging/create-sendgrid-provider.md create mode 100644 docs/examples/messaging/create-sms.md create mode 100644 docs/examples/messaging/create-smtp-provider.md create mode 100644 docs/examples/messaging/create-telesign-provider.md create mode 100644 docs/examples/messaging/create-textmagic-provider.md create mode 100644 docs/examples/messaging/create-topic.md create mode 100644 docs/examples/messaging/create-twilio-provider.md create mode 100644 docs/examples/messaging/create-vonage-provider.md create mode 100644 docs/examples/messaging/delete-provider.md create mode 100644 docs/examples/messaging/delete-topic.md create mode 100644 docs/examples/messaging/delete.md create mode 100644 docs/examples/messaging/get-message.md create mode 100644 docs/examples/messaging/get-provider.md create mode 100644 docs/examples/messaging/get-subscriber.md create mode 100644 docs/examples/messaging/get-topic.md create mode 100644 docs/examples/messaging/list-message-logs.md create mode 100644 docs/examples/messaging/list-messages.md create mode 100644 docs/examples/messaging/list-provider-logs.md create mode 100644 docs/examples/messaging/list-providers.md create mode 100644 docs/examples/messaging/list-subscriber-logs.md create mode 100644 docs/examples/messaging/list-subscribers.md create mode 100644 docs/examples/messaging/list-targets.md create mode 100644 docs/examples/messaging/list-topic-logs.md create mode 100644 docs/examples/messaging/list-topics.md create mode 100644 docs/examples/messaging/update-apns-provider.md create mode 100644 docs/examples/messaging/update-email.md create mode 100644 docs/examples/messaging/update-fcm-provider.md create mode 100644 docs/examples/messaging/update-mailgun-provider.md create mode 100644 docs/examples/messaging/update-msg-91-provider.md create mode 100644 docs/examples/messaging/update-push.md create mode 100644 docs/examples/messaging/update-resend-provider.md create mode 100644 docs/examples/messaging/update-sendgrid-provider.md create mode 100644 docs/examples/messaging/update-sms.md create mode 100644 docs/examples/messaging/update-smtp-provider.md create mode 100644 docs/examples/messaging/update-telesign-provider.md create mode 100644 docs/examples/messaging/update-textmagic-provider.md create mode 100644 docs/examples/messaging/update-topic.md create mode 100644 docs/examples/messaging/update-twilio-provider.md create mode 100644 docs/examples/messaging/update-vonage-provider.md create mode 100644 docs/examples/project/create-android-platform.md create mode 100644 docs/examples/project/create-apple-platform.md create mode 100644 docs/examples/project/create-ephemeral-key.md create mode 100644 docs/examples/project/create-key.md create mode 100644 docs/examples/project/create-linux-platform.md create mode 100644 docs/examples/project/create-mock-phone.md create mode 100644 docs/examples/project/create-smtp-test.md create mode 100644 docs/examples/project/create-variable.md create mode 100644 docs/examples/project/create-web-platform.md create mode 100644 docs/examples/project/create-windows-platform.md create mode 100644 docs/examples/project/delete-key.md create mode 100644 docs/examples/project/delete-mock-phone.md create mode 100644 docs/examples/project/delete-platform.md create mode 100644 docs/examples/project/delete-variable.md create mode 100644 docs/examples/project/delete.md create mode 100644 docs/examples/project/get-email-template.md create mode 100644 docs/examples/project/get-key.md create mode 100644 docs/examples/project/get-mock-phone.md create mode 100644 docs/examples/project/get-o-auth-2-provider.md create mode 100644 docs/examples/project/get-platform.md create mode 100644 docs/examples/project/get-policy.md create mode 100644 docs/examples/project/get-variable.md create mode 100644 docs/examples/project/get.md create mode 100644 docs/examples/project/list-email-templates.md create mode 100644 docs/examples/project/list-keys.md create mode 100644 docs/examples/project/list-mock-phones.md create mode 100644 docs/examples/project/list-o-auth-2-providers.md create mode 100644 docs/examples/project/list-platforms.md create mode 100644 docs/examples/project/list-policies.md create mode 100644 docs/examples/project/list-variables.md create mode 100644 docs/examples/project/update-android-platform.md create mode 100644 docs/examples/project/update-apple-platform.md create mode 100644 docs/examples/project/update-auth-method.md create mode 100644 docs/examples/project/update-deny-aliased-email-policy.md create mode 100644 docs/examples/project/update-deny-disposable-email-policy.md create mode 100644 docs/examples/project/update-deny-free-email-policy.md create mode 100644 docs/examples/project/update-email-template.md create mode 100644 docs/examples/project/update-key.md create mode 100644 docs/examples/project/update-labels.md create mode 100644 docs/examples/project/update-linux-platform.md create mode 100644 docs/examples/project/update-membership-privacy-policy.md create mode 100644 docs/examples/project/update-mock-phone.md create mode 100644 docs/examples/project/update-o-auth-2-amazon.md create mode 100644 docs/examples/project/update-o-auth-2-apple.md create mode 100644 docs/examples/project/update-o-auth-2-auth-0.md create mode 100644 docs/examples/project/update-o-auth-2-authentik.md create mode 100644 docs/examples/project/update-o-auth-2-autodesk.md create mode 100644 docs/examples/project/update-o-auth-2-bitbucket.md create mode 100644 docs/examples/project/update-o-auth-2-bitly.md create mode 100644 docs/examples/project/update-o-auth-2-box.md create mode 100644 docs/examples/project/update-o-auth-2-dailymotion.md create mode 100644 docs/examples/project/update-o-auth-2-discord.md create mode 100644 docs/examples/project/update-o-auth-2-disqus.md create mode 100644 docs/examples/project/update-o-auth-2-dropbox.md create mode 100644 docs/examples/project/update-o-auth-2-etsy.md create mode 100644 docs/examples/project/update-o-auth-2-facebook.md create mode 100644 docs/examples/project/update-o-auth-2-figma.md create mode 100644 docs/examples/project/update-o-auth-2-fusion-auth.md create mode 100644 docs/examples/project/update-o-auth-2-git-hub.md create mode 100644 docs/examples/project/update-o-auth-2-gitlab.md create mode 100644 docs/examples/project/update-o-auth-2-google.md create mode 100644 docs/examples/project/update-o-auth-2-keycloak.md create mode 100644 docs/examples/project/update-o-auth-2-kick.md create mode 100644 docs/examples/project/update-o-auth-2-linkedin.md create mode 100644 docs/examples/project/update-o-auth-2-microsoft.md create mode 100644 docs/examples/project/update-o-auth-2-notion.md create mode 100644 docs/examples/project/update-o-auth-2-oidc.md create mode 100644 docs/examples/project/update-o-auth-2-okta.md create mode 100644 docs/examples/project/update-o-auth-2-paypal-sandbox.md create mode 100644 docs/examples/project/update-o-auth-2-paypal.md create mode 100644 docs/examples/project/update-o-auth-2-podio.md create mode 100644 docs/examples/project/update-o-auth-2-salesforce.md create mode 100644 docs/examples/project/update-o-auth-2-slack.md create mode 100644 docs/examples/project/update-o-auth-2-spotify.md create mode 100644 docs/examples/project/update-o-auth-2-stripe.md create mode 100644 docs/examples/project/update-o-auth-2-tradeshift-sandbox.md create mode 100644 docs/examples/project/update-o-auth-2-tradeshift.md create mode 100644 docs/examples/project/update-o-auth-2-twitch.md create mode 100644 docs/examples/project/update-o-auth-2-word-press.md create mode 100644 docs/examples/project/update-o-auth-2-yahoo.md create mode 100644 docs/examples/project/update-o-auth-2-yandex.md create mode 100644 docs/examples/project/update-o-auth-2-zoho.md create mode 100644 docs/examples/project/update-o-auth-2-zoom.md create mode 100644 docs/examples/project/update-o-auth-2x.md create mode 100644 docs/examples/project/update-password-dictionary-policy.md create mode 100644 docs/examples/project/update-password-history-policy.md create mode 100644 docs/examples/project/update-password-personal-data-policy.md create mode 100644 docs/examples/project/update-protocol.md create mode 100644 docs/examples/project/update-service.md create mode 100644 docs/examples/project/update-session-alert-policy.md create mode 100644 docs/examples/project/update-session-duration-policy.md create mode 100644 docs/examples/project/update-session-invalidation-policy.md create mode 100644 docs/examples/project/update-session-limit-policy.md create mode 100644 docs/examples/project/update-smtp.md create mode 100644 docs/examples/project/update-user-limit-policy.md create mode 100644 docs/examples/project/update-variable.md create mode 100644 docs/examples/project/update-web-platform.md create mode 100644 docs/examples/project/update-windows-platform.md create mode 100644 docs/examples/proxy/create-api-rule.md create mode 100644 docs/examples/proxy/create-function-rule.md create mode 100644 docs/examples/proxy/create-redirect-rule.md create mode 100644 docs/examples/proxy/create-site-rule.md create mode 100644 docs/examples/proxy/delete-rule.md create mode 100644 docs/examples/proxy/get-rule.md create mode 100644 docs/examples/proxy/list-rules.md create mode 100644 docs/examples/proxy/update-rule-status.md create mode 100644 docs/examples/sites/create-deployment.md create mode 100644 docs/examples/sites/create-duplicate-deployment.md create mode 100644 docs/examples/sites/create-template-deployment.md create mode 100644 docs/examples/sites/create-variable.md create mode 100644 docs/examples/sites/create-vcs-deployment.md create mode 100644 docs/examples/sites/create.md create mode 100644 docs/examples/sites/delete-deployment.md create mode 100644 docs/examples/sites/delete-log.md create mode 100644 docs/examples/sites/delete-variable.md create mode 100644 docs/examples/sites/delete.md create mode 100644 docs/examples/sites/get-deployment-download.md create mode 100644 docs/examples/sites/get-deployment.md create mode 100644 docs/examples/sites/get-log.md create mode 100644 docs/examples/sites/get-variable.md create mode 100644 docs/examples/sites/get.md create mode 100644 docs/examples/sites/list-deployments.md create mode 100644 docs/examples/sites/list-frameworks.md create mode 100644 docs/examples/sites/list-logs.md create mode 100644 docs/examples/sites/list-specifications.md create mode 100644 docs/examples/sites/list-variables.md create mode 100644 docs/examples/sites/list.md create mode 100644 docs/examples/sites/update-deployment-status.md create mode 100644 docs/examples/sites/update-site-deployment.md create mode 100644 docs/examples/sites/update-variable.md create mode 100644 docs/examples/sites/update.md create mode 100644 docs/examples/storage/create-bucket.md create mode 100644 docs/examples/storage/delete-bucket.md create mode 100644 docs/examples/storage/get-bucket.md create mode 100644 docs/examples/storage/list-buckets.md create mode 100644 docs/examples/storage/update-bucket.md create mode 100644 docs/examples/tablesdb/create-big-int-column.md create mode 100644 docs/examples/tablesdb/create-boolean-column.md create mode 100644 docs/examples/tablesdb/create-datetime-column.md create mode 100644 docs/examples/tablesdb/create-email-column.md create mode 100644 docs/examples/tablesdb/create-enum-column.md create mode 100644 docs/examples/tablesdb/create-float-column.md create mode 100644 docs/examples/tablesdb/create-index.md create mode 100644 docs/examples/tablesdb/create-integer-column.md create mode 100644 docs/examples/tablesdb/create-ip-column.md create mode 100644 docs/examples/tablesdb/create-line-column.md create mode 100644 docs/examples/tablesdb/create-longtext-column.md create mode 100644 docs/examples/tablesdb/create-mediumtext-column.md create mode 100644 docs/examples/tablesdb/create-point-column.md create mode 100644 docs/examples/tablesdb/create-polygon-column.md create mode 100644 docs/examples/tablesdb/create-relationship-column.md create mode 100644 docs/examples/tablesdb/create-string-column.md create mode 100644 docs/examples/tablesdb/create-table.md create mode 100644 docs/examples/tablesdb/create-text-column.md create mode 100644 docs/examples/tablesdb/create-url-column.md create mode 100644 docs/examples/tablesdb/create-varchar-column.md create mode 100644 docs/examples/tablesdb/create.md create mode 100644 docs/examples/tablesdb/delete-column.md create mode 100644 docs/examples/tablesdb/delete-index.md create mode 100644 docs/examples/tablesdb/delete-rows.md create mode 100644 docs/examples/tablesdb/delete-table.md create mode 100644 docs/examples/tablesdb/delete.md create mode 100644 docs/examples/tablesdb/get-column.md create mode 100644 docs/examples/tablesdb/get-index.md create mode 100644 docs/examples/tablesdb/get-table.md create mode 100644 docs/examples/tablesdb/get.md create mode 100644 docs/examples/tablesdb/list-columns.md create mode 100644 docs/examples/tablesdb/list-indexes.md create mode 100644 docs/examples/tablesdb/list-tables.md create mode 100644 docs/examples/tablesdb/list.md create mode 100644 docs/examples/tablesdb/update-big-int-column.md create mode 100644 docs/examples/tablesdb/update-boolean-column.md create mode 100644 docs/examples/tablesdb/update-datetime-column.md create mode 100644 docs/examples/tablesdb/update-email-column.md create mode 100644 docs/examples/tablesdb/update-enum-column.md create mode 100644 docs/examples/tablesdb/update-float-column.md create mode 100644 docs/examples/tablesdb/update-integer-column.md create mode 100644 docs/examples/tablesdb/update-ip-column.md create mode 100644 docs/examples/tablesdb/update-line-column.md create mode 100644 docs/examples/tablesdb/update-longtext-column.md create mode 100644 docs/examples/tablesdb/update-mediumtext-column.md create mode 100644 docs/examples/tablesdb/update-point-column.md create mode 100644 docs/examples/tablesdb/update-polygon-column.md create mode 100644 docs/examples/tablesdb/update-relationship-column.md create mode 100644 docs/examples/tablesdb/update-rows.md create mode 100644 docs/examples/tablesdb/update-string-column.md create mode 100644 docs/examples/tablesdb/update-table.md create mode 100644 docs/examples/tablesdb/update-text-column.md create mode 100644 docs/examples/tablesdb/update-url-column.md create mode 100644 docs/examples/tablesdb/update-varchar-column.md create mode 100644 docs/examples/tablesdb/update.md create mode 100644 docs/examples/tablesdb/upsert-rows.md create mode 100644 docs/examples/tokens/create-file-token.md create mode 100644 docs/examples/tokens/delete.md create mode 100644 docs/examples/tokens/get.md create mode 100644 docs/examples/tokens/list.md create mode 100644 docs/examples/tokens/update.md create mode 100644 docs/examples/usage/list-events.md create mode 100644 docs/examples/usage/list-gauges.md create mode 100644 docs/examples/users/create-argon-2-user.md create mode 100644 docs/examples/users/create-bcrypt-user.md create mode 100644 docs/examples/users/create-jwt.md create mode 100644 docs/examples/users/create-md-5-user.md create mode 100644 docs/examples/users/create-mfa-recovery-codes.md create mode 100644 docs/examples/users/create-ph-pass-user.md create mode 100644 docs/examples/users/create-scrypt-modified-user.md create mode 100644 docs/examples/users/create-scrypt-user.md create mode 100644 docs/examples/users/create-session.md create mode 100644 docs/examples/users/create-sha-user.md create mode 100644 docs/examples/users/create-target.md create mode 100644 docs/examples/users/create-token.md create mode 100644 docs/examples/users/create.md create mode 100644 docs/examples/users/delete-identity.md create mode 100644 docs/examples/users/delete-mfa-authenticator.md rename docs/examples/{account/update-verification.md => users/delete-session.md} (60%) create mode 100644 docs/examples/users/delete-sessions.md create mode 100644 docs/examples/users/delete-target.md create mode 100644 docs/examples/users/delete.md create mode 100644 docs/examples/users/get-mfa-recovery-codes.md create mode 100644 docs/examples/users/get-prefs.md create mode 100644 docs/examples/users/get-target.md create mode 100644 docs/examples/users/get.md create mode 100644 docs/examples/users/list-identities.md create mode 100644 docs/examples/users/list-logs.md create mode 100644 docs/examples/users/list-memberships.md create mode 100644 docs/examples/users/list-mfa-factors.md create mode 100644 docs/examples/users/list-sessions.md create mode 100644 docs/examples/users/list-targets.md create mode 100644 docs/examples/users/list.md create mode 100644 docs/examples/users/update-email-verification.md create mode 100644 docs/examples/users/update-email.md create mode 100644 docs/examples/users/update-impersonator.md create mode 100644 docs/examples/users/update-labels.md create mode 100644 docs/examples/users/update-mfa-recovery-codes.md create mode 100644 docs/examples/users/update-mfa.md create mode 100644 docs/examples/users/update-name.md create mode 100644 docs/examples/users/update-password.md create mode 100644 docs/examples/users/update-phone-verification.md create mode 100644 docs/examples/users/update-phone.md create mode 100644 docs/examples/users/update-prefs.md create mode 100644 docs/examples/users/update-status.md create mode 100644 docs/examples/users/update-target.md create mode 100644 docs/examples/webhooks/create.md create mode 100644 docs/examples/webhooks/delete.md create mode 100644 docs/examples/webhooks/get.md create mode 100644 docs/examples/webhooks/list.md create mode 100644 docs/examples/webhooks/update-secret.md create mode 100644 docs/examples/webhooks/update.md create mode 100644 src/enums/adapter.ts create mode 100644 src/enums/attribute-status.ts create mode 100644 src/enums/backup-services.ts create mode 100644 src/enums/build-runtime.ts create mode 100644 src/enums/column-status.ts create mode 100644 src/enums/compression.ts create mode 100644 src/enums/database-type.ts create mode 100644 src/enums/databases-index-type.ts create mode 100644 src/enums/deployment-download-type.ts create mode 100644 src/enums/deployment-status.ts create mode 100644 src/enums/framework.ts create mode 100644 src/enums/health-antivirus-status.ts create mode 100644 src/enums/health-check-status.ts create mode 100644 src/enums/index-status.ts create mode 100644 src/enums/message-priority.ts create mode 100644 src/enums/message-status.ts create mode 100644 src/enums/messaging-provider-type.ts create mode 100644 src/enums/name.ts create mode 100644 src/enums/o-auth-2-google-prompt.ts create mode 100644 src/enums/order-by.ts create mode 100644 src/enums/password-hash.ts create mode 100644 src/enums/platform-type.ts create mode 100644 src/enums/project-auth-method-id.ts create mode 100644 src/enums/project-email-template-id.ts create mode 100644 src/enums/project-email-template-locale.ts create mode 100644 src/enums/project-key-scopes.ts create mode 100644 src/enums/project-o-auth-2-google-prompt.ts create mode 100644 src/enums/project-o-auth-provider-id.ts create mode 100644 src/enums/project-policy-id.ts create mode 100644 src/enums/project-protocol-id.ts create mode 100644 src/enums/project-service-id.ts create mode 100644 src/enums/project-smtp-secure.ts create mode 100644 src/enums/proxy-resource-type.ts create mode 100644 src/enums/proxy-rule-deployment-resource-type.ts create mode 100644 src/enums/proxy-rule-status.ts create mode 100644 src/enums/relation-mutate.ts create mode 100644 src/enums/relationship-type.ts create mode 100644 src/enums/runtime.ts create mode 100644 src/enums/scopes.ts create mode 100644 src/enums/smtp-encryption.ts create mode 100644 src/enums/status-code.ts create mode 100644 src/enums/tables-db-index-type.ts create mode 100644 src/enums/template-reference-type.ts create mode 100644 src/enums/vcs-reference-type.ts create mode 100644 src/services/activities.ts create mode 100644 src/services/advisor.ts create mode 100644 src/services/backups.ts create mode 100644 src/services/health.ts create mode 100644 src/services/project.ts create mode 100644 src/services/proxy.ts create mode 100644 src/services/sites.ts create mode 100644 src/services/tokens.ts create mode 100644 src/services/usage.ts create mode 100644 src/services/users.ts create mode 100644 src/services/webhooks.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index bbee4e7c..7e8c9dfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Change Log +## 26.0.0 + +* Added: Isomorphic `Client` typed by auth capability — services narrow available methods by auth type at compile time +* Added: Static factory constructors `Client.from`, `Client.fromSession`, `Client.fromAPIKey`, `Client.fromCookie`, `Client.fromJWT`, `Client.fromDevKey`, and `Client.fromImpersonation` +* Added: Server-side auth via `apiKey`, `cookie`, and `jwt` factories +* Added: Admin and server-only endpoints (`Users`, `Projects`, function and site deployments, storage buckets, and more) +* Deprecated: `new Client()` constructor and `setEndpoint`/`setProject`/setter pattern remain for backwards compatibility but are now marked deprecated +* Updated: `x-sdk-platform` header now reflects browser or server runtime + ## 25.1.1 * Fixed: Removed `Advisor` service and `Insight`, `InsightCTA`, `InsightList`, `Report`, `ReportList` models (admin-only endpoints, not intended for client SDKs) diff --git a/README.md b/README.md index 6ebf9c36..8044285e 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ import { Client, Account } from "appwrite"; To install with a CDN (content delivery network) add the following scripts to the bottom of your tag, but before you use any Appwrite services: ```html - + ``` diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index cf6a6098..df016baf 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.createMFAAuthenticator({ +const result = await account.createMfaAuthenticator({ type: AuthenticatorType.Totp }); diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index d9d9856d..03c03be3 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.createMFAChallenge({ +const result = await account.createMfaChallenge({ factor: AuthenticationFactor.Email }); diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index 3c292f26..42aa7ac0 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.createMFARecoveryCodes(); +const result = await account.createMfaRecoveryCodes(); console.log(result); ``` diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index 079f0b95..626b4172 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.deleteMFAAuthenticator({ +const result = await account.deleteMfaAuthenticator({ type: AuthenticatorType.Totp }); diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index 1d102583..a2bca114 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.getMFARecoveryCodes(); +const result = await account.getMfaRecoveryCodes(); console.log(result); ``` diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index 9950129b..63148467 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.listMFAFactors(); +const result = await account.listMfaFactors(); console.log(result); ``` diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index bf25c76b..7aa949c7 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.updateMFAAuthenticator({ +const result = await account.updateMfaAuthenticator({ type: AuthenticatorType.Totp, otp: '' }); diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index a16ea43a..34e5b267 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.updateMFAChallenge({ +const result = await account.updateMfaChallenge({ challengeId: '', otp: '' }); diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index 8bc8273c..3d22c889 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.updateMFARecoveryCodes(); +const result = await account.updateMfaRecoveryCodes(); console.log(result); ``` diff --git a/docs/examples/account/create-verification.md b/docs/examples/activities/get-event.md similarity index 56% rename from docs/examples/account/create-verification.md rename to docs/examples/activities/get-event.md index 0795d0ac..b3259ff8 100644 --- a/docs/examples/account/create-verification.md +++ b/docs/examples/activities/get-event.md @@ -1,14 +1,14 @@ ```javascript -import { Client, Account } from "appwrite"; +import { Client, Activities } from "appwrite"; const client = new Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint .setProject(''); // Your project ID -const account = new Account(client); +const activities = new Activities(client); -const result = await account.createVerification({ - url: 'https://example.com' +const result = await activities.getEvent({ + eventId: '' }); console.log(result); diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md new file mode 100644 index 00000000..883371e3 --- /dev/null +++ b/docs/examples/activities/list-events.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Activities } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const activities = new Activities(client); + +const result = await activities.listEvents({ + queries: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/advisor/delete-report.md b/docs/examples/advisor/delete-report.md new file mode 100644 index 00000000..3237bea0 --- /dev/null +++ b/docs/examples/advisor/delete-report.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Advisor } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const advisor = new Advisor(client); + +const result = await advisor.deleteReport({ + reportId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/advisor/get-insight.md b/docs/examples/advisor/get-insight.md new file mode 100644 index 00000000..28661f98 --- /dev/null +++ b/docs/examples/advisor/get-insight.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Advisor } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const advisor = new Advisor(client); + +const result = await advisor.getInsight({ + reportId: '', + insightId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/advisor/get-report.md b/docs/examples/advisor/get-report.md new file mode 100644 index 00000000..79736784 --- /dev/null +++ b/docs/examples/advisor/get-report.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Advisor } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const advisor = new Advisor(client); + +const result = await advisor.getReport({ + reportId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/advisor/list-insights.md b/docs/examples/advisor/list-insights.md new file mode 100644 index 00000000..c9b8f2ea --- /dev/null +++ b/docs/examples/advisor/list-insights.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Advisor } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const advisor = new Advisor(client); + +const result = await advisor.listInsights({ + reportId: '', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/advisor/list-reports.md b/docs/examples/advisor/list-reports.md new file mode 100644 index 00000000..9480e970 --- /dev/null +++ b/docs/examples/advisor/list-reports.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Advisor } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const advisor = new Advisor(client); + +const result = await advisor.listReports({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md new file mode 100644 index 00000000..5a0c1d32 --- /dev/null +++ b/docs/examples/backups/create-archive.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Backups, BackupServices } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.createArchive({ + services: [BackupServices.Databases], + resourceId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md new file mode 100644 index 00000000..183a19c8 --- /dev/null +++ b/docs/examples/backups/create-policy.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Backups, BackupServices } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.createPolicy({ + policyId: '', + services: [BackupServices.Databases], + retention: 1, + schedule: '', + name: '', // optional + resourceId: '', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md new file mode 100644 index 00000000..19e40470 --- /dev/null +++ b/docs/examples/backups/create-restoration.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Backups, BackupServices } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.createRestoration({ + archiveId: '', + services: [BackupServices.Databases], + newResourceId: '', // optional + newResourceName: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md new file mode 100644 index 00000000..95722eb3 --- /dev/null +++ b/docs/examples/backups/delete-archive.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Backups } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.deleteArchive({ + archiveId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md new file mode 100644 index 00000000..07499bb6 --- /dev/null +++ b/docs/examples/backups/delete-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Backups } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.deletePolicy({ + policyId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md new file mode 100644 index 00000000..2ab79ac7 --- /dev/null +++ b/docs/examples/backups/get-archive.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Backups } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.getArchive({ + archiveId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md new file mode 100644 index 00000000..aed31bf7 --- /dev/null +++ b/docs/examples/backups/get-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Backups } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.getPolicy({ + policyId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md new file mode 100644 index 00000000..c0deac84 --- /dev/null +++ b/docs/examples/backups/get-restoration.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Backups } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.getRestoration({ + restorationId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md new file mode 100644 index 00000000..33a1dd26 --- /dev/null +++ b/docs/examples/backups/list-archives.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Backups } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.listArchives({ + queries: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md new file mode 100644 index 00000000..4a7fa7bd --- /dev/null +++ b/docs/examples/backups/list-policies.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Backups } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.listPolicies({ + queries: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md new file mode 100644 index 00000000..04c3a373 --- /dev/null +++ b/docs/examples/backups/list-restorations.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Backups } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.listRestorations({ + queries: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md new file mode 100644 index 00000000..69a5503c --- /dev/null +++ b/docs/examples/backups/update-policy.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Backups } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const backups = new Backups(client); + +const result = await backups.updatePolicy({ + policyId: '', + name: '', // optional + retention: 1, // optional + schedule: '', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-big-int-attribute.md b/docs/examples/databases/create-big-int-attribute.md new file mode 100644 index 00000000..e0e4541f --- /dev/null +++ b/docs/examples/databases/create-big-int-attribute.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createBigIntAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + xdefault: null, // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-boolean-attribute.md b/docs/examples/databases/create-boolean-attribute.md new file mode 100644 index 00000000..d41f60bb --- /dev/null +++ b/docs/examples/databases/create-boolean-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createBooleanAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: false, // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-collection.md b/docs/examples/databases/create-collection.md new file mode 100644 index 00000000..0da70c48 --- /dev/null +++ b/docs/examples/databases/create-collection.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Databases, Permission, Role } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createCollection({ + databaseId: '', + collectionId: '', + name: '', + permissions: [Permission.read(Role.any())], // optional + documentSecurity: false, // optional + enabled: false, // optional + attributes: [], // optional + indexes: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md new file mode 100644 index 00000000..b59332b8 --- /dev/null +++ b/docs/examples/databases/create-datetime-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createDatetimeAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '2020-10-15T06:38:00.000+00:00', // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 4d8d7f90..eff84945 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -10,15 +10,16 @@ const databases = new Databases(client); const result = await databases.createDocument({ databaseId: '', collectionId: '', - documentId: '', + documentId: '', // optional data: { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 30, "isAdmin": false - }, + }, // optional permissions: [Permission.read(Role.any())], // optional + documents: [], // optional transactionId: '' // optional }); diff --git a/docs/examples/databases/create-email-attribute.md b/docs/examples/databases/create-email-attribute.md new file mode 100644 index 00000000..87444399 --- /dev/null +++ b/docs/examples/databases/create-email-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createEmailAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: 'email@example.com', // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md new file mode 100644 index 00000000..0787923a --- /dev/null +++ b/docs/examples/databases/create-enum-attribute.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createEnumAttribute({ + databaseId: '', + collectionId: '', + key: '', + elements: [], + required: false, + xdefault: '', // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-float-attribute.md b/docs/examples/databases/create-float-attribute.md new file mode 100644 index 00000000..3d46dc43 --- /dev/null +++ b/docs/examples/databases/create-float-attribute.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createFloatAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + xdefault: null, // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md new file mode 100644 index 00000000..7f77071a --- /dev/null +++ b/docs/examples/databases/create-index.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Databases, DatabasesIndexType, OrderBy } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createIndex({ + databaseId: '', + collectionId: '', + key: '', + type: DatabasesIndexType.Key, + attributes: [], + orders: [OrderBy.Asc], // optional + lengths: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-integer-attribute.md b/docs/examples/databases/create-integer-attribute.md new file mode 100644 index 00000000..4c700cbb --- /dev/null +++ b/docs/examples/databases/create-integer-attribute.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createIntegerAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + xdefault: null, // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-ip-attribute.md b/docs/examples/databases/create-ip-attribute.md new file mode 100644 index 00000000..3bd98af5 --- /dev/null +++ b/docs/examples/databases/create-ip-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createIpAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '', // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md new file mode 100644 index 00000000..659af6e0 --- /dev/null +++ b/docs/examples/databases/create-line-attribute.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createLineAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: [[1, 2], [3, 4], [5, 6]] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-longtext-attribute.md b/docs/examples/databases/create-longtext-attribute.md new file mode 100644 index 00000000..a1352102 --- /dev/null +++ b/docs/examples/databases/create-longtext-attribute.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createLongtextAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '', // optional + array: false, // optional + encrypt: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-mediumtext-attribute.md b/docs/examples/databases/create-mediumtext-attribute.md new file mode 100644 index 00000000..f2035f29 --- /dev/null +++ b/docs/examples/databases/create-mediumtext-attribute.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createMediumtextAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '', // optional + array: false, // optional + encrypt: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md new file mode 100644 index 00000000..46dbb28d --- /dev/null +++ b/docs/examples/databases/create-point-attribute.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createPointAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: [1, 2] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md new file mode 100644 index 00000000..d57f1e25 --- /dev/null +++ b/docs/examples/databases/create-polygon-attribute.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createPolygonAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-relationship-attribute.md b/docs/examples/databases/create-relationship-attribute.md new file mode 100644 index 00000000..d11019bd --- /dev/null +++ b/docs/examples/databases/create-relationship-attribute.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Databases, RelationshipType, RelationMutate } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createRelationshipAttribute({ + databaseId: '', + collectionId: '', + relatedCollectionId: '', + type: RelationshipType.OneToOne, + twoWay: false, // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: RelationMutate.Cascade // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-string-attribute.md b/docs/examples/databases/create-string-attribute.md new file mode 100644 index 00000000..6e284ce2 --- /dev/null +++ b/docs/examples/databases/create-string-attribute.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createStringAttribute({ + databaseId: '', + collectionId: '', + key: '', + size: 1, + required: false, + xdefault: '', // optional + array: false, // optional + encrypt: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-text-attribute.md b/docs/examples/databases/create-text-attribute.md new file mode 100644 index 00000000..c0cb5c3d --- /dev/null +++ b/docs/examples/databases/create-text-attribute.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createTextAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '', // optional + array: false, // optional + encrypt: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-url-attribute.md b/docs/examples/databases/create-url-attribute.md new file mode 100644 index 00000000..31c85599 --- /dev/null +++ b/docs/examples/databases/create-url-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createUrlAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: 'https://example.com', // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-varchar-attribute.md b/docs/examples/databases/create-varchar-attribute.md new file mode 100644 index 00000000..111ae5fd --- /dev/null +++ b/docs/examples/databases/create-varchar-attribute.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createVarcharAttribute({ + databaseId: '', + collectionId: '', + key: '', + size: 1, + required: false, + xdefault: '', // optional + array: false, // optional + encrypt: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create.md b/docs/examples/databases/create.md new file mode 100644 index 00000000..d9ec0129 --- /dev/null +++ b/docs/examples/databases/create.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.create({ + databaseId: '', + name: '', + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/delete-attribute.md b/docs/examples/databases/delete-attribute.md new file mode 100644 index 00000000..5a6f68e7 --- /dev/null +++ b/docs/examples/databases/delete-attribute.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.deleteAttribute({ + databaseId: '', + collectionId: '', + key: '' +}); + +console.log(result); +``` diff --git a/docs/examples/databases/delete-collection.md b/docs/examples/databases/delete-collection.md new file mode 100644 index 00000000..2f9d0e23 --- /dev/null +++ b/docs/examples/databases/delete-collection.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.deleteCollection({ + databaseId: '', + collectionId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md new file mode 100644 index 00000000..21e5725e --- /dev/null +++ b/docs/examples/databases/delete-documents.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.deleteDocuments({ + databaseId: '', + collectionId: '', + queries: [], // optional + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/delete-index.md b/docs/examples/databases/delete-index.md new file mode 100644 index 00000000..5a47e2db --- /dev/null +++ b/docs/examples/databases/delete-index.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.deleteIndex({ + databaseId: '', + collectionId: '', + key: '' +}); + +console.log(result); +``` diff --git a/docs/examples/databases/delete.md b/docs/examples/databases/delete.md new file mode 100644 index 00000000..b0de2e3f --- /dev/null +++ b/docs/examples/databases/delete.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.delete({ + databaseId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/databases/get-attribute.md b/docs/examples/databases/get-attribute.md new file mode 100644 index 00000000..315e3766 --- /dev/null +++ b/docs/examples/databases/get-attribute.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.getAttribute({ + databaseId: '', + collectionId: '', + key: '' +}); + +console.log(result); +``` diff --git a/docs/examples/databases/get-collection.md b/docs/examples/databases/get-collection.md new file mode 100644 index 00000000..b3341d61 --- /dev/null +++ b/docs/examples/databases/get-collection.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.getCollection({ + databaseId: '', + collectionId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/databases/get-index.md b/docs/examples/databases/get-index.md new file mode 100644 index 00000000..2347e48e --- /dev/null +++ b/docs/examples/databases/get-index.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.getIndex({ + databaseId: '', + collectionId: '', + key: '' +}); + +console.log(result); +``` diff --git a/docs/examples/databases/get.md b/docs/examples/databases/get.md new file mode 100644 index 00000000..3ecc657a --- /dev/null +++ b/docs/examples/databases/get.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.get({ + databaseId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/databases/list-attributes.md b/docs/examples/databases/list-attributes.md new file mode 100644 index 00000000..3ea4e27e --- /dev/null +++ b/docs/examples/databases/list-attributes.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.listAttributes({ + databaseId: '', + collectionId: '', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/list-collections.md b/docs/examples/databases/list-collections.md new file mode 100644 index 00000000..915c58a7 --- /dev/null +++ b/docs/examples/databases/list-collections.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.listCollections({ + databaseId: '', + queries: [], // optional + search: '', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/list-indexes.md b/docs/examples/databases/list-indexes.md new file mode 100644 index 00000000..b7bbd5e9 --- /dev/null +++ b/docs/examples/databases/list-indexes.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.listIndexes({ + databaseId: '', + collectionId: '', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/list.md b/docs/examples/databases/list.md new file mode 100644 index 00000000..bdb054c4 --- /dev/null +++ b/docs/examples/databases/list.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.list({ + queries: [], // optional + search: '', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-big-int-attribute.md b/docs/examples/databases/update-big-int-attribute.md new file mode 100644 index 00000000..df732291 --- /dev/null +++ b/docs/examples/databases/update-big-int-attribute.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateBigIntAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-boolean-attribute.md b/docs/examples/databases/update-boolean-attribute.md new file mode 100644 index 00000000..46f589bc --- /dev/null +++ b/docs/examples/databases/update-boolean-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateBooleanAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: false, + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md new file mode 100644 index 00000000..8ae672fd --- /dev/null +++ b/docs/examples/databases/update-collection.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Databases, Permission, Role } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateCollection({ + databaseId: '', + collectionId: '', + name: '', // optional + permissions: [Permission.read(Role.any())], // optional + documentSecurity: false, // optional + enabled: false, // optional + purge: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md new file mode 100644 index 00000000..3b0ab4eb --- /dev/null +++ b/docs/examples/databases/update-datetime-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateDatetimeAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '2020-10-15T06:38:00.000+00:00', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md new file mode 100644 index 00000000..ed953513 --- /dev/null +++ b/docs/examples/databases/update-documents.md @@ -0,0 +1,25 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateDocuments({ + databaseId: '', + collectionId: '', + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }, // optional + queries: [], // optional + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-email-attribute.md b/docs/examples/databases/update-email-attribute.md new file mode 100644 index 00000000..3da6e229 --- /dev/null +++ b/docs/examples/databases/update-email-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateEmailAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: 'email@example.com', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md new file mode 100644 index 00000000..a6d700e7 --- /dev/null +++ b/docs/examples/databases/update-enum-attribute.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateEnumAttribute({ + databaseId: '', + collectionId: '', + key: '', + elements: [], + required: false, + xdefault: '', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-float-attribute.md b/docs/examples/databases/update-float-attribute.md new file mode 100644 index 00000000..2502c75f --- /dev/null +++ b/docs/examples/databases/update-float-attribute.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateFloatAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-integer-attribute.md b/docs/examples/databases/update-integer-attribute.md new file mode 100644 index 00000000..4b8b26b9 --- /dev/null +++ b/docs/examples/databases/update-integer-attribute.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateIntegerAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-ip-attribute.md b/docs/examples/databases/update-ip-attribute.md new file mode 100644 index 00000000..e467a4dc --- /dev/null +++ b/docs/examples/databases/update-ip-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateIpAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md new file mode 100644 index 00000000..cb963988 --- /dev/null +++ b/docs/examples/databases/update-line-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateLineAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: [[1, 2], [3, 4], [5, 6]], // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-longtext-attribute.md b/docs/examples/databases/update-longtext-attribute.md new file mode 100644 index 00000000..ef74a098 --- /dev/null +++ b/docs/examples/databases/update-longtext-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateLongtextAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-mediumtext-attribute.md b/docs/examples/databases/update-mediumtext-attribute.md new file mode 100644 index 00000000..c3e34af0 --- /dev/null +++ b/docs/examples/databases/update-mediumtext-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateMediumtextAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md new file mode 100644 index 00000000..de0391b1 --- /dev/null +++ b/docs/examples/databases/update-point-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updatePointAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: [1, 2], // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md new file mode 100644 index 00000000..7d13baee --- /dev/null +++ b/docs/examples/databases/update-polygon-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updatePolygonAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-relationship-attribute.md b/docs/examples/databases/update-relationship-attribute.md new file mode 100644 index 00000000..51dbfd69 --- /dev/null +++ b/docs/examples/databases/update-relationship-attribute.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Databases, RelationMutate } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateRelationshipAttribute({ + databaseId: '', + collectionId: '', + key: '', + onDelete: RelationMutate.Cascade, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-string-attribute.md b/docs/examples/databases/update-string-attribute.md new file mode 100644 index 00000000..891d851b --- /dev/null +++ b/docs/examples/databases/update-string-attribute.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateStringAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '', + size: 1, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-text-attribute.md b/docs/examples/databases/update-text-attribute.md new file mode 100644 index 00000000..b954a492 --- /dev/null +++ b/docs/examples/databases/update-text-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateTextAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-url-attribute.md b/docs/examples/databases/update-url-attribute.md new file mode 100644 index 00000000..040eafe9 --- /dev/null +++ b/docs/examples/databases/update-url-attribute.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateUrlAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: 'https://example.com', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update-varchar-attribute.md b/docs/examples/databases/update-varchar-attribute.md new file mode 100644 index 00000000..67b82ae6 --- /dev/null +++ b/docs/examples/databases/update-varchar-attribute.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.updateVarcharAttribute({ + databaseId: '', + collectionId: '', + key: '', + required: false, + xdefault: '', + size: 1, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md new file mode 100644 index 00000000..aa15b64a --- /dev/null +++ b/docs/examples/databases/update.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.update({ + databaseId: '', + name: '', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md new file mode 100644 index 00000000..ade173ca --- /dev/null +++ b/docs/examples/databases/upsert-documents.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const databases = new Databases(client); + +const result = await databases.upsertDocuments({ + databaseId: '', + collectionId: '', + documents: [], + transactionId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/create-deployment.md b/docs/examples/functions/create-deployment.md new file mode 100644 index 00000000..048e8de5 --- /dev/null +++ b/docs/examples/functions/create-deployment.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.createDeployment({ + functionId: '', + code: document.getElementById('uploader').files[0], + activate: false, + entrypoint: '', // optional + commands: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/create-duplicate-deployment.md b/docs/examples/functions/create-duplicate-deployment.md new file mode 100644 index 00000000..d3cbb752 --- /dev/null +++ b/docs/examples/functions/create-duplicate-deployment.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.createDuplicateDeployment({ + functionId: '', + deploymentId: '', + buildId: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/create-template-deployment.md b/docs/examples/functions/create-template-deployment.md new file mode 100644 index 00000000..e1f5a1c5 --- /dev/null +++ b/docs/examples/functions/create-template-deployment.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Functions, TemplateReferenceType } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.createTemplateDeployment({ + functionId: '', + repository: '', + owner: '', + rootDirectory: '', + type: TemplateReferenceType.Commit, + reference: '', + activate: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/create-variable.md b/docs/examples/functions/create-variable.md new file mode 100644 index 00000000..351967ae --- /dev/null +++ b/docs/examples/functions/create-variable.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.createVariable({ + functionId: '', + variableId: '', + key: '', + value: '', + secret: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/create-vcs-deployment.md b/docs/examples/functions/create-vcs-deployment.md new file mode 100644 index 00000000..ecf7b679 --- /dev/null +++ b/docs/examples/functions/create-vcs-deployment.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Functions, VCSReferenceType } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.createVcsDeployment({ + functionId: '', + type: VCSReferenceType.Branch, + reference: '', + activate: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md new file mode 100644 index 00000000..35a6b33f --- /dev/null +++ b/docs/examples/functions/create.md @@ -0,0 +1,34 @@ +```javascript +import { Client, Functions, Runtime, Scopes } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.create({ + functionId: '', + name: '', + runtime: Runtime.Node145, + execute: ["any"], // optional + events: [], // optional + schedule: '', // optional + timeout: 1, // optional + enabled: false, // optional + logging: false, // optional + entrypoint: '', // optional + commands: '', // optional + scopes: [Scopes.ProjectRead], // optional + installationId: '', // optional + providerRepositoryId: '', // optional + providerBranch: '', // optional + providerSilentMode: false, // optional + providerRootDirectory: '', // optional + buildSpecification: '', // optional + runtimeSpecification: '', // optional + deploymentRetention: 0 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/delete-deployment.md b/docs/examples/functions/delete-deployment.md new file mode 100644 index 00000000..ea60b025 --- /dev/null +++ b/docs/examples/functions/delete-deployment.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.deleteDeployment({ + functionId: '', + deploymentId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/functions/delete-execution.md b/docs/examples/functions/delete-execution.md new file mode 100644 index 00000000..bfef2df9 --- /dev/null +++ b/docs/examples/functions/delete-execution.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.deleteExecution({ + functionId: '', + executionId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/functions/delete-variable.md b/docs/examples/functions/delete-variable.md new file mode 100644 index 00000000..d5a28b13 --- /dev/null +++ b/docs/examples/functions/delete-variable.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.deleteVariable({ + functionId: '', + variableId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/functions/delete.md b/docs/examples/functions/delete.md new file mode 100644 index 00000000..6211af35 --- /dev/null +++ b/docs/examples/functions/delete.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.delete({ + functionId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md new file mode 100644 index 00000000..eb098d89 --- /dev/null +++ b/docs/examples/functions/get-deployment-download.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Functions, DeploymentDownloadType } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = functions.getDeploymentDownload({ + functionId: '', + deploymentId: '', + type: DeploymentDownloadType.Source // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/get-deployment.md b/docs/examples/functions/get-deployment.md new file mode 100644 index 00000000..09227179 --- /dev/null +++ b/docs/examples/functions/get-deployment.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.getDeployment({ + functionId: '', + deploymentId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/functions/get-variable.md b/docs/examples/functions/get-variable.md new file mode 100644 index 00000000..dec53083 --- /dev/null +++ b/docs/examples/functions/get-variable.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.getVariable({ + functionId: '', + variableId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/functions/get.md b/docs/examples/functions/get.md new file mode 100644 index 00000000..fa5bf658 --- /dev/null +++ b/docs/examples/functions/get.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.get({ + functionId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/functions/list-deployments.md b/docs/examples/functions/list-deployments.md new file mode 100644 index 00000000..9f15b95e --- /dev/null +++ b/docs/examples/functions/list-deployments.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.listDeployments({ + functionId: '', + queries: [], // optional + search: '', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md new file mode 100644 index 00000000..6d879f03 --- /dev/null +++ b/docs/examples/functions/list-runtimes.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.listRuntimes(); + +console.log(result); +``` diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md new file mode 100644 index 00000000..19e9a4c5 --- /dev/null +++ b/docs/examples/functions/list-specifications.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.listSpecifications(); + +console.log(result); +``` diff --git a/docs/examples/functions/list-variables.md b/docs/examples/functions/list-variables.md new file mode 100644 index 00000000..fded4882 --- /dev/null +++ b/docs/examples/functions/list-variables.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.listVariables({ + functionId: '', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/list.md b/docs/examples/functions/list.md new file mode 100644 index 00000000..14ec102a --- /dev/null +++ b/docs/examples/functions/list.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.list({ + queries: [], // optional + search: '', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/update-deployment-status.md b/docs/examples/functions/update-deployment-status.md new file mode 100644 index 00000000..1368d478 --- /dev/null +++ b/docs/examples/functions/update-deployment-status.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.updateDeploymentStatus({ + functionId: '', + deploymentId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/functions/update-function-deployment.md b/docs/examples/functions/update-function-deployment.md new file mode 100644 index 00000000..b5918fd2 --- /dev/null +++ b/docs/examples/functions/update-function-deployment.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.updateFunctionDeployment({ + functionId: '', + deploymentId: '' +}); + +console.log(result); +``` diff --git a/docs/examples/functions/update-variable.md b/docs/examples/functions/update-variable.md new file mode 100644 index 00000000..58f549fe --- /dev/null +++ b/docs/examples/functions/update-variable.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Functions } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.updateVariable({ + functionId: '', + variableId: '', + key: '', // optional + value: '', // optional + secret: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md new file mode 100644 index 00000000..56394751 --- /dev/null +++ b/docs/examples/functions/update.md @@ -0,0 +1,34 @@ +```javascript +import { Client, Functions, Runtime, Scopes } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const functions = new Functions(client); + +const result = await functions.update({ + functionId: '', + name: '', + runtime: Runtime.Node145, // optional + execute: ["any"], // optional + events: [], // optional + schedule: '', // optional + timeout: 1, // optional + enabled: false, // optional + logging: false, // optional + entrypoint: '', // optional + commands: '', // optional + scopes: [Scopes.ProjectRead], // optional + installationId: '', // optional + providerRepositoryId: '', // optional + providerBranch: '', // optional + providerSilentMode: false, // optional + providerRootDirectory: '', // optional + buildSpecification: '', // optional + runtimeSpecification: '', // optional + deploymentRetention: 0 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/health/get-antivirus.md new file mode 100644 index 00000000..05c6502f --- /dev/null +++ b/docs/examples/health/get-antivirus.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getAntivirus(); + +console.log(result); +``` diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md new file mode 100644 index 00000000..1b71eee9 --- /dev/null +++ b/docs/examples/health/get-cache.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getCache(); + +console.log(result); +``` diff --git a/docs/examples/health/get-certificate.md b/docs/examples/health/get-certificate.md new file mode 100644 index 00000000..0f20e19e --- /dev/null +++ b/docs/examples/health/get-certificate.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getCertificate({ + domain: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-console-pausing.md b/docs/examples/health/get-console-pausing.md new file mode 100644 index 00000000..bca1b45a --- /dev/null +++ b/docs/examples/health/get-console-pausing.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getConsolePausing({ + threshold: null, // optional + inactivityDays: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-db.md b/docs/examples/health/get-db.md new file mode 100644 index 00000000..561b6ab7 --- /dev/null +++ b/docs/examples/health/get-db.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getDB(); + +console.log(result); +``` diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/health/get-failed-jobs.md new file mode 100644 index 00000000..737c8d8b --- /dev/null +++ b/docs/examples/health/get-failed-jobs.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Health, Name } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getFailedJobs({ + name: Name.V1Database, + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-pub-sub.md b/docs/examples/health/get-pub-sub.md new file mode 100644 index 00000000..e8244436 --- /dev/null +++ b/docs/examples/health/get-pub-sub.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getPubSub(); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-audits.md b/docs/examples/health/get-queue-audits.md new file mode 100644 index 00000000..301446b0 --- /dev/null +++ b/docs/examples/health/get-queue-audits.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueAudits({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-builds.md b/docs/examples/health/get-queue-builds.md new file mode 100644 index 00000000..a6b37dd4 --- /dev/null +++ b/docs/examples/health/get-queue-builds.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueBuilds({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/health/get-queue-certificates.md new file mode 100644 index 00000000..60e91f5f --- /dev/null +++ b/docs/examples/health/get-queue-certificates.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueCertificates({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-databases.md b/docs/examples/health/get-queue-databases.md new file mode 100644 index 00000000..23eb2561 --- /dev/null +++ b/docs/examples/health/get-queue-databases.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueDatabases({ + name: '', // optional + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-deletes.md b/docs/examples/health/get-queue-deletes.md new file mode 100644 index 00000000..77d514f2 --- /dev/null +++ b/docs/examples/health/get-queue-deletes.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueDeletes({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md new file mode 100644 index 00000000..72a18645 --- /dev/null +++ b/docs/examples/health/get-queue-functions.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueFunctions({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md new file mode 100644 index 00000000..0086f86b --- /dev/null +++ b/docs/examples/health/get-queue-logs.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueLogs({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-mails.md b/docs/examples/health/get-queue-mails.md new file mode 100644 index 00000000..7800f23b --- /dev/null +++ b/docs/examples/health/get-queue-mails.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueMails({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-messaging.md b/docs/examples/health/get-queue-messaging.md new file mode 100644 index 00000000..408e4016 --- /dev/null +++ b/docs/examples/health/get-queue-messaging.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueMessaging({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-migrations.md b/docs/examples/health/get-queue-migrations.md new file mode 100644 index 00000000..5bfaf659 --- /dev/null +++ b/docs/examples/health/get-queue-migrations.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueMigrations({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-stats-resources.md b/docs/examples/health/get-queue-stats-resources.md new file mode 100644 index 00000000..45999f02 --- /dev/null +++ b/docs/examples/health/get-queue-stats-resources.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueStatsResources({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-usage.md b/docs/examples/health/get-queue-usage.md new file mode 100644 index 00000000..ae90ba51 --- /dev/null +++ b/docs/examples/health/get-queue-usage.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueUsage({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md new file mode 100644 index 00000000..461ae283 --- /dev/null +++ b/docs/examples/health/get-queue-webhooks.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getQueueWebhooks({ + threshold: null // optional +}); + +console.log(result); +``` diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md new file mode 100644 index 00000000..6acb21e2 --- /dev/null +++ b/docs/examples/health/get-storage-local.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getStorageLocal(); + +console.log(result); +``` diff --git a/docs/examples/health/get-storage.md b/docs/examples/health/get-storage.md new file mode 100644 index 00000000..27391b51 --- /dev/null +++ b/docs/examples/health/get-storage.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getStorage(); + +console.log(result); +``` diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md new file mode 100644 index 00000000..2727c0b9 --- /dev/null +++ b/docs/examples/health/get-time.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.getTime(); + +console.log(result); +``` diff --git a/docs/examples/health/get.md b/docs/examples/health/get.md new file mode 100644 index 00000000..5dce8db6 --- /dev/null +++ b/docs/examples/health/get.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Health } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const health = new Health(client); + +const result = await health.get(); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md new file mode 100644 index 00000000..5859a952 --- /dev/null +++ b/docs/examples/messaging/create-apns-provider.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createApnsProvider({ + providerId: '', + name: '', + authKey: '', // optional + authKeyId: '', // optional + teamId: '', // optional + bundleId: '', // optional + sandbox: false, // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md new file mode 100644 index 00000000..08b5b0ed --- /dev/null +++ b/docs/examples/messaging/create-email.md @@ -0,0 +1,26 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createEmail({ + messageId: '', + subject: '', + content: '', + topics: [], // optional + users: [], // optional + targets: [], // optional + cc: [], // optional + bcc: [], // optional + attachments: [], // optional + draft: false, // optional + html: false, // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md new file mode 100644 index 00000000..aba9af52 --- /dev/null +++ b/docs/examples/messaging/create-fcm-provider.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createFcmProvider({ + providerId: '', + name: '', + serviceAccountJSON: {}, // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-mailgun-provider.md b/docs/examples/messaging/create-mailgun-provider.md new file mode 100644 index 00000000..8e231f4b --- /dev/null +++ b/docs/examples/messaging/create-mailgun-provider.md @@ -0,0 +1,24 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createMailgunProvider({ + providerId: '', + name: '', + apiKey: '', // optional + domain: '', // optional + isEuRegion: false, // optional + fromName: '', // optional + fromEmail: 'email@example.com', // optional + replyToName: '', // optional + replyToEmail: 'email@example.com', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-msg-91-provider.md b/docs/examples/messaging/create-msg-91-provider.md new file mode 100644 index 00000000..65b4493f --- /dev/null +++ b/docs/examples/messaging/create-msg-91-provider.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createMsg91Provider({ + providerId: '', + name: '', + templateId: '', // optional + senderId: '', // optional + authKey: '', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md new file mode 100644 index 00000000..1daf07b5 --- /dev/null +++ b/docs/examples/messaging/create-push.md @@ -0,0 +1,33 @@ +```javascript +import { Client, Messaging, MessagePriority } from "appwrite"; + +const client = new Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject(''); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createPush({ + messageId: '', + title: '', // optional + body: '<BODY>', // optional + topics: [], // optional + users: [], // optional + targets: [], // optional + data: {}, // optional + action: '<ACTION>', // optional + image: '<ID1:ID2>', // optional + icon: '<ICON>', // optional + sound: '<SOUND>', // optional + color: '<COLOR>', // optional + tag: '<TAG>', // optional + badge: null, // optional + draft: false, // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional + contentAvailable: false, // optional + critical: false, // optional + priority: MessagePriority.Normal // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-resend-provider.md b/docs/examples/messaging/create-resend-provider.md new file mode 100644 index 00000000..947a9e2c --- /dev/null +++ b/docs/examples/messaging/create-resend-provider.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createResendProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + apiKey: '<API_KEY>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: 'email@example.com', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-sendgrid-provider.md b/docs/examples/messaging/create-sendgrid-provider.md new file mode 100644 index 00000000..05d8eac1 --- /dev/null +++ b/docs/examples/messaging/create-sendgrid-provider.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createSendgridProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + apiKey: '<API_KEY>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: 'email@example.com', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md new file mode 100644 index 00000000..152b0542 --- /dev/null +++ b/docs/examples/messaging/create-sms.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createSms({ + messageId: '<MESSAGE_ID>', + content: '<CONTENT>', + topics: [], // optional + users: [], // optional + targets: [], // optional + draft: false, // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md new file mode 100644 index 00000000..5ce889c4 --- /dev/null +++ b/docs/examples/messaging/create-smtp-provider.md @@ -0,0 +1,28 @@ +```javascript +import { Client, Messaging, SmtpEncryption } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createSmtpProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + host: '<HOST>', + port: 1, // optional + username: '<USERNAME>', // optional + password: '<PASSWORD>', // optional + encryption: SmtpEncryption.None, // optional + autoTLS: false, // optional + mailer: '<MAILER>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: 'email@example.com', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-telesign-provider.md b/docs/examples/messaging/create-telesign-provider.md new file mode 100644 index 00000000..a1ebd717 --- /dev/null +++ b/docs/examples/messaging/create-telesign-provider.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createTelesignProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + customerId: '<CUSTOMER_ID>', // optional + apiKey: '<API_KEY>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-textmagic-provider.md b/docs/examples/messaging/create-textmagic-provider.md new file mode 100644 index 00000000..9f81c7e6 --- /dev/null +++ b/docs/examples/messaging/create-textmagic-provider.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createTextmagicProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + username: '<USERNAME>', // optional + apiKey: '<API_KEY>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md new file mode 100644 index 00000000..fa8b1dad --- /dev/null +++ b/docs/examples/messaging/create-topic.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createTopic({ + topicId: '<TOPIC_ID>', + name: '<NAME>', + subscribe: ["any"] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md new file mode 100644 index 00000000..186cff00 --- /dev/null +++ b/docs/examples/messaging/create-twilio-provider.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createTwilioProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + accountSid: '<ACCOUNT_SID>', // optional + authToken: '<AUTH_TOKEN>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-vonage-provider.md b/docs/examples/messaging/create-vonage-provider.md new file mode 100644 index 00000000..74fb12d9 --- /dev/null +++ b/docs/examples/messaging/create-vonage-provider.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.createVonageProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', + from: '+12065550100', // optional + apiKey: '<API_KEY>', // optional + apiSecret: '<API_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/delete-provider.md b/docs/examples/messaging/delete-provider.md new file mode 100644 index 00000000..8a371422 --- /dev/null +++ b/docs/examples/messaging/delete-provider.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.deleteProvider({ + providerId: '<PROVIDER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/delete-topic.md b/docs/examples/messaging/delete-topic.md new file mode 100644 index 00000000..3ef42894 --- /dev/null +++ b/docs/examples/messaging/delete-topic.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.deleteTopic({ + topicId: '<TOPIC_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/delete.md b/docs/examples/messaging/delete.md new file mode 100644 index 00000000..a4f42e5e --- /dev/null +++ b/docs/examples/messaging/delete.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.delete({ + messageId: '<MESSAGE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/get-message.md b/docs/examples/messaging/get-message.md new file mode 100644 index 00000000..7b10f853 --- /dev/null +++ b/docs/examples/messaging/get-message.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.getMessage({ + messageId: '<MESSAGE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/get-provider.md b/docs/examples/messaging/get-provider.md new file mode 100644 index 00000000..54c28480 --- /dev/null +++ b/docs/examples/messaging/get-provider.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.getProvider({ + providerId: '<PROVIDER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/get-subscriber.md b/docs/examples/messaging/get-subscriber.md new file mode 100644 index 00000000..8363067b --- /dev/null +++ b/docs/examples/messaging/get-subscriber.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.getSubscriber({ + topicId: '<TOPIC_ID>', + subscriberId: '<SUBSCRIBER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/get-topic.md b/docs/examples/messaging/get-topic.md new file mode 100644 index 00000000..6d6ea170 --- /dev/null +++ b/docs/examples/messaging/get-topic.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.getTopic({ + topicId: '<TOPIC_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/messaging/list-message-logs.md new file mode 100644 index 00000000..cc90cf0b --- /dev/null +++ b/docs/examples/messaging/list-message-logs.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.listMessageLogs({ + messageId: '<MESSAGE_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/list-messages.md b/docs/examples/messaging/list-messages.md new file mode 100644 index 00000000..dd451294 --- /dev/null +++ b/docs/examples/messaging/list-messages.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.listMessages({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md new file mode 100644 index 00000000..cf599a86 --- /dev/null +++ b/docs/examples/messaging/list-provider-logs.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.listProviderLogs({ + providerId: '<PROVIDER_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/list-providers.md b/docs/examples/messaging/list-providers.md new file mode 100644 index 00000000..243f83fa --- /dev/null +++ b/docs/examples/messaging/list-providers.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.listProviders({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md new file mode 100644 index 00000000..eea608b3 --- /dev/null +++ b/docs/examples/messaging/list-subscriber-logs.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.listSubscriberLogs({ + subscriberId: '<SUBSCRIBER_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/list-subscribers.md b/docs/examples/messaging/list-subscribers.md new file mode 100644 index 00000000..2c888eff --- /dev/null +++ b/docs/examples/messaging/list-subscribers.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.listSubscribers({ + topicId: '<TOPIC_ID>', + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/list-targets.md b/docs/examples/messaging/list-targets.md new file mode 100644 index 00000000..e99f37a6 --- /dev/null +++ b/docs/examples/messaging/list-targets.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.listTargets({ + messageId: '<MESSAGE_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md new file mode 100644 index 00000000..7a057dd0 --- /dev/null +++ b/docs/examples/messaging/list-topic-logs.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.listTopicLogs({ + topicId: '<TOPIC_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/list-topics.md b/docs/examples/messaging/list-topics.md new file mode 100644 index 00000000..9b7114e0 --- /dev/null +++ b/docs/examples/messaging/list-topics.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.listTopics({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md new file mode 100644 index 00000000..33d44077 --- /dev/null +++ b/docs/examples/messaging/update-apns-provider.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateApnsProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + authKey: '<AUTH_KEY>', // optional + authKeyId: '<AUTH_KEY_ID>', // optional + teamId: '<TEAM_ID>', // optional + bundleId: '<BUNDLE_ID>', // optional + sandbox: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md new file mode 100644 index 00000000..e7ef6af9 --- /dev/null +++ b/docs/examples/messaging/update-email.md @@ -0,0 +1,26 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateEmail({ + messageId: '<MESSAGE_ID>', + topics: [], // optional + users: [], // optional + targets: [], // optional + subject: '<SUBJECT>', // optional + content: '<CONTENT>', // optional + draft: false, // optional + html: false, // optional + cc: [], // optional + bcc: [], // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional + attachments: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md new file mode 100644 index 00000000..860952e3 --- /dev/null +++ b/docs/examples/messaging/update-fcm-provider.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateFcmProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + serviceAccountJSON: {} // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-mailgun-provider.md b/docs/examples/messaging/update-mailgun-provider.md new file mode 100644 index 00000000..64b1ef5a --- /dev/null +++ b/docs/examples/messaging/update-mailgun-provider.md @@ -0,0 +1,24 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateMailgunProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + apiKey: '<API_KEY>', // optional + domain: '<DOMAIN>', // optional + isEuRegion: false, // optional + enabled: false, // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: '<REPLY_TO_EMAIL>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-msg-91-provider.md b/docs/examples/messaging/update-msg-91-provider.md new file mode 100644 index 00000000..8adf6c85 --- /dev/null +++ b/docs/examples/messaging/update-msg-91-provider.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateMsg91Provider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + templateId: '<TEMPLATE_ID>', // optional + senderId: '<SENDER_ID>', // optional + authKey: '<AUTH_KEY>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md new file mode 100644 index 00000000..bb399fdd --- /dev/null +++ b/docs/examples/messaging/update-push.md @@ -0,0 +1,33 @@ +```javascript +import { Client, Messaging, MessagePriority } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updatePush({ + messageId: '<MESSAGE_ID>', + topics: [], // optional + users: [], // optional + targets: [], // optional + title: '<TITLE>', // optional + body: '<BODY>', // optional + data: {}, // optional + action: '<ACTION>', // optional + image: '<ID1:ID2>', // optional + icon: '<ICON>', // optional + sound: '<SOUND>', // optional + color: '<COLOR>', // optional + tag: '<TAG>', // optional + badge: null, // optional + draft: false, // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00', // optional + contentAvailable: false, // optional + critical: false, // optional + priority: MessagePriority.Normal // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-resend-provider.md b/docs/examples/messaging/update-resend-provider.md new file mode 100644 index 00000000..6fe46a37 --- /dev/null +++ b/docs/examples/messaging/update-resend-provider.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateResendProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + apiKey: '<API_KEY>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: '<REPLY_TO_EMAIL>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-sendgrid-provider.md b/docs/examples/messaging/update-sendgrid-provider.md new file mode 100644 index 00000000..67ae148e --- /dev/null +++ b/docs/examples/messaging/update-sendgrid-provider.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateSendgridProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + apiKey: '<API_KEY>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: '<REPLY_TO_EMAIL>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md new file mode 100644 index 00000000..40df7c77 --- /dev/null +++ b/docs/examples/messaging/update-sms.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateSms({ + messageId: '<MESSAGE_ID>', + topics: [], // optional + users: [], // optional + targets: [], // optional + content: '<CONTENT>', // optional + draft: false, // optional + scheduledAt: '2020-10-15T06:38:00.000+00:00' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md new file mode 100644 index 00000000..aaeae762 --- /dev/null +++ b/docs/examples/messaging/update-smtp-provider.md @@ -0,0 +1,28 @@ +```javascript +import { Client, Messaging, SmtpEncryption } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateSmtpProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + host: '<HOST>', // optional + port: 1, // optional + username: '<USERNAME>', // optional + password: '<PASSWORD>', // optional + encryption: SmtpEncryption.None, // optional + autoTLS: false, // optional + mailer: '<MAILER>', // optional + fromName: '<FROM_NAME>', // optional + fromEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + replyToEmail: '<REPLY_TO_EMAIL>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-telesign-provider.md b/docs/examples/messaging/update-telesign-provider.md new file mode 100644 index 00000000..03519b79 --- /dev/null +++ b/docs/examples/messaging/update-telesign-provider.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateTelesignProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + customerId: '<CUSTOMER_ID>', // optional + apiKey: '<API_KEY>', // optional + from: '<FROM>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-textmagic-provider.md b/docs/examples/messaging/update-textmagic-provider.md new file mode 100644 index 00000000..9d29c079 --- /dev/null +++ b/docs/examples/messaging/update-textmagic-provider.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateTextmagicProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + username: '<USERNAME>', // optional + apiKey: '<API_KEY>', // optional + from: '<FROM>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md new file mode 100644 index 00000000..307bc143 --- /dev/null +++ b/docs/examples/messaging/update-topic.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateTopic({ + topicId: '<TOPIC_ID>', + name: '<NAME>', // optional + subscribe: ["any"] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-twilio-provider.md b/docs/examples/messaging/update-twilio-provider.md new file mode 100644 index 00000000..8aebdc79 --- /dev/null +++ b/docs/examples/messaging/update-twilio-provider.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateTwilioProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + accountSid: '<ACCOUNT_SID>', // optional + authToken: '<AUTH_TOKEN>', // optional + from: '<FROM>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/update-vonage-provider.md b/docs/examples/messaging/update-vonage-provider.md new file mode 100644 index 00000000..506d29d0 --- /dev/null +++ b/docs/examples/messaging/update-vonage-provider.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Messaging } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const messaging = new Messaging(client); + +const result = await messaging.updateVonageProvider({ + providerId: '<PROVIDER_ID>', + name: '<NAME>', // optional + enabled: false, // optional + apiKey: '<API_KEY>', // optional + apiSecret: '<API_SECRET>', // optional + from: '<FROM>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/presences/update.md b/docs/examples/presences/update.md index 79e5aa91..01cc3fc7 100644 --- a/docs/examples/presences/update.md +++ b/docs/examples/presences/update.md @@ -9,6 +9,7 @@ const presences = new Presences(client); const result = await presences.update({ presenceId: '<PRESENCE_ID>', + userId: '<USER_ID>', // optional status: '<STATUS>', // optional expiresAt: '2020-10-15T06:38:00.000+00:00', // optional metadata: {}, // optional diff --git a/docs/examples/presences/upsert.md b/docs/examples/presences/upsert.md index e8fb6349..3d13e32e 100644 --- a/docs/examples/presences/upsert.md +++ b/docs/examples/presences/upsert.md @@ -10,6 +10,7 @@ const presences = new Presences(client); const result = await presences.upsert({ presenceId: '<PRESENCE_ID>', status: '<STATUS>', + userId: '<USER_ID>', // optional permissions: [Permission.read(Role.any())], // optional expiresAt: '2020-10-15T06:38:00.000+00:00', // optional metadata: {} // optional diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md new file mode 100644 index 00000000..7ea0aef8 --- /dev/null +++ b/docs/examples/project/create-android-platform.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.createAndroidPlatform({ + platformId: '<PLATFORM_ID>', + name: '<NAME>', + applicationId: '<APPLICATION_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-apple-platform.md b/docs/examples/project/create-apple-platform.md new file mode 100644 index 00000000..a83fc859 --- /dev/null +++ b/docs/examples/project/create-apple-platform.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.createApplePlatform({ + platformId: '<PLATFORM_ID>', + name: '<NAME>', + bundleIdentifier: '<BUNDLE_IDENTIFIER>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md new file mode 100644 index 00000000..377ac851 --- /dev/null +++ b/docs/examples/project/create-ephemeral-key.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project, ProjectKeyScopes } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.createEphemeralKey({ + scopes: [ProjectKeyScopes.ProjectRead], + duration: 600 +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-key.md b/docs/examples/project/create-key.md new file mode 100644 index 00000000..0c4dd820 --- /dev/null +++ b/docs/examples/project/create-key.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project, ProjectKeyScopes } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.createKey({ + keyId: '<KEY_ID>', + name: '<NAME>', + scopes: [ProjectKeyScopes.ProjectRead], + expire: '2020-10-15T06:38:00.000+00:00' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-linux-platform.md b/docs/examples/project/create-linux-platform.md new file mode 100644 index 00000000..93103d34 --- /dev/null +++ b/docs/examples/project/create-linux-platform.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.createLinuxPlatform({ + platformId: '<PLATFORM_ID>', + name: '<NAME>', + packageName: '<PACKAGE_NAME>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-mock-phone.md b/docs/examples/project/create-mock-phone.md new file mode 100644 index 00000000..918d5853 --- /dev/null +++ b/docs/examples/project/create-mock-phone.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.createMockPhone({ + number: '+12065550100', + otp: '<OTP>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md new file mode 100644 index 00000000..cd0f8ed4 --- /dev/null +++ b/docs/examples/project/create-smtp-test.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.createSMTPTest({ + emails: [] +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-variable.md b/docs/examples/project/create-variable.md new file mode 100644 index 00000000..98a4f66f --- /dev/null +++ b/docs/examples/project/create-variable.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.createVariable({ + variableId: '<VARIABLE_ID>', + key: '<KEY>', + value: '<VALUE>', + secret: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-web-platform.md b/docs/examples/project/create-web-platform.md new file mode 100644 index 00000000..d0ddc06a --- /dev/null +++ b/docs/examples/project/create-web-platform.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.createWebPlatform({ + platformId: '<PLATFORM_ID>', + name: '<NAME>', + hostname: 'app.example.com' +}); + +console.log(result); +``` diff --git a/docs/examples/project/create-windows-platform.md b/docs/examples/project/create-windows-platform.md new file mode 100644 index 00000000..c6c220e1 --- /dev/null +++ b/docs/examples/project/create-windows-platform.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.createWindowsPlatform({ + platformId: '<PLATFORM_ID>', + name: '<NAME>', + packageIdentifierName: '<PACKAGE_IDENTIFIER_NAME>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/delete-key.md b/docs/examples/project/delete-key.md new file mode 100644 index 00000000..fa9681e1 --- /dev/null +++ b/docs/examples/project/delete-key.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.deleteKey({ + keyId: '<KEY_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/delete-mock-phone.md b/docs/examples/project/delete-mock-phone.md new file mode 100644 index 00000000..5a59358f --- /dev/null +++ b/docs/examples/project/delete-mock-phone.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.deleteMockPhone({ + number: '+12065550100' +}); + +console.log(result); +``` diff --git a/docs/examples/project/delete-platform.md b/docs/examples/project/delete-platform.md new file mode 100644 index 00000000..70562379 --- /dev/null +++ b/docs/examples/project/delete-platform.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.deletePlatform({ + platformId: '<PLATFORM_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/delete-variable.md b/docs/examples/project/delete-variable.md new file mode 100644 index 00000000..a50b5ae4 --- /dev/null +++ b/docs/examples/project/delete-variable.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.deleteVariable({ + variableId: '<VARIABLE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/delete.md b/docs/examples/project/delete.md new file mode 100644 index 00000000..757763cc --- /dev/null +++ b/docs/examples/project/delete.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.delete(); + +console.log(result); +``` diff --git a/docs/examples/project/get-email-template.md b/docs/examples/project/get-email-template.md new file mode 100644 index 00000000..2d1c9e3e --- /dev/null +++ b/docs/examples/project/get-email-template.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project, ProjectEmailTemplateId, ProjectEmailTemplateLocale } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.getEmailTemplate({ + templateId: ProjectEmailTemplateId.Verification, + locale: ProjectEmailTemplateLocale.Af // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/get-key.md b/docs/examples/project/get-key.md new file mode 100644 index 00000000..655569e9 --- /dev/null +++ b/docs/examples/project/get-key.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.getKey({ + keyId: '<KEY_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/get-mock-phone.md b/docs/examples/project/get-mock-phone.md new file mode 100644 index 00000000..6f0b3154 --- /dev/null +++ b/docs/examples/project/get-mock-phone.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.getMockPhone({ + number: '+12065550100' +}); + +console.log(result); +``` diff --git a/docs/examples/project/get-o-auth-2-provider.md b/docs/examples/project/get-o-auth-2-provider.md new file mode 100644 index 00000000..4447791a --- /dev/null +++ b/docs/examples/project/get-o-auth-2-provider.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project, ProjectOAuthProviderId } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.getOAuth2Provider({ + providerId: ProjectOAuthProviderId.Amazon +}); + +console.log(result); +``` diff --git a/docs/examples/project/get-platform.md b/docs/examples/project/get-platform.md new file mode 100644 index 00000000..908cad46 --- /dev/null +++ b/docs/examples/project/get-platform.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.getPlatform({ + platformId: '<PLATFORM_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/get-policy.md b/docs/examples/project/get-policy.md new file mode 100644 index 00000000..a6a74aef --- /dev/null +++ b/docs/examples/project/get-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project, ProjectPolicyId } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.getPolicy({ + policyId: ProjectPolicyId.PasswordDictionary +}); + +console.log(result); +``` diff --git a/docs/examples/project/get-variable.md b/docs/examples/project/get-variable.md new file mode 100644 index 00000000..53b059c0 --- /dev/null +++ b/docs/examples/project/get-variable.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.getVariable({ + variableId: '<VARIABLE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/get.md b/docs/examples/project/get.md new file mode 100644 index 00000000..96bc8614 --- /dev/null +++ b/docs/examples/project/get.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.get(); + +console.log(result); +``` diff --git a/docs/examples/project/list-email-templates.md b/docs/examples/project/list-email-templates.md new file mode 100644 index 00000000..6ae1f3c1 --- /dev/null +++ b/docs/examples/project/list-email-templates.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.listEmailTemplates({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/list-keys.md b/docs/examples/project/list-keys.md new file mode 100644 index 00000000..c5f521a8 --- /dev/null +++ b/docs/examples/project/list-keys.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.listKeys({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/list-mock-phones.md b/docs/examples/project/list-mock-phones.md new file mode 100644 index 00000000..3e5d66e7 --- /dev/null +++ b/docs/examples/project/list-mock-phones.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.listMockPhones({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/list-o-auth-2-providers.md b/docs/examples/project/list-o-auth-2-providers.md new file mode 100644 index 00000000..8d8fcc75 --- /dev/null +++ b/docs/examples/project/list-o-auth-2-providers.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.listOAuth2Providers({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/list-platforms.md b/docs/examples/project/list-platforms.md new file mode 100644 index 00000000..b6303317 --- /dev/null +++ b/docs/examples/project/list-platforms.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.listPlatforms({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/list-policies.md b/docs/examples/project/list-policies.md new file mode 100644 index 00000000..a06943da --- /dev/null +++ b/docs/examples/project/list-policies.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.listPolicies({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/list-variables.md b/docs/examples/project/list-variables.md new file mode 100644 index 00000000..6fec55b5 --- /dev/null +++ b/docs/examples/project/list-variables.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.listVariables({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md new file mode 100644 index 00000000..3fa7dcf8 --- /dev/null +++ b/docs/examples/project/update-android-platform.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateAndroidPlatform({ + platformId: '<PLATFORM_ID>', + name: '<NAME>', + applicationId: '<APPLICATION_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-apple-platform.md b/docs/examples/project/update-apple-platform.md new file mode 100644 index 00000000..e6bf227a --- /dev/null +++ b/docs/examples/project/update-apple-platform.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateApplePlatform({ + platformId: '<PLATFORM_ID>', + name: '<NAME>', + bundleIdentifier: '<BUNDLE_IDENTIFIER>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-auth-method.md b/docs/examples/project/update-auth-method.md new file mode 100644 index 00000000..68da4b94 --- /dev/null +++ b/docs/examples/project/update-auth-method.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project, ProjectAuthMethodId } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateAuthMethod({ + methodId: ProjectAuthMethodId.EmailPassword, + enabled: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-deny-aliased-email-policy.md b/docs/examples/project/update-deny-aliased-email-policy.md new file mode 100644 index 00000000..0c19b5f9 --- /dev/null +++ b/docs/examples/project/update-deny-aliased-email-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateDenyAliasedEmailPolicy({ + enabled: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-deny-disposable-email-policy.md b/docs/examples/project/update-deny-disposable-email-policy.md new file mode 100644 index 00000000..12706609 --- /dev/null +++ b/docs/examples/project/update-deny-disposable-email-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateDenyDisposableEmailPolicy({ + enabled: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-deny-free-email-policy.md b/docs/examples/project/update-deny-free-email-policy.md new file mode 100644 index 00000000..19297d98 --- /dev/null +++ b/docs/examples/project/update-deny-free-email-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateDenyFreeEmailPolicy({ + enabled: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-email-template.md b/docs/examples/project/update-email-template.md new file mode 100644 index 00000000..ae06c888 --- /dev/null +++ b/docs/examples/project/update-email-template.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Project, ProjectEmailTemplateId, ProjectEmailTemplateLocale } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateEmailTemplate({ + templateId: ProjectEmailTemplateId.Verification, + locale: ProjectEmailTemplateLocale.Af, // optional + subject: '<SUBJECT>', // optional + message: '<MESSAGE>', // optional + senderName: '<SENDER_NAME>', // optional + senderEmail: 'email@example.com', // optional + replyToEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md new file mode 100644 index 00000000..e926daeb --- /dev/null +++ b/docs/examples/project/update-key.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project, ProjectKeyScopes } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateKey({ + keyId: '<KEY_ID>', + name: '<NAME>', + scopes: [ProjectKeyScopes.ProjectRead], + expire: '2020-10-15T06:38:00.000+00:00' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md new file mode 100644 index 00000000..47a133e8 --- /dev/null +++ b/docs/examples/project/update-labels.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateLabels({ + labels: [] +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-linux-platform.md b/docs/examples/project/update-linux-platform.md new file mode 100644 index 00000000..2744862e --- /dev/null +++ b/docs/examples/project/update-linux-platform.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateLinuxPlatform({ + platformId: '<PLATFORM_ID>', + name: '<NAME>', + packageName: '<PACKAGE_NAME>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-membership-privacy-policy.md b/docs/examples/project/update-membership-privacy-policy.md new file mode 100644 index 00000000..06ebae70 --- /dev/null +++ b/docs/examples/project/update-membership-privacy-policy.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateMembershipPrivacyPolicy({ + userId: false, // optional + userEmail: false, // optional + userPhone: false, // optional + userName: false, // optional + userMFA: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-mock-phone.md b/docs/examples/project/update-mock-phone.md new file mode 100644 index 00000000..971173c2 --- /dev/null +++ b/docs/examples/project/update-mock-phone.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateMockPhone({ + number: '+12065550100', + otp: '<OTP>' +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-amazon.md b/docs/examples/project/update-o-auth-2-amazon.md new file mode 100644 index 00000000..dab2d701 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-amazon.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Amazon({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md new file mode 100644 index 00000000..948c9a59 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Apple({ + serviceId: '<SERVICE_ID>', // optional + keyId: '<KEY_ID>', // optional + teamId: '<TEAM_ID>', // optional + p8File: '<P8_FILE>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md new file mode 100644 index 00000000..abde7451 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Auth0({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + endpoint: '<ENDPOINT>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-authentik.md b/docs/examples/project/update-o-auth-2-authentik.md new file mode 100644 index 00000000..41c118bf --- /dev/null +++ b/docs/examples/project/update-o-auth-2-authentik.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Authentik({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + endpoint: '<ENDPOINT>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-autodesk.md b/docs/examples/project/update-o-auth-2-autodesk.md new file mode 100644 index 00000000..febb558a --- /dev/null +++ b/docs/examples/project/update-o-auth-2-autodesk.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Autodesk({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-bitbucket.md b/docs/examples/project/update-o-auth-2-bitbucket.md new file mode 100644 index 00000000..f96ea278 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-bitbucket.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Bitbucket({ + key: '<KEY>', // optional + secret: '<SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-bitly.md b/docs/examples/project/update-o-auth-2-bitly.md new file mode 100644 index 00000000..08cafcd0 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-bitly.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Bitly({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-box.md b/docs/examples/project/update-o-auth-2-box.md new file mode 100644 index 00000000..08221d3d --- /dev/null +++ b/docs/examples/project/update-o-auth-2-box.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Box({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-dailymotion.md b/docs/examples/project/update-o-auth-2-dailymotion.md new file mode 100644 index 00000000..8a520b29 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-dailymotion.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Dailymotion({ + apiKey: '<API_KEY>', // optional + apiSecret: '<API_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md new file mode 100644 index 00000000..5c921ceb --- /dev/null +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Discord({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-disqus.md b/docs/examples/project/update-o-auth-2-disqus.md new file mode 100644 index 00000000..c091a6d0 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-disqus.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Disqus({ + publicKey: '<PUBLIC_KEY>', // optional + secretKey: '<SECRET_KEY>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-dropbox.md b/docs/examples/project/update-o-auth-2-dropbox.md new file mode 100644 index 00000000..c804af9f --- /dev/null +++ b/docs/examples/project/update-o-auth-2-dropbox.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Dropbox({ + appKey: '<APP_KEY>', // optional + appSecret: '<APP_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-etsy.md b/docs/examples/project/update-o-auth-2-etsy.md new file mode 100644 index 00000000..8deff628 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-etsy.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Etsy({ + keyString: '<KEY_STRING>', // optional + sharedSecret: '<SHARED_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-facebook.md b/docs/examples/project/update-o-auth-2-facebook.md new file mode 100644 index 00000000..74d1534f --- /dev/null +++ b/docs/examples/project/update-o-auth-2-facebook.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Facebook({ + appId: '<APP_ID>', // optional + appSecret: '<APP_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-figma.md b/docs/examples/project/update-o-auth-2-figma.md new file mode 100644 index 00000000..81038e28 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-figma.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Figma({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-fusion-auth.md b/docs/examples/project/update-o-auth-2-fusion-auth.md new file mode 100644 index 00000000..1cb70651 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-fusion-auth.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2FusionAuth({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + endpoint: '<ENDPOINT>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md new file mode 100644 index 00000000..16bb06c8 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2GitHub({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-gitlab.md b/docs/examples/project/update-o-auth-2-gitlab.md new file mode 100644 index 00000000..d0c9806b --- /dev/null +++ b/docs/examples/project/update-o-auth-2-gitlab.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Gitlab({ + applicationId: '<APPLICATION_ID>', // optional + secret: '<SECRET>', // optional + endpoint: 'https://example.com', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md new file mode 100644 index 00000000..d13a8a45 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-google.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project, ProjectOAuth2GooglePrompt } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Google({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + prompt: [ProjectOAuth2GooglePrompt.None], // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-keycloak.md b/docs/examples/project/update-o-auth-2-keycloak.md new file mode 100644 index 00000000..644c8e2e --- /dev/null +++ b/docs/examples/project/update-o-auth-2-keycloak.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Keycloak({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + endpoint: '<ENDPOINT>', // optional + realmName: '<REALM_NAME>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-kick.md b/docs/examples/project/update-o-auth-2-kick.md new file mode 100644 index 00000000..e5e2f559 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-kick.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Kick({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-linkedin.md b/docs/examples/project/update-o-auth-2-linkedin.md new file mode 100644 index 00000000..884e7110 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-linkedin.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Linkedin({ + clientId: '<CLIENT_ID>', // optional + primaryClientSecret: '<PRIMARY_CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md new file mode 100644 index 00000000..7cb0676a --- /dev/null +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Microsoft({ + applicationId: '<APPLICATION_ID>', // optional + applicationSecret: '<APPLICATION_SECRET>', // optional + tenant: '<TENANT>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-notion.md b/docs/examples/project/update-o-auth-2-notion.md new file mode 100644 index 00000000..fa46c71c --- /dev/null +++ b/docs/examples/project/update-o-auth-2-notion.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Notion({ + oauthClientId: '<OAUTH_CLIENT_ID>', // optional + oauthClientSecret: '<OAUTH_CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-oidc.md b/docs/examples/project/update-o-auth-2-oidc.md new file mode 100644 index 00000000..557c27b9 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-oidc.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Oidc({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + wellKnownURL: 'https://example.com', // optional + authorizationURL: 'https://example.com', // optional + tokenURL: 'https://example.com', // optional + userInfoURL: 'https://example.com', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md new file mode 100644 index 00000000..b0d3b94f --- /dev/null +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Okta({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + domain: '', // optional + authorizationServerId: '<AUTHORIZATION_SERVER_ID>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-paypal-sandbox.md b/docs/examples/project/update-o-auth-2-paypal-sandbox.md new file mode 100644 index 00000000..45e6a7b1 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-paypal-sandbox.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2PaypalSandbox({ + clientId: '<CLIENT_ID>', // optional + secretKey: '<SECRET_KEY>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-paypal.md b/docs/examples/project/update-o-auth-2-paypal.md new file mode 100644 index 00000000..2a732863 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-paypal.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Paypal({ + clientId: '<CLIENT_ID>', // optional + secretKey: '<SECRET_KEY>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-podio.md b/docs/examples/project/update-o-auth-2-podio.md new file mode 100644 index 00000000..3c0497d9 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-podio.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Podio({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md new file mode 100644 index 00000000..532733d5 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Salesforce({ + customerKey: '<CUSTOMER_KEY>', // optional + customerSecret: '<CUSTOMER_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-slack.md b/docs/examples/project/update-o-auth-2-slack.md new file mode 100644 index 00000000..325b644c --- /dev/null +++ b/docs/examples/project/update-o-auth-2-slack.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Slack({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-spotify.md b/docs/examples/project/update-o-auth-2-spotify.md new file mode 100644 index 00000000..d1f186b1 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-spotify.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Spotify({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-stripe.md b/docs/examples/project/update-o-auth-2-stripe.md new file mode 100644 index 00000000..01413997 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-stripe.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Stripe({ + clientId: '<CLIENT_ID>', // optional + apiSecretKey: '<API_SECRET_KEY>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md new file mode 100644 index 00000000..62a7a899 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tradeshift-sandbox.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2TradeshiftSandbox({ + oauth2ClientId: '<OAUTH2_CLIENT_ID>', // optional + oauth2ClientSecret: '<OAUTH2_CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-tradeshift.md b/docs/examples/project/update-o-auth-2-tradeshift.md new file mode 100644 index 00000000..646ca091 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tradeshift.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Tradeshift({ + oauth2ClientId: '<OAUTH2_CLIENT_ID>', // optional + oauth2ClientSecret: '<OAUTH2_CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-twitch.md b/docs/examples/project/update-o-auth-2-twitch.md new file mode 100644 index 00000000..d641bd65 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-twitch.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Twitch({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-word-press.md b/docs/examples/project/update-o-auth-2-word-press.md new file mode 100644 index 00000000..f865a5fc --- /dev/null +++ b/docs/examples/project/update-o-auth-2-word-press.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2WordPress({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-yahoo.md b/docs/examples/project/update-o-auth-2-yahoo.md new file mode 100644 index 00000000..7e9d5279 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-yahoo.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Yahoo({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-yandex.md b/docs/examples/project/update-o-auth-2-yandex.md new file mode 100644 index 00000000..9e551cf8 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-yandex.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Yandex({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md new file mode 100644 index 00000000..ab2cfcd0 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Zoho({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2-zoom.md b/docs/examples/project/update-o-auth-2-zoom.md new file mode 100644 index 00000000..fbefecd3 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-zoom.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2Zoom({ + clientId: '<CLIENT_ID>', // optional + clientSecret: '<CLIENT_SECRET>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-o-auth-2x.md b/docs/examples/project/update-o-auth-2x.md new file mode 100644 index 00000000..144b4a8c --- /dev/null +++ b/docs/examples/project/update-o-auth-2x.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateOAuth2X({ + customerKey: '<CUSTOMER_KEY>', // optional + secretKey: '<SECRET_KEY>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-password-dictionary-policy.md b/docs/examples/project/update-password-dictionary-policy.md new file mode 100644 index 00000000..d1083d12 --- /dev/null +++ b/docs/examples/project/update-password-dictionary-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updatePasswordDictionaryPolicy({ + enabled: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-password-history-policy.md b/docs/examples/project/update-password-history-policy.md new file mode 100644 index 00000000..22c26817 --- /dev/null +++ b/docs/examples/project/update-password-history-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updatePasswordHistoryPolicy({ + total: 1 +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-password-personal-data-policy.md b/docs/examples/project/update-password-personal-data-policy.md new file mode 100644 index 00000000..e8984f4b --- /dev/null +++ b/docs/examples/project/update-password-personal-data-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updatePasswordPersonalDataPolicy({ + enabled: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-protocol.md b/docs/examples/project/update-protocol.md new file mode 100644 index 00000000..2c278772 --- /dev/null +++ b/docs/examples/project/update-protocol.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project, ProjectProtocolId } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateProtocol({ + protocolId: ProjectProtocolId.Rest, + enabled: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-service.md b/docs/examples/project/update-service.md new file mode 100644 index 00000000..d2daa084 --- /dev/null +++ b/docs/examples/project/update-service.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Project, ProjectServiceId } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateService({ + serviceId: ProjectServiceId.Account, + enabled: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-session-alert-policy.md b/docs/examples/project/update-session-alert-policy.md new file mode 100644 index 00000000..3f04b2c5 --- /dev/null +++ b/docs/examples/project/update-session-alert-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateSessionAlertPolicy({ + enabled: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-session-duration-policy.md b/docs/examples/project/update-session-duration-policy.md new file mode 100644 index 00000000..5a63205e --- /dev/null +++ b/docs/examples/project/update-session-duration-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateSessionDurationPolicy({ + duration: 5 +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-session-invalidation-policy.md b/docs/examples/project/update-session-invalidation-policy.md new file mode 100644 index 00000000..8e5e01ca --- /dev/null +++ b/docs/examples/project/update-session-invalidation-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateSessionInvalidationPolicy({ + enabled: false +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-session-limit-policy.md b/docs/examples/project/update-session-limit-policy.md new file mode 100644 index 00000000..8b245e29 --- /dev/null +++ b/docs/examples/project/update-session-limit-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateSessionLimitPolicy({ + total: 1 +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-smtp.md b/docs/examples/project/update-smtp.md new file mode 100644 index 00000000..ac68fa13 --- /dev/null +++ b/docs/examples/project/update-smtp.md @@ -0,0 +1,24 @@ +```javascript +import { Client, Project, ProjectSMTPSecure } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateSMTP({ + host: '', // optional + port: null, // optional + username: '<USERNAME>', // optional + password: '<PASSWORD>', // optional + senderEmail: 'email@example.com', // optional + senderName: '<SENDER_NAME>', // optional + replyToEmail: 'email@example.com', // optional + replyToName: '<REPLY_TO_NAME>', // optional + secure: ProjectSMTPSecure.Tls, // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-user-limit-policy.md b/docs/examples/project/update-user-limit-policy.md new file mode 100644 index 00000000..89f16441 --- /dev/null +++ b/docs/examples/project/update-user-limit-policy.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateUserLimitPolicy({ + total: 1 +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-variable.md b/docs/examples/project/update-variable.md new file mode 100644 index 00000000..ba9e4391 --- /dev/null +++ b/docs/examples/project/update-variable.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateVariable({ + variableId: '<VARIABLE_ID>', + key: '<KEY>', // optional + value: '<VALUE>', // optional + secret: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-web-platform.md b/docs/examples/project/update-web-platform.md new file mode 100644 index 00000000..832dbfbd --- /dev/null +++ b/docs/examples/project/update-web-platform.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateWebPlatform({ + platformId: '<PLATFORM_ID>', + name: '<NAME>', + hostname: 'app.example.com' +}); + +console.log(result); +``` diff --git a/docs/examples/project/update-windows-platform.md b/docs/examples/project/update-windows-platform.md new file mode 100644 index 00000000..3d0f26b1 --- /dev/null +++ b/docs/examples/project/update-windows-platform.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Project } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const project = new Project(client); + +const result = await project.updateWindowsPlatform({ + platformId: '<PLATFORM_ID>', + name: '<NAME>', + packageIdentifierName: '<PACKAGE_IDENTIFIER_NAME>' +}); + +console.log(result); +``` diff --git a/docs/examples/proxy/create-api-rule.md b/docs/examples/proxy/create-api-rule.md new file mode 100644 index 00000000..e7455452 --- /dev/null +++ b/docs/examples/proxy/create-api-rule.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Proxy } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const proxy = new Proxy(client); + +const result = await proxy.createAPIRule({ + domain: '' +}); + +console.log(result); +``` diff --git a/docs/examples/proxy/create-function-rule.md b/docs/examples/proxy/create-function-rule.md new file mode 100644 index 00000000..44a93995 --- /dev/null +++ b/docs/examples/proxy/create-function-rule.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Proxy } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const proxy = new Proxy(client); + +const result = await proxy.createFunctionRule({ + domain: '', + functionId: '<FUNCTION_ID>', + branch: '<BRANCH>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/proxy/create-redirect-rule.md b/docs/examples/proxy/create-redirect-rule.md new file mode 100644 index 00000000..7caa9c8e --- /dev/null +++ b/docs/examples/proxy/create-redirect-rule.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Proxy, StatusCode, ProxyResourceType } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const proxy = new Proxy(client); + +const result = await proxy.createRedirectRule({ + domain: '', + url: 'https://example.com', + statusCode: StatusCode.MovedPermanently301, + resourceId: '<RESOURCE_ID>', + resourceType: ProxyResourceType.Site +}); + +console.log(result); +``` diff --git a/docs/examples/proxy/create-site-rule.md b/docs/examples/proxy/create-site-rule.md new file mode 100644 index 00000000..02db6911 --- /dev/null +++ b/docs/examples/proxy/create-site-rule.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Proxy } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const proxy = new Proxy(client); + +const result = await proxy.createSiteRule({ + domain: '', + siteId: '<SITE_ID>', + branch: '<BRANCH>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/proxy/delete-rule.md b/docs/examples/proxy/delete-rule.md new file mode 100644 index 00000000..115d78b9 --- /dev/null +++ b/docs/examples/proxy/delete-rule.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Proxy } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const proxy = new Proxy(client); + +const result = await proxy.deleteRule({ + ruleId: '<RULE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/proxy/get-rule.md b/docs/examples/proxy/get-rule.md new file mode 100644 index 00000000..6f52a062 --- /dev/null +++ b/docs/examples/proxy/get-rule.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Proxy } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const proxy = new Proxy(client); + +const result = await proxy.getRule({ + ruleId: '<RULE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/proxy/list-rules.md b/docs/examples/proxy/list-rules.md new file mode 100644 index 00000000..fb993b0d --- /dev/null +++ b/docs/examples/proxy/list-rules.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Proxy } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const proxy = new Proxy(client); + +const result = await proxy.listRules({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/proxy/update-rule-status.md b/docs/examples/proxy/update-rule-status.md new file mode 100644 index 00000000..46e579e4 --- /dev/null +++ b/docs/examples/proxy/update-rule-status.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Proxy } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const proxy = new Proxy(client); + +const result = await proxy.updateRuleStatus({ + ruleId: '<RULE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md new file mode 100644 index 00000000..cf7ffe9c --- /dev/null +++ b/docs/examples/sites/create-deployment.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.createDeployment({ + siteId: '<SITE_ID>', + code: document.getElementById('uploader').files[0], + installCommand: '<INSTALL_COMMAND>', // optional + buildCommand: '<BUILD_COMMAND>', // optional + outputDirectory: '<OUTPUT_DIRECTORY>', // optional + activate: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/create-duplicate-deployment.md b/docs/examples/sites/create-duplicate-deployment.md new file mode 100644 index 00000000..d9172798 --- /dev/null +++ b/docs/examples/sites/create-duplicate-deployment.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.createDuplicateDeployment({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/create-template-deployment.md b/docs/examples/sites/create-template-deployment.md new file mode 100644 index 00000000..e1ebe775 --- /dev/null +++ b/docs/examples/sites/create-template-deployment.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Sites, TemplateReferenceType } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.createTemplateDeployment({ + siteId: '<SITE_ID>', + repository: '<REPOSITORY>', + owner: '<OWNER>', + rootDirectory: '<ROOT_DIRECTORY>', + type: TemplateReferenceType.Branch, + reference: '<REFERENCE>', + activate: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/create-variable.md b/docs/examples/sites/create-variable.md new file mode 100644 index 00000000..0b7a3fef --- /dev/null +++ b/docs/examples/sites/create-variable.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.createVariable({ + siteId: '<SITE_ID>', + variableId: '<VARIABLE_ID>', + key: '<KEY>', + value: '<VALUE>', + secret: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/create-vcs-deployment.md b/docs/examples/sites/create-vcs-deployment.md new file mode 100644 index 00000000..d58947e9 --- /dev/null +++ b/docs/examples/sites/create-vcs-deployment.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Sites, VCSReferenceType } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.createVcsDeployment({ + siteId: '<SITE_ID>', + type: VCSReferenceType.Branch, + reference: '<REFERENCE>', + activate: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/create.md b/docs/examples/sites/create.md new file mode 100644 index 00000000..85e35285 --- /dev/null +++ b/docs/examples/sites/create.md @@ -0,0 +1,35 @@ +```javascript +import { Client, Sites, Framework, BuildRuntime, Adapter } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.create({ + siteId: '<SITE_ID>', + name: '<NAME>', + framework: Framework.Analog, + buildRuntime: BuildRuntime.Node145, + enabled: false, // optional + logging: false, // optional + timeout: 1, // optional + installCommand: '<INSTALL_COMMAND>', // optional + buildCommand: '<BUILD_COMMAND>', // optional + startCommand: '<START_COMMAND>', // optional + outputDirectory: '<OUTPUT_DIRECTORY>', // optional + adapter: Adapter.Static, // optional + installationId: '<INSTALLATION_ID>', // optional + fallbackFile: '<FALLBACK_FILE>', // optional + providerRepositoryId: '<PROVIDER_REPOSITORY_ID>', // optional + providerBranch: '<PROVIDER_BRANCH>', // optional + providerSilentMode: false, // optional + providerRootDirectory: '<PROVIDER_ROOT_DIRECTORY>', // optional + buildSpecification: '', // optional + runtimeSpecification: '', // optional + deploymentRetention: 0 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/delete-deployment.md b/docs/examples/sites/delete-deployment.md new file mode 100644 index 00000000..a344accd --- /dev/null +++ b/docs/examples/sites/delete-deployment.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.deleteDeployment({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/delete-log.md b/docs/examples/sites/delete-log.md new file mode 100644 index 00000000..65eb61b1 --- /dev/null +++ b/docs/examples/sites/delete-log.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.deleteLog({ + siteId: '<SITE_ID>', + logId: '<LOG_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/delete-variable.md b/docs/examples/sites/delete-variable.md new file mode 100644 index 00000000..e2297008 --- /dev/null +++ b/docs/examples/sites/delete-variable.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.deleteVariable({ + siteId: '<SITE_ID>', + variableId: '<VARIABLE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/delete.md b/docs/examples/sites/delete.md new file mode 100644 index 00000000..cb6756e2 --- /dev/null +++ b/docs/examples/sites/delete.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.delete({ + siteId: '<SITE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/get-deployment-download.md b/docs/examples/sites/get-deployment-download.md new file mode 100644 index 00000000..badf3a7c --- /dev/null +++ b/docs/examples/sites/get-deployment-download.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Sites, DeploymentDownloadType } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = sites.getDeploymentDownload({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>', + type: DeploymentDownloadType.Source // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/get-deployment.md b/docs/examples/sites/get-deployment.md new file mode 100644 index 00000000..6986b429 --- /dev/null +++ b/docs/examples/sites/get-deployment.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.getDeployment({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/get-log.md b/docs/examples/sites/get-log.md new file mode 100644 index 00000000..5a2c590e --- /dev/null +++ b/docs/examples/sites/get-log.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.getLog({ + siteId: '<SITE_ID>', + logId: '<LOG_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/get-variable.md b/docs/examples/sites/get-variable.md new file mode 100644 index 00000000..e0fbe48e --- /dev/null +++ b/docs/examples/sites/get-variable.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.getVariable({ + siteId: '<SITE_ID>', + variableId: '<VARIABLE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/get.md b/docs/examples/sites/get.md new file mode 100644 index 00000000..012ab9d6 --- /dev/null +++ b/docs/examples/sites/get.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.get({ + siteId: '<SITE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/list-deployments.md b/docs/examples/sites/list-deployments.md new file mode 100644 index 00000000..b141b7f7 --- /dev/null +++ b/docs/examples/sites/list-deployments.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.listDeployments({ + siteId: '<SITE_ID>', + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md new file mode 100644 index 00000000..13d10fc1 --- /dev/null +++ b/docs/examples/sites/list-frameworks.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.listFrameworks(); + +console.log(result); +``` diff --git a/docs/examples/sites/list-logs.md b/docs/examples/sites/list-logs.md new file mode 100644 index 00000000..106aef04 --- /dev/null +++ b/docs/examples/sites/list-logs.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.listLogs({ + siteId: '<SITE_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md new file mode 100644 index 00000000..26faef89 --- /dev/null +++ b/docs/examples/sites/list-specifications.md @@ -0,0 +1,13 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.listSpecifications(); + +console.log(result); +``` diff --git a/docs/examples/sites/list-variables.md b/docs/examples/sites/list-variables.md new file mode 100644 index 00000000..31b80257 --- /dev/null +++ b/docs/examples/sites/list-variables.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.listVariables({ + siteId: '<SITE_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/list.md b/docs/examples/sites/list.md new file mode 100644 index 00000000..34f07a29 --- /dev/null +++ b/docs/examples/sites/list.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.list({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/update-deployment-status.md b/docs/examples/sites/update-deployment-status.md new file mode 100644 index 00000000..358c4dbb --- /dev/null +++ b/docs/examples/sites/update-deployment-status.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.updateDeploymentStatus({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/update-site-deployment.md b/docs/examples/sites/update-site-deployment.md new file mode 100644 index 00000000..7388a96b --- /dev/null +++ b/docs/examples/sites/update-site-deployment.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.updateSiteDeployment({ + siteId: '<SITE_ID>', + deploymentId: '<DEPLOYMENT_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/sites/update-variable.md b/docs/examples/sites/update-variable.md new file mode 100644 index 00000000..62e63991 --- /dev/null +++ b/docs/examples/sites/update-variable.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Sites } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.updateVariable({ + siteId: '<SITE_ID>', + variableId: '<VARIABLE_ID>', + key: '<KEY>', // optional + value: '<VALUE>', // optional + secret: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/sites/update.md b/docs/examples/sites/update.md new file mode 100644 index 00000000..0e925ec1 --- /dev/null +++ b/docs/examples/sites/update.md @@ -0,0 +1,35 @@ +```javascript +import { Client, Sites, Framework, BuildRuntime, Adapter } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const sites = new Sites(client); + +const result = await sites.update({ + siteId: '<SITE_ID>', + name: '<NAME>', + framework: Framework.Analog, + enabled: false, // optional + logging: false, // optional + timeout: 1, // optional + installCommand: '<INSTALL_COMMAND>', // optional + buildCommand: '<BUILD_COMMAND>', // optional + startCommand: '<START_COMMAND>', // optional + outputDirectory: '<OUTPUT_DIRECTORY>', // optional + buildRuntime: BuildRuntime.Node145, // optional + adapter: Adapter.Static, // optional + fallbackFile: '<FALLBACK_FILE>', // optional + installationId: '<INSTALLATION_ID>', // optional + providerRepositoryId: '<PROVIDER_REPOSITORY_ID>', // optional + providerBranch: '<PROVIDER_BRANCH>', // optional + providerSilentMode: false, // optional + providerRootDirectory: '<PROVIDER_ROOT_DIRECTORY>', // optional + buildSpecification: '', // optional + runtimeSpecification: '', // optional + deploymentRetention: 0 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/storage/create-bucket.md b/docs/examples/storage/create-bucket.md new file mode 100644 index 00000000..8908249d --- /dev/null +++ b/docs/examples/storage/create-bucket.md @@ -0,0 +1,25 @@ +```javascript +import { Client, Storage, Compression, Permission, Role } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const storage = new Storage(client); + +const result = await storage.createBucket({ + bucketId: '<BUCKET_ID>', + name: '<NAME>', + permissions: [Permission.read(Role.any())], // optional + fileSecurity: false, // optional + enabled: false, // optional + maximumFileSize: 1, // optional + allowedFileExtensions: [], // optional + compression: Compression.None, // optional + encryption: false, // optional + antivirus: false, // optional + transformations: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/storage/delete-bucket.md b/docs/examples/storage/delete-bucket.md new file mode 100644 index 00000000..3e87249d --- /dev/null +++ b/docs/examples/storage/delete-bucket.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Storage } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const storage = new Storage(client); + +const result = await storage.deleteBucket({ + bucketId: '<BUCKET_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/storage/get-bucket.md b/docs/examples/storage/get-bucket.md new file mode 100644 index 00000000..804d20af --- /dev/null +++ b/docs/examples/storage/get-bucket.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Storage } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const storage = new Storage(client); + +const result = await storage.getBucket({ + bucketId: '<BUCKET_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/storage/list-buckets.md b/docs/examples/storage/list-buckets.md new file mode 100644 index 00000000..a2313243 --- /dev/null +++ b/docs/examples/storage/list-buckets.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Storage } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const storage = new Storage(client); + +const result = await storage.listBuckets({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/storage/update-bucket.md b/docs/examples/storage/update-bucket.md new file mode 100644 index 00000000..974561f4 --- /dev/null +++ b/docs/examples/storage/update-bucket.md @@ -0,0 +1,25 @@ +```javascript +import { Client, Storage, Compression, Permission, Role } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const storage = new Storage(client); + +const result = await storage.updateBucket({ + bucketId: '<BUCKET_ID>', + name: '<NAME>', + permissions: [Permission.read(Role.any())], // optional + fileSecurity: false, // optional + enabled: false, // optional + maximumFileSize: 1, // optional + allowedFileExtensions: [], // optional + compression: Compression.None, // optional + encryption: false, // optional + antivirus: false, // optional + transformations: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-big-int-column.md b/docs/examples/tablesdb/create-big-int-column.md new file mode 100644 index 00000000..b3c0bd77 --- /dev/null +++ b/docs/examples/tablesdb/create-big-int-column.md @@ -0,0 +1,22 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createBigIntColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + min: null, // optional + max: null, // optional + xdefault: null, // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-boolean-column.md b/docs/examples/tablesdb/create-boolean-column.md new file mode 100644 index 00000000..0774f1d1 --- /dev/null +++ b/docs/examples/tablesdb/create-boolean-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createBooleanColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: false, // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md new file mode 100644 index 00000000..6357ae46 --- /dev/null +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createDatetimeColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '2020-10-15T06:38:00.000+00:00', // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-email-column.md b/docs/examples/tablesdb/create-email-column.md new file mode 100644 index 00000000..5d83cee6 --- /dev/null +++ b/docs/examples/tablesdb/create-email-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createEmailColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: 'email@example.com', // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md new file mode 100644 index 00000000..1a3f013b --- /dev/null +++ b/docs/examples/tablesdb/create-enum-column.md @@ -0,0 +1,21 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createEnumColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + elements: [], + required: false, + xdefault: '<DEFAULT>', // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-float-column.md b/docs/examples/tablesdb/create-float-column.md new file mode 100644 index 00000000..efc0553d --- /dev/null +++ b/docs/examples/tablesdb/create-float-column.md @@ -0,0 +1,22 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createFloatColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + min: null, // optional + max: null, // optional + xdefault: null, // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md new file mode 100644 index 00000000..ae53bf23 --- /dev/null +++ b/docs/examples/tablesdb/create-index.md @@ -0,0 +1,21 @@ +```javascript +import { Client, TablesDB, TablesDBIndexType, OrderBy } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createIndex({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + type: TablesDBIndexType.Key, + columns: [], + orders: [OrderBy.Asc], // optional + lengths: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-integer-column.md b/docs/examples/tablesdb/create-integer-column.md new file mode 100644 index 00000000..1bf07163 --- /dev/null +++ b/docs/examples/tablesdb/create-integer-column.md @@ -0,0 +1,22 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createIntegerColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + min: null, // optional + max: null, // optional + xdefault: null, // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-ip-column.md b/docs/examples/tablesdb/create-ip-column.md new file mode 100644 index 00000000..91c877ce --- /dev/null +++ b/docs/examples/tablesdb/create-ip-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createIpColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '', // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md new file mode 100644 index 00000000..0239130e --- /dev/null +++ b/docs/examples/tablesdb/create-line-column.md @@ -0,0 +1,19 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createLineColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: [[1, 2], [3, 4], [5, 6]] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-longtext-column.md b/docs/examples/tablesdb/create-longtext-column.md new file mode 100644 index 00000000..dda9dae5 --- /dev/null +++ b/docs/examples/tablesdb/create-longtext-column.md @@ -0,0 +1,21 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createLongtextColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '<DEFAULT>', // optional + array: false, // optional + encrypt: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-mediumtext-column.md b/docs/examples/tablesdb/create-mediumtext-column.md new file mode 100644 index 00000000..c5be8a15 --- /dev/null +++ b/docs/examples/tablesdb/create-mediumtext-column.md @@ -0,0 +1,21 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createMediumtextColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '<DEFAULT>', // optional + array: false, // optional + encrypt: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md new file mode 100644 index 00000000..7a61823c --- /dev/null +++ b/docs/examples/tablesdb/create-point-column.md @@ -0,0 +1,19 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createPointColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: [1, 2] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md new file mode 100644 index 00000000..fdf5c476 --- /dev/null +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -0,0 +1,19 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createPolygonColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-relationship-column.md b/docs/examples/tablesdb/create-relationship-column.md new file mode 100644 index 00000000..412f020d --- /dev/null +++ b/docs/examples/tablesdb/create-relationship-column.md @@ -0,0 +1,22 @@ +```javascript +import { Client, TablesDB, RelationshipType, RelationMutate } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createRelationshipColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + relatedTableId: '<RELATED_TABLE_ID>', + type: RelationshipType.OneToOne, + twoWay: false, // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: RelationMutate.Cascade // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 105c4445..3ca869aa 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -10,15 +10,16 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createRow({ databaseId: '<DATABASE_ID>', tableId: '<TABLE_ID>', - rowId: '<ROW_ID>', + rowId: '<ROW_ID>', // optional data: { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 30, "isAdmin": false - }, + }, // optional permissions: [Permission.read(Role.any())], // optional + rows: [], // optional transactionId: '<TRANSACTION_ID>' // optional }); diff --git a/docs/examples/tablesdb/create-string-column.md b/docs/examples/tablesdb/create-string-column.md new file mode 100644 index 00000000..0032c72a --- /dev/null +++ b/docs/examples/tablesdb/create-string-column.md @@ -0,0 +1,22 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createStringColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + size: 1, + required: false, + xdefault: '<DEFAULT>', // optional + array: false, // optional + encrypt: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-table.md b/docs/examples/tablesdb/create-table.md new file mode 100644 index 00000000..064719d4 --- /dev/null +++ b/docs/examples/tablesdb/create-table.md @@ -0,0 +1,22 @@ +```javascript +import { Client, TablesDB, Permission, Role } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createTable({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + name: '<NAME>', + permissions: [Permission.read(Role.any())], // optional + rowSecurity: false, // optional + enabled: false, // optional + columns: [], // optional + indexes: [] // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-text-column.md b/docs/examples/tablesdb/create-text-column.md new file mode 100644 index 00000000..07c96773 --- /dev/null +++ b/docs/examples/tablesdb/create-text-column.md @@ -0,0 +1,21 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createTextColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '<DEFAULT>', // optional + array: false, // optional + encrypt: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-url-column.md b/docs/examples/tablesdb/create-url-column.md new file mode 100644 index 00000000..1a619f2c --- /dev/null +++ b/docs/examples/tablesdb/create-url-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createUrlColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: 'https://example.com', // optional + array: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create-varchar-column.md b/docs/examples/tablesdb/create-varchar-column.md new file mode 100644 index 00000000..9d5dbd68 --- /dev/null +++ b/docs/examples/tablesdb/create-varchar-column.md @@ -0,0 +1,22 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createVarcharColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + size: 1, + required: false, + xdefault: '<DEFAULT>', // optional + array: false, // optional + encrypt: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md new file mode 100644 index 00000000..458d1f6d --- /dev/null +++ b/docs/examples/tablesdb/create.md @@ -0,0 +1,17 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.create({ + databaseId: '<DATABASE_ID>', + name: '<NAME>', + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/delete-column.md b/docs/examples/tablesdb/delete-column.md new file mode 100644 index 00000000..d61e885b --- /dev/null +++ b/docs/examples/tablesdb/delete-column.md @@ -0,0 +1,17 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.deleteColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '' +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/delete-index.md b/docs/examples/tablesdb/delete-index.md new file mode 100644 index 00000000..33229588 --- /dev/null +++ b/docs/examples/tablesdb/delete-index.md @@ -0,0 +1,17 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.deleteIndex({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '' +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md new file mode 100644 index 00000000..fe1867cb --- /dev/null +++ b/docs/examples/tablesdb/delete-rows.md @@ -0,0 +1,18 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.deleteRows({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + queries: [], // optional + transactionId: '<TRANSACTION_ID>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/delete-table.md b/docs/examples/tablesdb/delete-table.md new file mode 100644 index 00000000..701ccbb6 --- /dev/null +++ b/docs/examples/tablesdb/delete-table.md @@ -0,0 +1,16 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.deleteTable({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/delete.md b/docs/examples/tablesdb/delete.md new file mode 100644 index 00000000..73a9ec80 --- /dev/null +++ b/docs/examples/tablesdb/delete.md @@ -0,0 +1,15 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.delete({ + databaseId: '<DATABASE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/get-column.md b/docs/examples/tablesdb/get-column.md new file mode 100644 index 00000000..e3a6c982 --- /dev/null +++ b/docs/examples/tablesdb/get-column.md @@ -0,0 +1,17 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.getColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '' +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/get-index.md b/docs/examples/tablesdb/get-index.md new file mode 100644 index 00000000..d3629791 --- /dev/null +++ b/docs/examples/tablesdb/get-index.md @@ -0,0 +1,17 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.getIndex({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '' +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/get-table.md b/docs/examples/tablesdb/get-table.md new file mode 100644 index 00000000..828b8f1a --- /dev/null +++ b/docs/examples/tablesdb/get-table.md @@ -0,0 +1,16 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.getTable({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/get.md b/docs/examples/tablesdb/get.md new file mode 100644 index 00000000..f1623964 --- /dev/null +++ b/docs/examples/tablesdb/get.md @@ -0,0 +1,15 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.get({ + databaseId: '<DATABASE_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/list-columns.md b/docs/examples/tablesdb/list-columns.md new file mode 100644 index 00000000..68aa5218 --- /dev/null +++ b/docs/examples/tablesdb/list-columns.md @@ -0,0 +1,18 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.listColumns({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/list-indexes.md b/docs/examples/tablesdb/list-indexes.md new file mode 100644 index 00000000..41430a18 --- /dev/null +++ b/docs/examples/tablesdb/list-indexes.md @@ -0,0 +1,18 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.listIndexes({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/list-tables.md b/docs/examples/tablesdb/list-tables.md new file mode 100644 index 00000000..f224cecc --- /dev/null +++ b/docs/examples/tablesdb/list-tables.md @@ -0,0 +1,18 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.listTables({ + databaseId: '<DATABASE_ID>', + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/list.md b/docs/examples/tablesdb/list.md new file mode 100644 index 00000000..86908f75 --- /dev/null +++ b/docs/examples/tablesdb/list.md @@ -0,0 +1,17 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.list({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-big-int-column.md b/docs/examples/tablesdb/update-big-int-column.md new file mode 100644 index 00000000..25cdbba3 --- /dev/null +++ b/docs/examples/tablesdb/update-big-int-column.md @@ -0,0 +1,22 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateBigIntColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-boolean-column.md b/docs/examples/tablesdb/update-boolean-column.md new file mode 100644 index 00000000..a5c66a01 --- /dev/null +++ b/docs/examples/tablesdb/update-boolean-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateBooleanColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: false, + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md new file mode 100644 index 00000000..af608bbc --- /dev/null +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateDatetimeColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '2020-10-15T06:38:00.000+00:00', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-email-column.md b/docs/examples/tablesdb/update-email-column.md new file mode 100644 index 00000000..2a53e577 --- /dev/null +++ b/docs/examples/tablesdb/update-email-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateEmailColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: 'email@example.com', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md new file mode 100644 index 00000000..873d7e03 --- /dev/null +++ b/docs/examples/tablesdb/update-enum-column.md @@ -0,0 +1,21 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateEnumColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + elements: [], + required: false, + xdefault: '<DEFAULT>', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-float-column.md b/docs/examples/tablesdb/update-float-column.md new file mode 100644 index 00000000..97d1ac7c --- /dev/null +++ b/docs/examples/tablesdb/update-float-column.md @@ -0,0 +1,22 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateFloatColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-integer-column.md b/docs/examples/tablesdb/update-integer-column.md new file mode 100644 index 00000000..377b1c8c --- /dev/null +++ b/docs/examples/tablesdb/update-integer-column.md @@ -0,0 +1,22 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateIntegerColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-ip-column.md b/docs/examples/tablesdb/update-ip-column.md new file mode 100644 index 00000000..c45e95fb --- /dev/null +++ b/docs/examples/tablesdb/update-ip-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateIpColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md new file mode 100644 index 00000000..1d6e7a46 --- /dev/null +++ b/docs/examples/tablesdb/update-line-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateLineColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: [[1, 2], [3, 4], [5, 6]], // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-longtext-column.md b/docs/examples/tablesdb/update-longtext-column.md new file mode 100644 index 00000000..61b1ae88 --- /dev/null +++ b/docs/examples/tablesdb/update-longtext-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateLongtextColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '<DEFAULT>', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-mediumtext-column.md b/docs/examples/tablesdb/update-mediumtext-column.md new file mode 100644 index 00000000..99174099 --- /dev/null +++ b/docs/examples/tablesdb/update-mediumtext-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateMediumtextColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '<DEFAULT>', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md new file mode 100644 index 00000000..186b6ff0 --- /dev/null +++ b/docs/examples/tablesdb/update-point-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updatePointColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: [1, 2], // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md new file mode 100644 index 00000000..18f1aabb --- /dev/null +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updatePolygonColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-relationship-column.md b/docs/examples/tablesdb/update-relationship-column.md new file mode 100644 index 00000000..fde78015 --- /dev/null +++ b/docs/examples/tablesdb/update-relationship-column.md @@ -0,0 +1,19 @@ +```javascript +import { Client, TablesDB, RelationMutate } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateRelationshipColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + onDelete: RelationMutate.Cascade, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md new file mode 100644 index 00000000..8e2bca2d --- /dev/null +++ b/docs/examples/tablesdb/update-rows.md @@ -0,0 +1,25 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateRows({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + data: { + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 33, + "isAdmin": false + }, // optional + queries: [], // optional + transactionId: '<TRANSACTION_ID>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-string-column.md b/docs/examples/tablesdb/update-string-column.md new file mode 100644 index 00000000..f2d493b6 --- /dev/null +++ b/docs/examples/tablesdb/update-string-column.md @@ -0,0 +1,21 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateStringColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '<DEFAULT>', + size: 1, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md new file mode 100644 index 00000000..af4068d8 --- /dev/null +++ b/docs/examples/tablesdb/update-table.md @@ -0,0 +1,21 @@ +```javascript +import { Client, TablesDB, Permission, Role } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateTable({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + name: '<NAME>', // optional + permissions: [Permission.read(Role.any())], // optional + rowSecurity: false, // optional + enabled: false, // optional + purge: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-text-column.md b/docs/examples/tablesdb/update-text-column.md new file mode 100644 index 00000000..208c044e --- /dev/null +++ b/docs/examples/tablesdb/update-text-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateTextColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '<DEFAULT>', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-url-column.md b/docs/examples/tablesdb/update-url-column.md new file mode 100644 index 00000000..1af088c8 --- /dev/null +++ b/docs/examples/tablesdb/update-url-column.md @@ -0,0 +1,20 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateUrlColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: 'https://example.com', + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update-varchar-column.md b/docs/examples/tablesdb/update-varchar-column.md new file mode 100644 index 00000000..d387b934 --- /dev/null +++ b/docs/examples/tablesdb/update-varchar-column.md @@ -0,0 +1,21 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.updateVarcharColumn({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + key: '', + required: false, + xdefault: '<DEFAULT>', + size: 1, // optional + newKey: '' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md new file mode 100644 index 00000000..f0a8a2f7 --- /dev/null +++ b/docs/examples/tablesdb/update.md @@ -0,0 +1,17 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.update({ + databaseId: '<DATABASE_ID>', + name: '<NAME>', // optional + enabled: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md new file mode 100644 index 00000000..a01aca2e --- /dev/null +++ b/docs/examples/tablesdb/upsert-rows.md @@ -0,0 +1,18 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.upsertRows({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rows: [], + transactionId: '<TRANSACTION_ID>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tokens/create-file-token.md b/docs/examples/tokens/create-file-token.md new file mode 100644 index 00000000..40061e71 --- /dev/null +++ b/docs/examples/tokens/create-file-token.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Tokens } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tokens = new Tokens(client); + +const result = await tokens.createFileToken({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + expire: '2020-10-15T06:38:00.000+00:00' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tokens/delete.md b/docs/examples/tokens/delete.md new file mode 100644 index 00000000..448d2aa7 --- /dev/null +++ b/docs/examples/tokens/delete.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Tokens } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tokens = new Tokens(client); + +const result = await tokens.delete({ + tokenId: '<TOKEN_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/tokens/get.md b/docs/examples/tokens/get.md new file mode 100644 index 00000000..257f81f9 --- /dev/null +++ b/docs/examples/tokens/get.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Tokens } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tokens = new Tokens(client); + +const result = await tokens.get({ + tokenId: '<TOKEN_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/tokens/list.md b/docs/examples/tokens/list.md new file mode 100644 index 00000000..ac836baa --- /dev/null +++ b/docs/examples/tokens/list.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Tokens } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tokens = new Tokens(client); + +const result = await tokens.list({ + bucketId: '<BUCKET_ID>', + fileId: '<FILE_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/tokens/update.md b/docs/examples/tokens/update.md new file mode 100644 index 00000000..b2284219 --- /dev/null +++ b/docs/examples/tokens/update.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Tokens } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tokens = new Tokens(client); + +const result = await tokens.update({ + tokenId: '<TOKEN_ID>', + expire: '2020-10-15T06:38:00.000+00:00' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/usage/list-events.md b/docs/examples/usage/list-events.md new file mode 100644 index 00000000..8b3b8559 --- /dev/null +++ b/docs/examples/usage/list-events.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Usage } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const usage = new Usage(client); + +const result = await usage.listEvents({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/usage/list-gauges.md b/docs/examples/usage/list-gauges.md new file mode 100644 index 00000000..9a2e97f4 --- /dev/null +++ b/docs/examples/usage/list-gauges.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Usage } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const usage = new Usage(client); + +const result = await usage.listGauges({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-argon-2-user.md b/docs/examples/users/create-argon-2-user.md new file mode 100644 index 00000000..fd77c87d --- /dev/null +++ b/docs/examples/users/create-argon-2-user.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createArgon2User({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-bcrypt-user.md b/docs/examples/users/create-bcrypt-user.md new file mode 100644 index 00000000..4f283be0 --- /dev/null +++ b/docs/examples/users/create-bcrypt-user.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createBcryptUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-jwt.md b/docs/examples/users/create-jwt.md new file mode 100644 index 00000000..07a17be6 --- /dev/null +++ b/docs/examples/users/create-jwt.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createJWT({ + userId: '<USER_ID>', + sessionId: '<SESSION_ID>', // optional + duration: 0 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-md-5-user.md b/docs/examples/users/create-md-5-user.md new file mode 100644 index 00000000..851d9fc9 --- /dev/null +++ b/docs/examples/users/create-md-5-user.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createMD5User({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md new file mode 100644 index 00000000..a9cc4bd4 --- /dev/null +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createMfaRecoveryCodes({ + userId: '<USER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-ph-pass-user.md b/docs/examples/users/create-ph-pass-user.md new file mode 100644 index 00000000..f7464853 --- /dev/null +++ b/docs/examples/users/create-ph-pass-user.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createPHPassUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + name: '<NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-scrypt-modified-user.md b/docs/examples/users/create-scrypt-modified-user.md new file mode 100644 index 00000000..2a783bab --- /dev/null +++ b/docs/examples/users/create-scrypt-modified-user.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createScryptModifiedUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + passwordSalt: '<PASSWORD_SALT>', + passwordSaltSeparator: '<PASSWORD_SALT_SEPARATOR>', + passwordSignerKey: '<PASSWORD_SIGNER_KEY>', + name: '<NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-scrypt-user.md b/docs/examples/users/create-scrypt-user.md new file mode 100644 index 00000000..808539b0 --- /dev/null +++ b/docs/examples/users/create-scrypt-user.md @@ -0,0 +1,23 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createScryptUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + passwordSalt: '<PASSWORD_SALT>', + passwordCpu: null, + passwordMemory: null, + passwordParallel: null, + passwordLength: null, + name: '<NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-session.md b/docs/examples/users/create-session.md new file mode 100644 index 00000000..db9f0202 --- /dev/null +++ b/docs/examples/users/create-session.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createSession({ + userId: '<USER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-sha-user.md b/docs/examples/users/create-sha-user.md new file mode 100644 index 00000000..c3d7fbbd --- /dev/null +++ b/docs/examples/users/create-sha-user.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Users, PasswordHash } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createSHAUser({ + userId: '<USER_ID>', + email: 'email@example.com', + password: 'password', + passwordVersion: PasswordHash.Sha1, // optional + name: '<NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-target.md b/docs/examples/users/create-target.md new file mode 100644 index 00000000..b62723ce --- /dev/null +++ b/docs/examples/users/create-target.md @@ -0,0 +1,20 @@ +```javascript +import { Client, Users, MessagingProviderType } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + providerType: MessagingProviderType.Email, + identifier: '<IDENTIFIER>', + providerId: '<PROVIDER_ID>', // optional + name: '<NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-token.md b/docs/examples/users/create-token.md new file mode 100644 index 00000000..39d85e57 --- /dev/null +++ b/docs/examples/users/create-token.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.createToken({ + userId: '<USER_ID>', + length: 4, // optional + expire: 60 // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create.md b/docs/examples/users/create.md new file mode 100644 index 00000000..ae89fb9f --- /dev/null +++ b/docs/examples/users/create.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.create({ + userId: '<USER_ID>', + email: 'email@example.com', // optional + phone: '+12065550100', // optional + password: '', // optional + name: '<NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/delete-identity.md b/docs/examples/users/delete-identity.md new file mode 100644 index 00000000..595d3d9b --- /dev/null +++ b/docs/examples/users/delete-identity.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.deleteIdentity({ + identityId: '<IDENTITY_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md new file mode 100644 index 00000000..81d5b18b --- /dev/null +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users, AuthenticatorType } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.deleteMfaAuthenticator({ + userId: '<USER_ID>', + type: AuthenticatorType.Totp +}); + +console.log(result); +``` diff --git a/docs/examples/account/update-verification.md b/docs/examples/users/delete-session.md similarity index 60% rename from docs/examples/account/update-verification.md rename to docs/examples/users/delete-session.md index 3b52a83c..49ccaf42 100644 --- a/docs/examples/account/update-verification.md +++ b/docs/examples/users/delete-session.md @@ -1,15 +1,15 @@ ```javascript -import { Client, Account } from "appwrite"; +import { Client, Users } from "appwrite"; const client = new Client() .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint .setProject('<YOUR_PROJECT_ID>'); // Your project ID -const account = new Account(client); +const users = new Users(client); -const result = await account.updateVerification({ +const result = await users.deleteSession({ userId: '<USER_ID>', - secret: '<SECRET>' + sessionId: '<SESSION_ID>' }); console.log(result); diff --git a/docs/examples/users/delete-sessions.md b/docs/examples/users/delete-sessions.md new file mode 100644 index 00000000..7ba6f4fd --- /dev/null +++ b/docs/examples/users/delete-sessions.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.deleteSessions({ + userId: '<USER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/delete-target.md b/docs/examples/users/delete-target.md new file mode 100644 index 00000000..3e0eb547 --- /dev/null +++ b/docs/examples/users/delete-target.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.deleteTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/delete.md b/docs/examples/users/delete.md new file mode 100644 index 00000000..82974a00 --- /dev/null +++ b/docs/examples/users/delete.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.delete({ + userId: '<USER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md new file mode 100644 index 00000000..c9c19e22 --- /dev/null +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.getMfaRecoveryCodes({ + userId: '<USER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/get-prefs.md b/docs/examples/users/get-prefs.md new file mode 100644 index 00000000..f5f8df30 --- /dev/null +++ b/docs/examples/users/get-prefs.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.getPrefs({ + userId: '<USER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/get-target.md b/docs/examples/users/get-target.md new file mode 100644 index 00000000..4426de45 --- /dev/null +++ b/docs/examples/users/get-target.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.getTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/get.md b/docs/examples/users/get.md new file mode 100644 index 00000000..a3aa0246 --- /dev/null +++ b/docs/examples/users/get.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.get({ + userId: '<USER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/list-identities.md b/docs/examples/users/list-identities.md new file mode 100644 index 00000000..f3500c6e --- /dev/null +++ b/docs/examples/users/list-identities.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.listIdentities({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md new file mode 100644 index 00000000..58516305 --- /dev/null +++ b/docs/examples/users/list-logs.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.listLogs({ + userId: '<USER_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/list-memberships.md b/docs/examples/users/list-memberships.md new file mode 100644 index 00000000..07d7e782 --- /dev/null +++ b/docs/examples/users/list-memberships.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.listMemberships({ + userId: '<USER_ID>', + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md new file mode 100644 index 00000000..b15be0c8 --- /dev/null +++ b/docs/examples/users/list-mfa-factors.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.listMfaFactors({ + userId: '<USER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/list-sessions.md b/docs/examples/users/list-sessions.md new file mode 100644 index 00000000..f5f1d7df --- /dev/null +++ b/docs/examples/users/list-sessions.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.listSessions({ + userId: '<USER_ID>', + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/list-targets.md b/docs/examples/users/list-targets.md new file mode 100644 index 00000000..38276a41 --- /dev/null +++ b/docs/examples/users/list-targets.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.listTargets({ + userId: '<USER_ID>', + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/list.md b/docs/examples/users/list.md new file mode 100644 index 00000000..10f14129 --- /dev/null +++ b/docs/examples/users/list.md @@ -0,0 +1,17 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.list({ + queries: [], // optional + search: '<SEARCH>', // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-email-verification.md b/docs/examples/users/update-email-verification.md new file mode 100644 index 00000000..41cc7818 --- /dev/null +++ b/docs/examples/users/update-email-verification.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updateEmailVerification({ + userId: '<USER_ID>', + emailVerification: false +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-email.md b/docs/examples/users/update-email.md new file mode 100644 index 00000000..26f56f62 --- /dev/null +++ b/docs/examples/users/update-email.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updateEmail({ + userId: '<USER_ID>', + email: 'email@example.com' +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-impersonator.md b/docs/examples/users/update-impersonator.md new file mode 100644 index 00000000..917cd1f7 --- /dev/null +++ b/docs/examples/users/update-impersonator.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updateImpersonator({ + userId: '<USER_ID>', + impersonator: false +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md new file mode 100644 index 00000000..5754ca2e --- /dev/null +++ b/docs/examples/users/update-labels.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updateLabels({ + userId: '<USER_ID>', + labels: [] +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md new file mode 100644 index 00000000..c79714d6 --- /dev/null +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updateMfaRecoveryCodes({ + userId: '<USER_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md new file mode 100644 index 00000000..9a4c579c --- /dev/null +++ b/docs/examples/users/update-mfa.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updateMfa({ + userId: '<USER_ID>', + mfa: false +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-name.md b/docs/examples/users/update-name.md new file mode 100644 index 00000000..5462a36d --- /dev/null +++ b/docs/examples/users/update-name.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updateName({ + userId: '<USER_ID>', + name: '<NAME>' +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-password.md b/docs/examples/users/update-password.md new file mode 100644 index 00000000..62915d50 --- /dev/null +++ b/docs/examples/users/update-password.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updatePassword({ + userId: '<USER_ID>', + password: '' +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-phone-verification.md b/docs/examples/users/update-phone-verification.md new file mode 100644 index 00000000..882cc511 --- /dev/null +++ b/docs/examples/users/update-phone-verification.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updatePhoneVerification({ + userId: '<USER_ID>', + phoneVerification: false +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-phone.md b/docs/examples/users/update-phone.md new file mode 100644 index 00000000..8b367e9a --- /dev/null +++ b/docs/examples/users/update-phone.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updatePhone({ + userId: '<USER_ID>', + number: '+12065550100' +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-prefs.md b/docs/examples/users/update-prefs.md new file mode 100644 index 00000000..89f38d33 --- /dev/null +++ b/docs/examples/users/update-prefs.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updatePrefs({ + userId: '<USER_ID>', + prefs: {} +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-status.md b/docs/examples/users/update-status.md new file mode 100644 index 00000000..c9e583b2 --- /dev/null +++ b/docs/examples/users/update-status.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updateStatus({ + userId: '<USER_ID>', + status: false +}); + +console.log(result); +``` diff --git a/docs/examples/users/update-target.md b/docs/examples/users/update-target.md new file mode 100644 index 00000000..76868514 --- /dev/null +++ b/docs/examples/users/update-target.md @@ -0,0 +1,19 @@ +```javascript +import { Client, Users } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const users = new Users(client); + +const result = await users.updateTarget({ + userId: '<USER_ID>', + targetId: '<TARGET_ID>', + identifier: '<IDENTIFIER>', // optional + providerId: '<PROVIDER_ID>', // optional + name: '<NAME>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md new file mode 100644 index 00000000..d5d87086 --- /dev/null +++ b/docs/examples/webhooks/create.md @@ -0,0 +1,23 @@ +```javascript +import { Client, Webhooks } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const webhooks = new Webhooks(client); + +const result = await webhooks.create({ + webhookId: '<WEBHOOK_ID>', + url: '', + name: '<NAME>', + events: [], + enabled: false, // optional + tls: false, // optional + authUsername: '<AUTH_USERNAME>', // optional + authPassword: '<AUTH_PASSWORD>', // optional + secret: '<SECRET>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/webhooks/delete.md b/docs/examples/webhooks/delete.md new file mode 100644 index 00000000..d80acfbd --- /dev/null +++ b/docs/examples/webhooks/delete.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Webhooks } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const webhooks = new Webhooks(client); + +const result = await webhooks.delete({ + webhookId: '<WEBHOOK_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/webhooks/get.md b/docs/examples/webhooks/get.md new file mode 100644 index 00000000..5d737d5e --- /dev/null +++ b/docs/examples/webhooks/get.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Webhooks } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const webhooks = new Webhooks(client); + +const result = await webhooks.get({ + webhookId: '<WEBHOOK_ID>' +}); + +console.log(result); +``` diff --git a/docs/examples/webhooks/list.md b/docs/examples/webhooks/list.md new file mode 100644 index 00000000..282d3546 --- /dev/null +++ b/docs/examples/webhooks/list.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Webhooks } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const webhooks = new Webhooks(client); + +const result = await webhooks.list({ + queries: [], // optional + total: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/webhooks/update-secret.md b/docs/examples/webhooks/update-secret.md new file mode 100644 index 00000000..7736f73c --- /dev/null +++ b/docs/examples/webhooks/update-secret.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Webhooks } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const webhooks = new Webhooks(client); + +const result = await webhooks.updateSecret({ + webhookId: '<WEBHOOK_ID>', + secret: '<SECRET>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md new file mode 100644 index 00000000..2dad3865 --- /dev/null +++ b/docs/examples/webhooks/update.md @@ -0,0 +1,22 @@ +```javascript +import { Client, Webhooks } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const webhooks = new Webhooks(client); + +const result = await webhooks.update({ + webhookId: '<WEBHOOK_ID>', + name: '<NAME>', + url: '', + events: [], + enabled: false, // optional + tls: false, // optional + authUsername: '<AUTH_USERNAME>', // optional + authPassword: '<AUTH_PASSWORD>' // optional +}); + +console.log(result); +``` diff --git a/package-lock.json b/package-lock.json index ee1f26d3..a3aa13e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "appwrite", - "version": "25.1.1", + "version": "26.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "appwrite", - "version": "25.1.1", + "version": "26.0.0", "license": "BSD-3-Clause", "dependencies": { "json-bigint": "1.0.0" diff --git a/package.json b/package.json index af76357c..b3307c14 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "appwrite", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "25.1.1", + "version": "26.0.0", "license": "BSD-3-Clause", "main": "dist/cjs/sdk.js", "exports": { diff --git a/src/client.ts b/src/client.ts index 26012676..38a1ac44 100644 --- a/src/client.ts +++ b/src/client.ts @@ -344,8 +344,48 @@ class AppwriteException extends Error { /** * Client that handles requests to Appwrite */ -class Client { +type SDKPlatform = 'client' | 'server'; +type ClientAuth = 'browser' | 'session' | 'devKey' | 'impersonation'; +type ServerAuth = 'apiKey' | 'jwt' | 'cookie'; +type Auth = ClientAuth | ServerAuth; +declare const clientAuthBrand: unique symbol; + +// Forces TypeScript to display the expanded shape on hover instead of an alias name. +type Prettify<T> = { [K in keyof T]: T[K] } & {}; + +type BaseClientParams = { + endpoint: string; + endpointRealtime?: string; + selfSigned?: boolean; + projectId: string; + locale?: string; +}; + +type ImpersonationTarget = + | { userId: string; email?: never; phone?: never } + | { email: string; userId?: never; phone?: never } + | { phone: string; userId?: never; email?: never }; + +type LegacyClientSetter = Extract<keyof ClientRuntime<any>, `set${string}`>; +type ClientAuthBuilder = Extract<keyof ClientRuntime<any>, `with${string}`>; +type ClientInternalMethod = LegacyClientSetter | ClientAuthBuilder; +export type Client<TAuth extends Auth = 'browser'> = Omit<ClientRuntime<TAuth>, ClientInternalMethod>; +type LegacyClient<TAuth extends Auth = 'browser'> = Omit<ClientRuntime<TAuth>, ClientAuthBuilder>; + +type ClientConstructor = { + new <TAuth extends Auth = 'browser'>(): LegacyClient<TAuth>; + from(params: Prettify<BaseClientParams>): Client<'browser'>; + fromSession(params: Prettify<BaseClientParams & { session: string }>): Client<'session'>; + fromAPIKey(params: Prettify<BaseClientParams & { apiKey: string }>): Client<'apiKey'>; + fromCookie(params: Prettify<BaseClientParams & { cookie: string }>): Client<'cookie'>; + fromJWT(params: Prettify<BaseClientParams & { jwt: string }>): Client<'jwt'>; + fromDevKey(params: Prettify<BaseClientParams & { devKey: string }>): Client<'devKey'>; + fromImpersonation(params: Prettify<BaseClientParams & { session: string } & ImpersonationTarget>): Client<'impersonation'>; +}; + +class ClientRuntime<TAuth extends Auth = 'browser'> { static CHUNK_SIZE = 1024 * 1024 * 5; + declare readonly [clientAuthBrand]?: TAuth; /** * Holds configuration such as project. @@ -362,6 +402,9 @@ class Client { impersonateuserid: string; impersonateuseremail: string; impersonateuserphone: string; + key: string; + forwardeduseragent: string; + selfSigned: boolean; } = { endpoint: 'https://cloud.appwrite.io/v1', endpointRealtime: '', @@ -374,18 +417,133 @@ class Client { impersonateuserid: '', impersonateuseremail: '', impersonateuserphone: '', + key: '', + forwardeduseragent: '', + selfSigned: false, }; + + private sdkPlatform: SDKPlatform = 'server'; + /** * Custom headers for API requests. */ headers: Headers = { 'x-sdk-name': 'Web', - 'x-sdk-platform': 'client', + 'x-sdk-platform': 'server', 'x-sdk-language': 'web', - 'x-sdk-version': '25.1.1', + 'x-sdk-version': '26.0.0', 'X-Appwrite-Response-Format': '1.9.5', }; + static from(params: Prettify<BaseClientParams>): Client<'browser'> { + return new ClientRuntime<'browser'>().applyBase<'browser'>(params, 'client'); + } + + static fromSession(params: Prettify<BaseClientParams & { session: string }>): Client<'session'> { + const client = new ClientRuntime<'session'>() + .applyBase<'session'>(params, 'client'); + client.headers['X-Appwrite-Session'] = params.session; + client.config.session = params.session; + return client; + } + + static fromAPIKey(params: Prettify<BaseClientParams & { apiKey: string }>): Client<'apiKey'> { + const client = new ClientRuntime<'apiKey'>() + .applyBase<'apiKey'>(params, 'server'); + client.headers['X-Appwrite-Key'] = params.apiKey; + (client.config as unknown as Record<string, string>).key = params.apiKey; + return client; + } + + static fromCookie(params: Prettify<BaseClientParams & { cookie: string }>): Client<'cookie'> { + const client = new ClientRuntime<'cookie'>() + .applyBase<'cookie'>(params, 'server'); + client.headers['Cookie'] = params.cookie; + client.config.cookie = params.cookie; + return client; + } + + static fromJWT(params: Prettify<BaseClientParams & { jwt: string }>): Client<'jwt'> { + const client = new ClientRuntime<'jwt'>() + .applyBase<'jwt'>(params, 'server'); + client.headers['X-Appwrite-JWT'] = params.jwt; + client.config.jwt = params.jwt; + return client; + } + + static fromDevKey(params: Prettify<BaseClientParams & { devKey: string }>): Client<'devKey'> { + const client = new ClientRuntime<'devKey'>() + .applyBase<'devKey'>(params, 'client'); + client.headers['X-Appwrite-Dev-Key'] = params.devKey; + client.config.devkey = params.devKey; + return client; + } + + static fromImpersonation(params: Prettify<BaseClientParams & { session: string } & ImpersonationTarget>): Client<'impersonation'> { + const targets = [ + params.userId !== undefined, + params.email !== undefined, + params.phone !== undefined + ].filter(Boolean).length; + + if (targets !== 1) { + throw new AppwriteException('Exactly one impersonation target must be provided'); + } + + const client = new ClientRuntime<'impersonation'>() + .applyBase<'impersonation'>(params, 'client'); + + client.headers['X-Appwrite-Session'] = params.session; + client.config.session = params.session; + + if (params.userId !== undefined) { + client.headers['X-Appwrite-Impersonate-User-Id'] = params.userId; + client.config.impersonateuserid = params.userId; + return client; + } + if (params.email !== undefined) { + client.headers['X-Appwrite-Impersonate-User-Email'] = params.email; + client.config.impersonateuseremail = params.email; + return client; + } + client.headers['X-Appwrite-Impersonate-User-Phone'] = params.phone; + client.config.impersonateuserphone = params.phone; + return client; + } + + withJWT(jwt: string): this { + this.headers['X-Appwrite-JWT'] = jwt; + this.config.jwt = jwt; + return this; + } + + withForwardedUserAgent(forwardedUserAgent: string): this { + this.headers['X-Forwarded-User-Agent'] = forwardedUserAgent; + return this; + } + + private applyBase<T extends Auth>(params: BaseClientParams, sdkPlatform: SDKPlatform): ClientRuntime<T> { + const client = this as unknown as ClientRuntime<T>; + client.sdkPlatform = sdkPlatform; + client.headers['x-sdk-platform'] = sdkPlatform === 'server' ? 'server' : 'client'; + client.setEndpoint(params.endpoint); + client.setProject(params.projectId); + + if (params.locale !== undefined) { + client.setLocale(params.locale); + } + + if (params.endpointRealtime !== undefined) { + client.setEndpointRealtime(params.endpointRealtime); + } + + if (params.selfSigned !== undefined) { + client.setSelfSigned(params.selfSigned); + } + + return client; + } + /** * Get Headers * @@ -407,6 +565,9 @@ class Client { * * @returns {this} */ + /** + * @deprecated Use `Client.from`, `Client.fromSession`, `Client.fromAPIKey`, or another static factory instead. + */ setEndpoint(endpoint: string): this { if (!endpoint || typeof endpoint !== 'string') { throw new AppwriteException('Endpoint must be a valid string'); @@ -429,6 +590,9 @@ class Client { * * @returns {this} */ + /** + * @deprecated Use the `endpointRealtime` field on a static factory params object instead. + */ setEndpointRealtime(endpointRealtime: string): this { if (!endpointRealtime || typeof endpointRealtime !== 'string') { throw new AppwriteException('Endpoint must be a valid string'); @@ -443,130 +607,120 @@ class Client { } /** - * Set Project + * Set self-signed * - * Your project ID + * @param {boolean} selfSigned * - * @param value string - * - * @return {this} + * @returns {this} + */ + /** + * @deprecated Use the `selfSigned` field on a static factory params object instead. + */ + setSelfSigned(selfSigned: boolean): this { + this.config.selfSigned = selfSigned; + return this; + } + + /** + * @deprecated Use a static client factory or factory params object instead. */ setProject(value: string): this { this.headers['X-Appwrite-Project'] = value; this.config.project = value; - return this; + return this as unknown as this; } + /** - * Set JWT - * - * Your secret JSON Web Token - * - * @param value string - * - * @return {this} + * @deprecated Use a static client factory or factory params object instead. */ - setJWT(value: string): this { + setJWT(value: string): ClientRuntime<'jwt'> { this.headers['X-Appwrite-JWT'] = value; this.config.jwt = value; - return this; + return this as unknown as ClientRuntime<'jwt'>; } + /** - * Set Locale - * - * @param value string - * - * @return {this} + * @deprecated Use a static client factory or factory params object instead. */ setLocale(value: string): this { this.headers['X-Appwrite-Locale'] = value; this.config.locale = value; - return this; + return this as unknown as this; } + /** - * Set Session - * - * The user session to authenticate with - * - * @param value string - * - * @return {this} + * @deprecated Use a static client factory or factory params object instead. */ - setSession(value: string): this { + setSession(value: string): ClientRuntime<'session'> { this.headers['X-Appwrite-Session'] = value; this.config.session = value; - return this; + return this as unknown as ClientRuntime<'session'>; } + /** - * Set DevKey - * - * Your secret dev API key - * - * @param value string - * - * @return {this} + * @deprecated Use a static client factory or factory params object instead. */ - setDevKey(value: string): this { + setDevKey(value: string): ClientRuntime<'devKey'> { this.headers['X-Appwrite-Dev-Key'] = value; this.config.devkey = value; - return this; + return this as unknown as ClientRuntime<'devKey'>; } + /** - * Set Cookie - * - * The user cookie to authenticate with. Used by SDKs that forward an incoming Cookie header in server-side runtimes. - * - * @param value string - * - * @return {this} + * @deprecated Use a static client factory or factory params object instead. */ - setCookie(value: string): this { + setCookie(value: string): ClientRuntime<'cookie'> { this.headers['Cookie'] = value; this.config.cookie = value; - return this; + return this as unknown as ClientRuntime<'cookie'>; } + /** - * Set ImpersonateUserId - * - * Impersonate a user by ID on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. - * - * @param value string - * - * @return {this} + * @deprecated Use a static client factory or factory params object instead. */ - setImpersonateUserId(value: string): this { + setImpersonateUserId(value: string): ClientRuntime<'impersonation'> { this.headers['X-Appwrite-Impersonate-User-Id'] = value; this.config.impersonateuserid = value; - return this; + return this as unknown as ClientRuntime<'impersonation'>; } + /** - * Set ImpersonateUserEmail - * - * Impersonate a user by email on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. - * - * @param value string - * - * @return {this} + * @deprecated Use a static client factory or factory params object instead. */ - setImpersonateUserEmail(value: string): this { + setImpersonateUserEmail(value: string): ClientRuntime<'impersonation'> { this.headers['X-Appwrite-Impersonate-User-Email'] = value; this.config.impersonateuseremail = value; - return this; + return this as unknown as ClientRuntime<'impersonation'>; } + /** - * Set ImpersonateUserPhone - * - * Impersonate a user by phone on an already user-authenticated request. Requires the current request to be authenticated as a user with impersonator capability; X-Appwrite-Key alone is not sufficient. Impersonator users are intentionally granted users.read so they can discover a target before impersonation begins. Internal audit logs still attribute actions to the original impersonator and record the impersonated target only in internal audit payload data. - * - * @param value string - * - * @return {this} + * @deprecated Use a static client factory or factory params object instead. */ - setImpersonateUserPhone(value: string): this { + setImpersonateUserPhone(value: string): ClientRuntime<'impersonation'> { this.headers['X-Appwrite-Impersonate-User-Phone'] = value; this.config.impersonateuserphone = value; - return this; + return this as unknown as ClientRuntime<'impersonation'>; } + /** + * @deprecated Use a static client factory or factory params object instead. + */ + setKey(value: string): ClientRuntime<'apiKey'> { + this.headers['X-Appwrite-Key'] = value; + this.config.key = value; + return this as unknown as ClientRuntime<'apiKey'>; + } + + /** + * @deprecated Use a static client factory or factory params object instead. + */ + setForwardedUserAgent(value: string): this { + this.headers['X-Forwarded-User-Agent'] = value; + this.config.forwardeduseragent = value; + return this as unknown as this; + } + + private realtime: Realtime = { socket: undefined, timeout: undefined, @@ -580,9 +734,13 @@ class Client { lastMessage: undefined, connect: () => { clearTimeout(this.realtime.timeout); - this.realtime.timeout = window?.setTimeout(() => { - this.realtime.createSocket(); - }, 50); + this.realtime.timeout = typeof window !== 'undefined' + ? window.setTimeout(() => { + this.realtime.createSocket(); + }, 50) + : setTimeout(() => { + this.realtime.createSocket(); + }, 50) as unknown as TimeoutHandle; }, getTimeout: () => { switch (true) { @@ -598,14 +756,20 @@ class Client { }, createHeartbeat: () => { if (this.realtime.heartbeat) { - clearTimeout(this.realtime.heartbeat); + clearInterval(this.realtime.heartbeat as any); } - this.realtime.heartbeat = window?.setInterval(() => { - this.realtime.socket?.send(JSONbig.stringify({ - type: 'ping' - })); - }, 20_000); + this.realtime.heartbeat = typeof window !== 'undefined' + ? window.setInterval(() => { + this.realtime.socket?.send(JSONbig.stringify({ + type: 'ping' + })); + }, 20_000) + : setInterval(() => { + this.realtime.socket?.send(JSONbig.stringify({ + type: 'ping' + })); + }, 20_000) as unknown as TimeoutHandle; }, createSocket: () => { if (this.realtime.subscriptions.size < 1) { @@ -691,8 +855,14 @@ class Client { let session = this.config.session; if (!session) { - const cookie = JSONbig.parse(window.localStorage.getItem('cookieFallback') ?? '{}'); - session = cookie?.[`a_session_${this.config.project}`]; + try { + if (typeof window !== 'undefined' && window.localStorage) { + const cookie = JSONbig.parse(window.localStorage.getItem('cookieFallback') ?? '{}'); + session = cookie?.[`a_session_${this.config.project}`]; + } + } catch (error) { + console.error('Failed to parse cookie fallback:', error); + } } if (session && !messageData?.user) { this.realtime.socket?.send(JSONbig.stringify(<RealtimeRequest>{ @@ -857,7 +1027,7 @@ class Client { headers = Object.assign({}, this.headers, headers); - if (typeof window !== 'undefined' && window.localStorage) { + if (this.sdkPlatform === 'client' && typeof window !== 'undefined' && window.localStorage) { const cookieFallback = window.localStorage.getItem('cookieFallback'); if (cookieFallback) { headers['X-Fallback-Cookies'] = cookieFallback; @@ -869,12 +1039,12 @@ class Client { headers, }; - if (headers['X-Appwrite-Dev-Key'] === undefined) { + if (this.sdkPlatform === 'client' && headers['X-Appwrite-Dev-Key'] === undefined) { options.credentials = 'include'; } if (method === 'GET') { - for (const [key, value] of Object.entries(Client.flatten(params))) { + for (const [key, value] of Object.entries(ClientRuntime.flatten(params))) { url.searchParams.append(key, value); } } else { @@ -884,6 +1054,10 @@ class Client { break; case 'multipart/form-data': + if (typeof FormData === 'undefined' || typeof File === 'undefined') { + throw new AppwriteException('Multipart requests require File and FormData globals'); + } + const formData = new FormData(); for (const [key, value] of Object.entries(params)) { @@ -908,13 +1082,17 @@ class Client { } async chunkedUpload(method: string, url: URL, headers: Headers = {}, originalPayload: Payload = {}, onProgress: (progress: UploadProgress) => void) { + if (typeof File === 'undefined' || typeof FormData === 'undefined') { + throw new AppwriteException('Chunked uploads require File and FormData globals'); + } + const [fileParam, file] = Object.entries(originalPayload).find(([_, value]) => value instanceof File) ?? []; if (!file || !fileParam) { throw new Error('File not found in payload'); } - if (file.size <= Client.CHUNK_SIZE) { + if (file.size <= ClientRuntime.CHUNK_SIZE) { return await this.call(method, url, headers, originalPayload); } @@ -922,26 +1100,27 @@ class Client { let response = null; while (start < file.size) { - let end = start + Client.CHUNK_SIZE; // Prepare end for the next chunk + let end = start + ClientRuntime.CHUNK_SIZE; // Prepare end for the next chunk if (end >= file.size) { end = file.size; // Adjust for the last chunk to include the last byte } - headers['content-range'] = `bytes ${start}-${end-1}/${file.size}`; + const chunkHeaders = { ...headers }; + chunkHeaders['content-range'] = `bytes ${start}-${end-1}/${file.size}`; const chunk = file.slice(start, end); let payload = { ...originalPayload }; payload[fileParam] = new File([chunk], file.name); - response = await this.call(method, url, headers, payload); + response = await this.call(method, url, chunkHeaders, payload); if (onProgress && typeof onProgress === 'function') { onProgress({ $id: response.$id, progress: Math.round((end / file.size) * 100), sizeUploaded: end, - chunksTotal: Math.ceil(file.size / Client.CHUNK_SIZE), - chunksUploaded: Math.ceil(end / Client.CHUNK_SIZE) + chunksTotal: Math.ceil(file.size / ClientRuntime.CHUNK_SIZE), + chunksUploaded: Math.ceil(end / ClientRuntime.CHUNK_SIZE) }); } @@ -967,9 +1146,9 @@ class Client { const response = await fetch(uri, options); // type opaque: No-CORS, different-origin response (CORS-issue) - if (response.type === 'opaque') { + if (this.sdkPlatform === 'client' && typeof window !== 'undefined' && response.type === 'opaque') { throw new AppwriteException( - `Invalid Origin. Register your new client (${window.location.host}) as a new Web platform on your project console dashboard`, + `Invalid Origin. Register your new client (${typeof window !== 'undefined' ? window.location.host : 'unknown'}) as a new Web platform on your project console dashboard`, 403, "forbidden", "" @@ -1003,7 +1182,7 @@ class Client { const cookieFallback = response.headers.get('X-Fallback-Cookies'); - if (typeof window !== 'undefined' && window.localStorage && cookieFallback) { + if (this.sdkPlatform === 'client' && typeof window !== 'undefined' && window.localStorage && cookieFallback) { window.console.warn('Appwrite is using localStorage for session management. Increase your security by adding a custom domain as your API endpoint.'); window.localStorage.setItem('cookieFallback', cookieFallback); } @@ -1021,7 +1200,7 @@ class Client { for (const [key, value] of Object.entries(data)) { let finalKey = prefix ? prefix + '[' + key +']' : key; if (Array.isArray(value)) { - output = { ...output, ...Client.flatten(value, finalKey) }; + output = { ...output, ...ClientRuntime.flatten(value, finalKey) }; } else { output[finalKey] = value; } @@ -1031,8 +1210,9 @@ class Client { } } +const Client = ClientRuntime as unknown as ClientConstructor; + export { Client, AppwriteException }; +export type { Models, SDKPlatform, ClientAuth, ServerAuth, Payload, RealtimeResponseEvent, UploadProgress }; export { Query } from './query'; -export type { Models, Payload, UploadProgress }; -export type { RealtimeResponseEvent }; export type { QueryTypes, QueryTypesList } from './query'; diff --git a/src/enums/adapter.ts b/src/enums/adapter.ts new file mode 100644 index 00000000..a3b1ae0c --- /dev/null +++ b/src/enums/adapter.ts @@ -0,0 +1,4 @@ +export enum Adapter { + Static = 'static', + Ssr = 'ssr', +} \ No newline at end of file diff --git a/src/enums/attribute-status.ts b/src/enums/attribute-status.ts new file mode 100644 index 00000000..ade1d36a --- /dev/null +++ b/src/enums/attribute-status.ts @@ -0,0 +1,7 @@ +export enum AttributeStatus { + Available = 'available', + Processing = 'processing', + Deleting = 'deleting', + Stuck = 'stuck', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/enums/backup-services.ts b/src/enums/backup-services.ts new file mode 100644 index 00000000..bd0582ce --- /dev/null +++ b/src/enums/backup-services.ts @@ -0,0 +1,8 @@ +export enum BackupServices { + Databases = 'databases', + Tablesdb = 'tablesdb', + Documentsdb = 'documentsdb', + Vectorsdb = 'vectorsdb', + Functions = 'functions', + Storage = 'storage', +} \ No newline at end of file diff --git a/src/enums/build-runtime.ts b/src/enums/build-runtime.ts new file mode 100644 index 00000000..1466d635 --- /dev/null +++ b/src/enums/build-runtime.ts @@ -0,0 +1,91 @@ +export enum BuildRuntime { + Node145 = 'node-14.5', + Node160 = 'node-16.0', + Node180 = 'node-18.0', + Node190 = 'node-19.0', + Node200 = 'node-20.0', + Node210 = 'node-21.0', + Node22 = 'node-22', + Node23 = 'node-23', + Node24 = 'node-24', + Node25 = 'node-25', + Php80 = 'php-8.0', + Php81 = 'php-8.1', + Php82 = 'php-8.2', + Php83 = 'php-8.3', + Php84 = 'php-8.4', + Ruby30 = 'ruby-3.0', + Ruby31 = 'ruby-3.1', + Ruby32 = 'ruby-3.2', + Ruby33 = 'ruby-3.3', + Ruby34 = 'ruby-3.4', + Ruby40 = 'ruby-4.0', + Python38 = 'python-3.8', + Python39 = 'python-3.9', + Python310 = 'python-3.10', + Python311 = 'python-3.11', + Python312 = 'python-3.12', + Python313 = 'python-3.13', + Python314 = 'python-3.14', + Pythonml311 = 'python-ml-3.11', + Pythonml312 = 'python-ml-3.12', + Pythonml313 = 'python-ml-3.13', + Deno140 = 'deno-1.40', + Deno146 = 'deno-1.46', + Deno20 = 'deno-2.0', + Deno25 = 'deno-2.5', + Deno26 = 'deno-2.6', + Dart215 = 'dart-2.15', + Dart216 = 'dart-2.16', + Dart217 = 'dart-2.17', + Dart218 = 'dart-2.18', + Dart219 = 'dart-2.19', + Dart30 = 'dart-3.0', + Dart31 = 'dart-3.1', + Dart33 = 'dart-3.3', + Dart35 = 'dart-3.5', + Dart38 = 'dart-3.8', + Dart39 = 'dart-3.9', + Dart310 = 'dart-3.10', + Dart311 = 'dart-3.11', + Dotnet60 = 'dotnet-6.0', + Dotnet70 = 'dotnet-7.0', + Dotnet80 = 'dotnet-8.0', + Dotnet10 = 'dotnet-10', + Java80 = 'java-8.0', + Java110 = 'java-11.0', + Java170 = 'java-17.0', + Java180 = 'java-18.0', + Java210 = 'java-21.0', + Java22 = 'java-22', + Java25 = 'java-25', + Swift55 = 'swift-5.5', + Swift58 = 'swift-5.8', + Swift59 = 'swift-5.9', + Swift510 = 'swift-5.10', + Swift62 = 'swift-6.2', + Kotlin16 = 'kotlin-1.6', + Kotlin18 = 'kotlin-1.8', + Kotlin19 = 'kotlin-1.9', + Kotlin20 = 'kotlin-2.0', + Kotlin23 = 'kotlin-2.3', + Cpp17 = 'cpp-17', + Cpp20 = 'cpp-20', + Bun10 = 'bun-1.0', + Bun11 = 'bun-1.1', + Bun12 = 'bun-1.2', + Bun13 = 'bun-1.3', + Go123 = 'go-1.23', + Go124 = 'go-1.24', + Go125 = 'go-1.25', + Go126 = 'go-1.26', + Rust183 = 'rust-1.83', + Static1 = 'static-1', + Flutter324 = 'flutter-3.24', + Flutter327 = 'flutter-3.27', + Flutter329 = 'flutter-3.29', + Flutter332 = 'flutter-3.32', + Flutter335 = 'flutter-3.35', + Flutter338 = 'flutter-3.38', + Flutter341 = 'flutter-3.41', +} \ No newline at end of file diff --git a/src/enums/column-status.ts b/src/enums/column-status.ts new file mode 100644 index 00000000..f53e8a66 --- /dev/null +++ b/src/enums/column-status.ts @@ -0,0 +1,7 @@ +export enum ColumnStatus { + Available = 'available', + Processing = 'processing', + Deleting = 'deleting', + Stuck = 'stuck', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/enums/compression.ts b/src/enums/compression.ts new file mode 100644 index 00000000..1bec0e78 --- /dev/null +++ b/src/enums/compression.ts @@ -0,0 +1,5 @@ +export enum Compression { + None = 'none', + Gzip = 'gzip', + Zstd = 'zstd', +} \ No newline at end of file diff --git a/src/enums/database-type.ts b/src/enums/database-type.ts new file mode 100644 index 00000000..8ccd9699 --- /dev/null +++ b/src/enums/database-type.ts @@ -0,0 +1,6 @@ +export enum DatabaseType { + Legacy = 'legacy', + Tablesdb = 'tablesdb', + Documentsdb = 'documentsdb', + Vectorsdb = 'vectorsdb', +} \ No newline at end of file diff --git a/src/enums/databases-index-type.ts b/src/enums/databases-index-type.ts new file mode 100644 index 00000000..85ccf867 --- /dev/null +++ b/src/enums/databases-index-type.ts @@ -0,0 +1,6 @@ +export enum DatabasesIndexType { + Key = 'key', + Fulltext = 'fulltext', + Unique = 'unique', + Spatial = 'spatial', +} \ No newline at end of file diff --git a/src/enums/deployment-download-type.ts b/src/enums/deployment-download-type.ts new file mode 100644 index 00000000..538709bc --- /dev/null +++ b/src/enums/deployment-download-type.ts @@ -0,0 +1,4 @@ +export enum DeploymentDownloadType { + Source = 'source', + Output = 'output', +} \ No newline at end of file diff --git a/src/enums/deployment-status.ts b/src/enums/deployment-status.ts new file mode 100644 index 00000000..7e8f4a1b --- /dev/null +++ b/src/enums/deployment-status.ts @@ -0,0 +1,8 @@ +export enum DeploymentStatus { + Waiting = 'waiting', + Processing = 'processing', + Building = 'building', + Ready = 'ready', + Canceled = 'canceled', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/enums/framework.ts b/src/enums/framework.ts new file mode 100644 index 00000000..7093da33 --- /dev/null +++ b/src/enums/framework.ts @@ -0,0 +1,17 @@ +export enum Framework { + Analog = 'analog', + Angular = 'angular', + Nextjs = 'nextjs', + React = 'react', + Nuxt = 'nuxt', + Vue = 'vue', + Sveltekit = 'sveltekit', + Astro = 'astro', + Tanstackstart = 'tanstack-start', + Remix = 'remix', + Lynx = 'lynx', + Flutter = 'flutter', + Reactnative = 'react-native', + Vite = 'vite', + Other = 'other', +} \ No newline at end of file diff --git a/src/enums/health-antivirus-status.ts b/src/enums/health-antivirus-status.ts new file mode 100644 index 00000000..d4da4c4f --- /dev/null +++ b/src/enums/health-antivirus-status.ts @@ -0,0 +1,5 @@ +export enum HealthAntivirusStatus { + Disabled = 'disabled', + Offline = 'offline', + Online = 'online', +} \ No newline at end of file diff --git a/src/enums/health-check-status.ts b/src/enums/health-check-status.ts new file mode 100644 index 00000000..9dbc6810 --- /dev/null +++ b/src/enums/health-check-status.ts @@ -0,0 +1,4 @@ +export enum HealthCheckStatus { + Pass = 'pass', + Fail = 'fail', +} \ No newline at end of file diff --git a/src/enums/index-status.ts b/src/enums/index-status.ts new file mode 100644 index 00000000..6ce90ac8 --- /dev/null +++ b/src/enums/index-status.ts @@ -0,0 +1,7 @@ +export enum IndexStatus { + Available = 'available', + Processing = 'processing', + Deleting = 'deleting', + Stuck = 'stuck', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/enums/message-priority.ts b/src/enums/message-priority.ts new file mode 100644 index 00000000..f3113a85 --- /dev/null +++ b/src/enums/message-priority.ts @@ -0,0 +1,4 @@ +export enum MessagePriority { + Normal = 'normal', + High = 'high', +} \ No newline at end of file diff --git a/src/enums/message-status.ts b/src/enums/message-status.ts new file mode 100644 index 00000000..08bd483b --- /dev/null +++ b/src/enums/message-status.ts @@ -0,0 +1,7 @@ +export enum MessageStatus { + Draft = 'draft', + Processing = 'processing', + Scheduled = 'scheduled', + Sent = 'sent', + Failed = 'failed', +} \ No newline at end of file diff --git a/src/enums/messaging-provider-type.ts b/src/enums/messaging-provider-type.ts new file mode 100644 index 00000000..18c9929b --- /dev/null +++ b/src/enums/messaging-provider-type.ts @@ -0,0 +1,5 @@ +export enum MessagingProviderType { + Email = 'email', + Sms = 'sms', + Push = 'push', +} \ No newline at end of file diff --git a/src/enums/name.ts b/src/enums/name.ts new file mode 100644 index 00000000..8cd297bc --- /dev/null +++ b/src/enums/name.ts @@ -0,0 +1,15 @@ +export enum Name { + V1database = 'v1-database', + V1deletes = 'v1-deletes', + V1audits = 'v1-audits', + V1mails = 'v1-mails', + V1functions = 'v1-functions', + V1statsresources = 'v1-stats-resources', + V1statsusage = 'v1-stats-usage', + V1webhooks = 'v1-webhooks', + V1certificates = 'v1-certificates', + V1builds = 'v1-builds', + V1screenshots = 'v1-screenshots', + V1messaging = 'v1-messaging', + V1migrations = 'v1-migrations', +} \ No newline at end of file diff --git a/src/enums/o-auth-2-google-prompt.ts b/src/enums/o-auth-2-google-prompt.ts new file mode 100644 index 00000000..f8e98e12 --- /dev/null +++ b/src/enums/o-auth-2-google-prompt.ts @@ -0,0 +1,5 @@ +export enum OAuth2GooglePrompt { + None = 'none', + Consent = 'consent', + SelectAccount = 'select_account', +} \ No newline at end of file diff --git a/src/enums/order-by.ts b/src/enums/order-by.ts new file mode 100644 index 00000000..62dffb98 --- /dev/null +++ b/src/enums/order-by.ts @@ -0,0 +1,4 @@ +export enum OrderBy { + Asc = 'asc', + Desc = 'desc', +} \ No newline at end of file diff --git a/src/enums/password-hash.ts b/src/enums/password-hash.ts new file mode 100644 index 00000000..76834af4 --- /dev/null +++ b/src/enums/password-hash.ts @@ -0,0 +1,13 @@ +export enum PasswordHash { + Sha1 = 'sha1', + Sha224 = 'sha224', + Sha256 = 'sha256', + Sha384 = 'sha384', + Sha512224 = 'sha512/224', + Sha512256 = 'sha512/256', + Sha512 = 'sha512', + Sha3224 = 'sha3-224', + Sha3256 = 'sha3-256', + Sha3384 = 'sha3-384', + Sha3512 = 'sha3-512', +} \ No newline at end of file diff --git a/src/enums/platform-type.ts b/src/enums/platform-type.ts new file mode 100644 index 00000000..bde1d30f --- /dev/null +++ b/src/enums/platform-type.ts @@ -0,0 +1,7 @@ +export enum PlatformType { + Windows = 'windows', + Apple = 'apple', + Android = 'android', + Linux = 'linux', + Web = 'web', +} \ No newline at end of file diff --git a/src/enums/project-auth-method-id.ts b/src/enums/project-auth-method-id.ts new file mode 100644 index 00000000..a05c217e --- /dev/null +++ b/src/enums/project-auth-method-id.ts @@ -0,0 +1,9 @@ +export enum ProjectAuthMethodId { + Emailpassword = 'email-password', + Magicurl = 'magic-url', + Emailotp = 'email-otp', + Anonymous = 'anonymous', + Invites = 'invites', + Jwt = 'jwt', + Phone = 'phone', +} \ No newline at end of file diff --git a/src/enums/project-email-template-id.ts b/src/enums/project-email-template-id.ts new file mode 100644 index 00000000..b5aba1a6 --- /dev/null +++ b/src/enums/project-email-template-id.ts @@ -0,0 +1,9 @@ +export enum ProjectEmailTemplateId { + Verification = 'verification', + MagicSession = 'magicSession', + Recovery = 'recovery', + Invitation = 'invitation', + MfaChallenge = 'mfaChallenge', + SessionAlert = 'sessionAlert', + OtpSession = 'otpSession', +} \ No newline at end of file diff --git a/src/enums/project-email-template-locale.ts b/src/enums/project-email-template-locale.ts new file mode 100644 index 00000000..b5bb7cf8 --- /dev/null +++ b/src/enums/project-email-template-locale.ts @@ -0,0 +1,133 @@ +export enum ProjectEmailTemplateLocale { + Af = 'af', + Arae = 'ar-ae', + Arbh = 'ar-bh', + Ardz = 'ar-dz', + Areg = 'ar-eg', + Ariq = 'ar-iq', + Arjo = 'ar-jo', + Arkw = 'ar-kw', + Arlb = 'ar-lb', + Arly = 'ar-ly', + Arma = 'ar-ma', + Arom = 'ar-om', + Arqa = 'ar-qa', + Arsa = 'ar-sa', + Arsy = 'ar-sy', + Artn = 'ar-tn', + Arye = 'ar-ye', + As = 'as', + Az = 'az', + Be = 'be', + Bg = 'bg', + Bh = 'bh', + Bn = 'bn', + Bs = 'bs', + Ca = 'ca', + Cs = 'cs', + Cy = 'cy', + Da = 'da', + De = 'de', + Deat = 'de-at', + Dech = 'de-ch', + Deli = 'de-li', + Delu = 'de-lu', + El = 'el', + En = 'en', + Enau = 'en-au', + Enbz = 'en-bz', + Enca = 'en-ca', + Engb = 'en-gb', + Enie = 'en-ie', + Enjm = 'en-jm', + Ennz = 'en-nz', + Entt = 'en-tt', + Enus = 'en-us', + Enza = 'en-za', + Eo = 'eo', + Es = 'es', + Esar = 'es-ar', + Esbo = 'es-bo', + Escl = 'es-cl', + Esco = 'es-co', + Escr = 'es-cr', + Esdo = 'es-do', + Esec = 'es-ec', + Esgt = 'es-gt', + Eshn = 'es-hn', + Esmx = 'es-mx', + Esni = 'es-ni', + Espa = 'es-pa', + Espe = 'es-pe', + Espr = 'es-pr', + Espy = 'es-py', + Essv = 'es-sv', + Esuy = 'es-uy', + Esve = 'es-ve', + Et = 'et', + Eu = 'eu', + Fa = 'fa', + Fi = 'fi', + Fo = 'fo', + Fr = 'fr', + Frbe = 'fr-be', + Frca = 'fr-ca', + Frch = 'fr-ch', + Frlu = 'fr-lu', + Ga = 'ga', + Gd = 'gd', + He = 'he', + Hi = 'hi', + Hr = 'hr', + Hu = 'hu', + Id = 'id', + Is = 'is', + It = 'it', + Itch = 'it-ch', + Ja = 'ja', + Ji = 'ji', + Ko = 'ko', + Ku = 'ku', + Lt = 'lt', + Lv = 'lv', + Mk = 'mk', + Ml = 'ml', + Ms = 'ms', + Mt = 'mt', + Nb = 'nb', + Ne = 'ne', + Nl = 'nl', + Nlbe = 'nl-be', + Nn = 'nn', + No = 'no', + Pa = 'pa', + Pl = 'pl', + Pt = 'pt', + Ptbr = 'pt-br', + Rm = 'rm', + Ro = 'ro', + Romd = 'ro-md', + Ru = 'ru', + Rumd = 'ru-md', + Sb = 'sb', + Sk = 'sk', + Sl = 'sl', + Sq = 'sq', + Sr = 'sr', + Sv = 'sv', + Svfi = 'sv-fi', + Th = 'th', + Tn = 'tn', + Tr = 'tr', + Ts = 'ts', + Ua = 'ua', + Ur = 'ur', + Ve = 've', + Vi = 'vi', + Xh = 'xh', + Zhcn = 'zh-cn', + Zhhk = 'zh-hk', + Zhsg = 'zh-sg', + Zhtw = 'zh-tw', + Zu = 'zu', +} \ No newline at end of file diff --git a/src/enums/project-key-scopes.ts b/src/enums/project-key-scopes.ts new file mode 100644 index 00000000..fe019965 --- /dev/null +++ b/src/enums/project-key-scopes.ts @@ -0,0 +1,96 @@ +export enum ProjectKeyScopes { + ProjectRead = 'project.read', + ProjectWrite = 'project.write', + KeysRead = 'keys.read', + KeysWrite = 'keys.write', + PlatformsRead = 'platforms.read', + PlatformsWrite = 'platforms.write', + MocksRead = 'mocks.read', + MocksWrite = 'mocks.write', + PoliciesRead = 'policies.read', + PoliciesWrite = 'policies.write', + ProjectPoliciesRead = 'project.policies.read', + ProjectPoliciesWrite = 'project.policies.write', + TemplatesRead = 'templates.read', + TemplatesWrite = 'templates.write', + Oauth2Read = 'oauth2.read', + Oauth2Write = 'oauth2.write', + UsersRead = 'users.read', + UsersWrite = 'users.write', + SessionsRead = 'sessions.read', + SessionsWrite = 'sessions.write', + TeamsRead = 'teams.read', + TeamsWrite = 'teams.write', + DatabasesRead = 'databases.read', + DatabasesWrite = 'databases.write', + TablesRead = 'tables.read', + TablesWrite = 'tables.write', + ColumnsRead = 'columns.read', + ColumnsWrite = 'columns.write', + IndexesRead = 'indexes.read', + IndexesWrite = 'indexes.write', + RowsRead = 'rows.read', + RowsWrite = 'rows.write', + CollectionsRead = 'collections.read', + CollectionsWrite = 'collections.write', + AttributesRead = 'attributes.read', + AttributesWrite = 'attributes.write', + DocumentsRead = 'documents.read', + DocumentsWrite = 'documents.write', + BucketsRead = 'buckets.read', + BucketsWrite = 'buckets.write', + FilesRead = 'files.read', + FilesWrite = 'files.write', + TokensRead = 'tokens.read', + TokensWrite = 'tokens.write', + FunctionsRead = 'functions.read', + FunctionsWrite = 'functions.write', + ExecutionsRead = 'executions.read', + ExecutionsWrite = 'executions.write', + ExecutionRead = 'execution.read', + ExecutionWrite = 'execution.write', + SitesRead = 'sites.read', + SitesWrite = 'sites.write', + LogRead = 'log.read', + LogWrite = 'log.write', + ProvidersRead = 'providers.read', + ProvidersWrite = 'providers.write', + TopicsRead = 'topics.read', + TopicsWrite = 'topics.write', + SubscribersRead = 'subscribers.read', + SubscribersWrite = 'subscribers.write', + TargetsRead = 'targets.read', + TargetsWrite = 'targets.write', + MessagesRead = 'messages.read', + MessagesWrite = 'messages.write', + RulesRead = 'rules.read', + RulesWrite = 'rules.write', + WebhooksRead = 'webhooks.read', + WebhooksWrite = 'webhooks.write', + LocaleRead = 'locale.read', + AvatarsRead = 'avatars.read', + HealthRead = 'health.read', + AssistantRead = 'assistant.read', + MigrationsRead = 'migrations.read', + MigrationsWrite = 'migrations.write', + SchedulesRead = 'schedules.read', + SchedulesWrite = 'schedules.write', + VcsRead = 'vcs.read', + VcsWrite = 'vcs.write', + InsightsRead = 'insights.read', + InsightsWrite = 'insights.write', + ReportsRead = 'reports.read', + ReportsWrite = 'reports.write', + PresencesRead = 'presences.read', + PresencesWrite = 'presences.write', + BackupsPoliciesRead = 'backups.policies.read', + BackupsPoliciesWrite = 'backups.policies.write', + ArchivesRead = 'archives.read', + ArchivesWrite = 'archives.write', + RestorationsRead = 'restorations.read', + RestorationsWrite = 'restorations.write', + DomainsRead = 'domains.read', + DomainsWrite = 'domains.write', + EventsRead = 'events.read', + UsageRead = 'usage.read', +} \ No newline at end of file diff --git a/src/enums/project-o-auth-2-google-prompt.ts b/src/enums/project-o-auth-2-google-prompt.ts new file mode 100644 index 00000000..75db98ec --- /dev/null +++ b/src/enums/project-o-auth-2-google-prompt.ts @@ -0,0 +1,5 @@ +export enum ProjectOAuth2GooglePrompt { + None = 'none', + Consent = 'consent', + SelectAccount = 'select_account', +} \ No newline at end of file diff --git a/src/enums/project-o-auth-provider-id.ts b/src/enums/project-o-auth-provider-id.ts new file mode 100644 index 00000000..e35d6ef0 --- /dev/null +++ b/src/enums/project-o-auth-provider-id.ts @@ -0,0 +1,47 @@ +export enum ProjectOAuthProviderId { + Amazon = 'amazon', + Apple = 'apple', + Auth0 = 'auth0', + Authentik = 'authentik', + Autodesk = 'autodesk', + Bitbucket = 'bitbucket', + Bitly = 'bitly', + Box = 'box', + Dailymotion = 'dailymotion', + Discord = 'discord', + Disqus = 'disqus', + Dropbox = 'dropbox', + Etsy = 'etsy', + Facebook = 'facebook', + Figma = 'figma', + Fusionauth = 'fusionauth', + Github = 'github', + Gitlab = 'gitlab', + Google = 'google', + Keycloak = 'keycloak', + Kick = 'kick', + Linkedin = 'linkedin', + Microsoft = 'microsoft', + Notion = 'notion', + Oidc = 'oidc', + Okta = 'okta', + Paypal = 'paypal', + PaypalSandbox = 'paypalSandbox', + Podio = 'podio', + Salesforce = 'salesforce', + Slack = 'slack', + Spotify = 'spotify', + Stripe = 'stripe', + Tradeshift = 'tradeshift', + TradeshiftBox = 'tradeshiftBox', + Twitch = 'twitch', + Wordpress = 'wordpress', + X = 'x', + Yahoo = 'yahoo', + Yammer = 'yammer', + Yandex = 'yandex', + Zoho = 'zoho', + Zoom = 'zoom', + GithubImagine = 'githubImagine', + GoogleImagine = 'googleImagine', +} \ No newline at end of file diff --git a/src/enums/project-policy-id.ts b/src/enums/project-policy-id.ts new file mode 100644 index 00000000..2031ce9b --- /dev/null +++ b/src/enums/project-policy-id.ts @@ -0,0 +1,11 @@ +export enum ProjectPolicyId { + Passworddictionary = 'password-dictionary', + Passwordhistory = 'password-history', + Passwordpersonaldata = 'password-personal-data', + Sessionalert = 'session-alert', + Sessionduration = 'session-duration', + Sessioninvalidation = 'session-invalidation', + Sessionlimit = 'session-limit', + Userlimit = 'user-limit', + Membershipprivacy = 'membership-privacy', +} \ No newline at end of file diff --git a/src/enums/project-protocol-id.ts b/src/enums/project-protocol-id.ts new file mode 100644 index 00000000..10a89c21 --- /dev/null +++ b/src/enums/project-protocol-id.ts @@ -0,0 +1,5 @@ +export enum ProjectProtocolId { + Rest = 'rest', + Graphql = 'graphql', + Websocket = 'websocket', +} \ No newline at end of file diff --git a/src/enums/project-service-id.ts b/src/enums/project-service-id.ts new file mode 100644 index 00000000..01f844a8 --- /dev/null +++ b/src/enums/project-service-id.ts @@ -0,0 +1,20 @@ +export enum ProjectServiceId { + Account = 'account', + Avatars = 'avatars', + Databases = 'databases', + Tablesdb = 'tablesdb', + Locale = 'locale', + Health = 'health', + Project = 'project', + Storage = 'storage', + Teams = 'teams', + Users = 'users', + Vcs = 'vcs', + Sites = 'sites', + Functions = 'functions', + Proxy = 'proxy', + Graphql = 'graphql', + Migrations = 'migrations', + Messaging = 'messaging', + Advisor = 'advisor', +} \ No newline at end of file diff --git a/src/enums/project-smtp-secure.ts b/src/enums/project-smtp-secure.ts new file mode 100644 index 00000000..d3d37687 --- /dev/null +++ b/src/enums/project-smtp-secure.ts @@ -0,0 +1,4 @@ +export enum ProjectSMTPSecure { + Tls = 'tls', + Ssl = 'ssl', +} \ No newline at end of file diff --git a/src/enums/proxy-resource-type.ts b/src/enums/proxy-resource-type.ts new file mode 100644 index 00000000..e04c8046 --- /dev/null +++ b/src/enums/proxy-resource-type.ts @@ -0,0 +1,4 @@ +export enum ProxyResourceType { + Site = 'site', + Function = 'function', +} \ No newline at end of file diff --git a/src/enums/proxy-rule-deployment-resource-type.ts b/src/enums/proxy-rule-deployment-resource-type.ts new file mode 100644 index 00000000..89236c74 --- /dev/null +++ b/src/enums/proxy-rule-deployment-resource-type.ts @@ -0,0 +1,4 @@ +export enum ProxyRuleDeploymentResourceType { + Function = 'function', + Site = 'site', +} \ No newline at end of file diff --git a/src/enums/proxy-rule-status.ts b/src/enums/proxy-rule-status.ts new file mode 100644 index 00000000..67b8e4cb --- /dev/null +++ b/src/enums/proxy-rule-status.ts @@ -0,0 +1,5 @@ +export enum ProxyRuleStatus { + Unverified = 'unverified', + Verifying = 'verifying', + Verified = 'verified', +} \ No newline at end of file diff --git a/src/enums/relation-mutate.ts b/src/enums/relation-mutate.ts new file mode 100644 index 00000000..722a7572 --- /dev/null +++ b/src/enums/relation-mutate.ts @@ -0,0 +1,5 @@ +export enum RelationMutate { + Cascade = 'cascade', + Restrict = 'restrict', + SetNull = 'setNull', +} \ No newline at end of file diff --git a/src/enums/relationship-type.ts b/src/enums/relationship-type.ts new file mode 100644 index 00000000..532015af --- /dev/null +++ b/src/enums/relationship-type.ts @@ -0,0 +1,6 @@ +export enum RelationshipType { + OneToOne = 'oneToOne', + ManyToOne = 'manyToOne', + ManyToMany = 'manyToMany', + OneToMany = 'oneToMany', +} \ No newline at end of file diff --git a/src/enums/runtime.ts b/src/enums/runtime.ts new file mode 100644 index 00000000..f4d20688 --- /dev/null +++ b/src/enums/runtime.ts @@ -0,0 +1,91 @@ +export enum Runtime { + Node145 = 'node-14.5', + Node160 = 'node-16.0', + Node180 = 'node-18.0', + Node190 = 'node-19.0', + Node200 = 'node-20.0', + Node210 = 'node-21.0', + Node22 = 'node-22', + Node23 = 'node-23', + Node24 = 'node-24', + Node25 = 'node-25', + Php80 = 'php-8.0', + Php81 = 'php-8.1', + Php82 = 'php-8.2', + Php83 = 'php-8.3', + Php84 = 'php-8.4', + Ruby30 = 'ruby-3.0', + Ruby31 = 'ruby-3.1', + Ruby32 = 'ruby-3.2', + Ruby33 = 'ruby-3.3', + Ruby34 = 'ruby-3.4', + Ruby40 = 'ruby-4.0', + Python38 = 'python-3.8', + Python39 = 'python-3.9', + Python310 = 'python-3.10', + Python311 = 'python-3.11', + Python312 = 'python-3.12', + Python313 = 'python-3.13', + Python314 = 'python-3.14', + Pythonml311 = 'python-ml-3.11', + Pythonml312 = 'python-ml-3.12', + Pythonml313 = 'python-ml-3.13', + Deno140 = 'deno-1.40', + Deno146 = 'deno-1.46', + Deno20 = 'deno-2.0', + Deno25 = 'deno-2.5', + Deno26 = 'deno-2.6', + Dart215 = 'dart-2.15', + Dart216 = 'dart-2.16', + Dart217 = 'dart-2.17', + Dart218 = 'dart-2.18', + Dart219 = 'dart-2.19', + Dart30 = 'dart-3.0', + Dart31 = 'dart-3.1', + Dart33 = 'dart-3.3', + Dart35 = 'dart-3.5', + Dart38 = 'dart-3.8', + Dart39 = 'dart-3.9', + Dart310 = 'dart-3.10', + Dart311 = 'dart-3.11', + Dotnet60 = 'dotnet-6.0', + Dotnet70 = 'dotnet-7.0', + Dotnet80 = 'dotnet-8.0', + Dotnet10 = 'dotnet-10', + Java80 = 'java-8.0', + Java110 = 'java-11.0', + Java170 = 'java-17.0', + Java180 = 'java-18.0', + Java210 = 'java-21.0', + Java22 = 'java-22', + Java25 = 'java-25', + Swift55 = 'swift-5.5', + Swift58 = 'swift-5.8', + Swift59 = 'swift-5.9', + Swift510 = 'swift-5.10', + Swift62 = 'swift-6.2', + Kotlin16 = 'kotlin-1.6', + Kotlin18 = 'kotlin-1.8', + Kotlin19 = 'kotlin-1.9', + Kotlin20 = 'kotlin-2.0', + Kotlin23 = 'kotlin-2.3', + Cpp17 = 'cpp-17', + Cpp20 = 'cpp-20', + Bun10 = 'bun-1.0', + Bun11 = 'bun-1.1', + Bun12 = 'bun-1.2', + Bun13 = 'bun-1.3', + Go123 = 'go-1.23', + Go124 = 'go-1.24', + Go125 = 'go-1.25', + Go126 = 'go-1.26', + Rust183 = 'rust-1.83', + Static1 = 'static-1', + Flutter324 = 'flutter-3.24', + Flutter327 = 'flutter-3.27', + Flutter329 = 'flutter-3.29', + Flutter332 = 'flutter-3.32', + Flutter335 = 'flutter-3.35', + Flutter338 = 'flutter-3.38', + Flutter341 = 'flutter-3.41', +} \ No newline at end of file diff --git a/src/enums/scopes.ts b/src/enums/scopes.ts new file mode 100644 index 00000000..54e9cb31 --- /dev/null +++ b/src/enums/scopes.ts @@ -0,0 +1,96 @@ +export enum Scopes { + ProjectRead = 'project.read', + ProjectWrite = 'project.write', + KeysRead = 'keys.read', + KeysWrite = 'keys.write', + PlatformsRead = 'platforms.read', + PlatformsWrite = 'platforms.write', + MocksRead = 'mocks.read', + MocksWrite = 'mocks.write', + PoliciesRead = 'policies.read', + PoliciesWrite = 'policies.write', + ProjectPoliciesRead = 'project.policies.read', + ProjectPoliciesWrite = 'project.policies.write', + TemplatesRead = 'templates.read', + TemplatesWrite = 'templates.write', + Oauth2Read = 'oauth2.read', + Oauth2Write = 'oauth2.write', + UsersRead = 'users.read', + UsersWrite = 'users.write', + SessionsRead = 'sessions.read', + SessionsWrite = 'sessions.write', + TeamsRead = 'teams.read', + TeamsWrite = 'teams.write', + DatabasesRead = 'databases.read', + DatabasesWrite = 'databases.write', + TablesRead = 'tables.read', + TablesWrite = 'tables.write', + ColumnsRead = 'columns.read', + ColumnsWrite = 'columns.write', + IndexesRead = 'indexes.read', + IndexesWrite = 'indexes.write', + RowsRead = 'rows.read', + RowsWrite = 'rows.write', + CollectionsRead = 'collections.read', + CollectionsWrite = 'collections.write', + AttributesRead = 'attributes.read', + AttributesWrite = 'attributes.write', + DocumentsRead = 'documents.read', + DocumentsWrite = 'documents.write', + BucketsRead = 'buckets.read', + BucketsWrite = 'buckets.write', + FilesRead = 'files.read', + FilesWrite = 'files.write', + TokensRead = 'tokens.read', + TokensWrite = 'tokens.write', + FunctionsRead = 'functions.read', + FunctionsWrite = 'functions.write', + ExecutionsRead = 'executions.read', + ExecutionsWrite = 'executions.write', + ExecutionRead = 'execution.read', + ExecutionWrite = 'execution.write', + SitesRead = 'sites.read', + SitesWrite = 'sites.write', + LogRead = 'log.read', + LogWrite = 'log.write', + ProvidersRead = 'providers.read', + ProvidersWrite = 'providers.write', + TopicsRead = 'topics.read', + TopicsWrite = 'topics.write', + SubscribersRead = 'subscribers.read', + SubscribersWrite = 'subscribers.write', + TargetsRead = 'targets.read', + TargetsWrite = 'targets.write', + MessagesRead = 'messages.read', + MessagesWrite = 'messages.write', + RulesRead = 'rules.read', + RulesWrite = 'rules.write', + WebhooksRead = 'webhooks.read', + WebhooksWrite = 'webhooks.write', + LocaleRead = 'locale.read', + AvatarsRead = 'avatars.read', + HealthRead = 'health.read', + AssistantRead = 'assistant.read', + MigrationsRead = 'migrations.read', + MigrationsWrite = 'migrations.write', + SchedulesRead = 'schedules.read', + SchedulesWrite = 'schedules.write', + VcsRead = 'vcs.read', + VcsWrite = 'vcs.write', + InsightsRead = 'insights.read', + InsightsWrite = 'insights.write', + ReportsRead = 'reports.read', + ReportsWrite = 'reports.write', + PresencesRead = 'presences.read', + PresencesWrite = 'presences.write', + BackupsPoliciesRead = 'backups.policies.read', + BackupsPoliciesWrite = 'backups.policies.write', + ArchivesRead = 'archives.read', + ArchivesWrite = 'archives.write', + RestorationsRead = 'restorations.read', + RestorationsWrite = 'restorations.write', + DomainsRead = 'domains.read', + DomainsWrite = 'domains.write', + EventsRead = 'events.read', + UsageRead = 'usage.read', +} \ No newline at end of file diff --git a/src/enums/smtp-encryption.ts b/src/enums/smtp-encryption.ts new file mode 100644 index 00000000..876177b6 --- /dev/null +++ b/src/enums/smtp-encryption.ts @@ -0,0 +1,5 @@ +export enum SmtpEncryption { + None = 'none', + Ssl = 'ssl', + Tls = 'tls', +} \ No newline at end of file diff --git a/src/enums/status-code.ts b/src/enums/status-code.ts new file mode 100644 index 00000000..1f3adf8b --- /dev/null +++ b/src/enums/status-code.ts @@ -0,0 +1,6 @@ +export enum StatusCode { + MovedPermanently301 = '301', + Found302 = '302', + TemporaryRedirect307 = '307', + PermanentRedirect308 = '308', +} \ No newline at end of file diff --git a/src/enums/tables-db-index-type.ts b/src/enums/tables-db-index-type.ts new file mode 100644 index 00000000..a199cd9c --- /dev/null +++ b/src/enums/tables-db-index-type.ts @@ -0,0 +1,6 @@ +export enum TablesDBIndexType { + Key = 'key', + Fulltext = 'fulltext', + Unique = 'unique', + Spatial = 'spatial', +} \ No newline at end of file diff --git a/src/enums/template-reference-type.ts b/src/enums/template-reference-type.ts new file mode 100644 index 00000000..bd72cfb5 --- /dev/null +++ b/src/enums/template-reference-type.ts @@ -0,0 +1,5 @@ +export enum TemplateReferenceType { + Commit = 'commit', + Branch = 'branch', + Tag = 'tag', +} \ No newline at end of file diff --git a/src/enums/vcs-reference-type.ts b/src/enums/vcs-reference-type.ts new file mode 100644 index 00000000..cb5270f5 --- /dev/null +++ b/src/enums/vcs-reference-type.ts @@ -0,0 +1,5 @@ +export enum VCSReferenceType { + Branch = 'branch', + Commit = 'commit', + Tag = 'tag', +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 89b0a515..caffb1df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,18 +7,29 @@ */ export { Client, Query, AppwriteException } from './client'; export { Account } from './services/account'; +export { Activities } from './services/activities'; export { Avatars } from './services/avatars'; +export { Backups } from './services/backups'; export { Databases } from './services/databases'; export { Functions } from './services/functions'; export { Graphql } from './services/graphql'; +export { Health } from './services/health'; export { Locale } from './services/locale'; export { Messaging } from './services/messaging'; export { Presences } from './services/presences'; +export { Project } from './services/project'; +export { Proxy } from './services/proxy'; +export { Advisor } from './services/advisor'; +export { Sites } from './services/sites'; export { Storage } from './services/storage'; export { TablesDB } from './services/tables-db'; export { Teams } from './services/teams'; +export { Tokens } from './services/tokens'; +export { Usage } from './services/usage'; +export { Users } from './services/users'; +export { Webhooks } from './services/webhooks'; export { Realtime } from './services/realtime'; -export type { Models, Payload, RealtimeResponseEvent, UploadProgress } from './client'; +export type { Models, Payload, RealtimeResponseEvent, UploadProgress, SDKPlatform, ClientAuth, ServerAuth } from './client'; export type { RealtimeSubscription } from './services/realtime'; export type { QueryTypes, QueryTypesList } from './query'; export { Permission } from './permission'; @@ -36,7 +47,51 @@ export { Theme } from './enums/theme'; export { Timezone } from './enums/timezone'; export { BrowserPermission } from './enums/browser-permission'; export { ImageFormat } from './enums/image-format'; +export { BackupServices } from './enums/backup-services'; +export { RelationshipType } from './enums/relationship-type'; +export { RelationMutate } from './enums/relation-mutate'; +export { DatabasesIndexType } from './enums/databases-index-type'; +export { OrderBy } from './enums/order-by'; +export { Runtime } from './enums/runtime'; +export { Scopes } from './enums/scopes'; +export { TemplateReferenceType } from './enums/template-reference-type'; +export { VCSReferenceType } from './enums/vcs-reference-type'; +export { DeploymentDownloadType } from './enums/deployment-download-type'; export { ExecutionMethod } from './enums/execution-method'; +export { Name } from './enums/name'; +export { MessagePriority } from './enums/message-priority'; +export { SmtpEncryption } from './enums/smtp-encryption'; +export { ProjectAuthMethodId } from './enums/project-auth-method-id'; +export { ProjectKeyScopes } from './enums/project-key-scopes'; +export { ProjectOAuth2GooglePrompt } from './enums/project-o-auth-2-google-prompt'; +export { ProjectOAuthProviderId } from './enums/project-o-auth-provider-id'; +export { ProjectPolicyId } from './enums/project-policy-id'; +export { ProjectProtocolId } from './enums/project-protocol-id'; +export { ProjectServiceId } from './enums/project-service-id'; +export { ProjectSMTPSecure } from './enums/project-smtp-secure'; +export { ProjectEmailTemplateId } from './enums/project-email-template-id'; +export { ProjectEmailTemplateLocale } from './enums/project-email-template-locale'; +export { StatusCode } from './enums/status-code'; +export { ProxyResourceType } from './enums/proxy-resource-type'; +export { Framework } from './enums/framework'; +export { BuildRuntime } from './enums/build-runtime'; +export { Adapter } from './enums/adapter'; +export { Compression } from './enums/compression'; export { ImageGravity } from './enums/image-gravity'; +export { TablesDBIndexType } from './enums/tables-db-index-type'; +export { PasswordHash } from './enums/password-hash'; +export { MessagingProviderType } from './enums/messaging-provider-type'; +export { DatabaseType } from './enums/database-type'; +export { AttributeStatus } from './enums/attribute-status'; +export { ColumnStatus } from './enums/column-status'; +export { IndexStatus } from './enums/index-status'; +export { DeploymentStatus } from './enums/deployment-status'; export { ExecutionTrigger } from './enums/execution-trigger'; export { ExecutionStatus } from './enums/execution-status'; +export { OAuth2GooglePrompt } from './enums/o-auth-2-google-prompt'; +export { PlatformType } from './enums/platform-type'; +export { HealthAntivirusStatus } from './enums/health-antivirus-status'; +export { HealthCheckStatus } from './enums/health-check-status'; +export { ProxyRuleDeploymentResourceType } from './enums/proxy-rule-deployment-resource-type'; +export { ProxyRuleStatus } from './enums/proxy-rule-status'; +export { MessageStatus } from './enums/message-status'; diff --git a/src/models.ts b/src/models.ts index 9556fba0..404dc453 100644 --- a/src/models.ts +++ b/src/models.ts @@ -1,5 +1,20 @@ +import { DatabaseType } from "./enums/database-type" +import { AttributeStatus } from "./enums/attribute-status" +import { ColumnStatus } from "./enums/column-status" +import { IndexStatus } from "./enums/index-status" +import { DeploymentStatus } from "./enums/deployment-status" import { ExecutionTrigger } from "./enums/execution-trigger" import { ExecutionStatus } from "./enums/execution-status" +import { ProjectAuthMethodId } from "./enums/project-auth-method-id" +import { ProjectServiceId } from "./enums/project-service-id" +import { ProjectProtocolId } from "./enums/project-protocol-id" +import { OAuth2GooglePrompt } from "./enums/o-auth-2-google-prompt" +import { PlatformType } from "./enums/platform-type" +import { HealthAntivirusStatus } from "./enums/health-antivirus-status" +import { HealthCheckStatus } from "./enums/health-check-status" +import { ProxyRuleDeploymentResourceType } from "./enums/proxy-rule-deployment-resource-type" +import { ProxyRuleStatus } from "./enums/proxy-rule-status" +import { MessageStatus } from "./enums/message-status" /** * Appwrite Models @@ -50,6 +65,90 @@ export namespace Models { presences: Presence[]; } + /** + * Tables List + */ + export type TableList = { + /** + * Total number of tables that matched your query. + */ + total: number; + /** + * List of tables. + */ + tables: Table[]; + } + + /** + * Collections List + */ + export type CollectionList = { + /** + * Total number of collections that matched your query. + */ + total: number; + /** + * List of collections. + */ + collections: Collection[]; + } + + /** + * Databases List + */ + export type DatabaseList = { + /** + * Total number of databases that matched your query. + */ + total: number; + /** + * List of databases. + */ + databases: Database[]; + } + + /** + * Indexes List + */ + export type IndexList = { + /** + * Total number of indexes that matched your query. + */ + total: number; + /** + * List of indexes. + */ + indexes: Index[]; + } + + /** + * Column Indexes List + */ + export type ColumnIndexList = { + /** + * Total number of indexes that matched your query. + */ + total: number; + /** + * List of indexes. + */ + indexes: ColumnIndex[]; + } + + /** + * Users List + */ + export type UserList<Preferences extends Models.Preferences = Models.DefaultPreferences> = { + /** + * Total number of users that matched your query. + */ + total: number; + /** + * List of users. + */ + users: User<Preferences>[]; + } + /** * Sessions List */ @@ -106,6 +205,34 @@ export namespace Models { files: File[]; } + /** + * Buckets List + */ + export type BucketList = { + /** + * Total number of buckets that matched your query. + */ + total: number; + /** + * List of buckets. + */ + buckets: Bucket[]; + } + + /** + * Resource Tokens List + */ + export type ResourceTokenList = { + /** + * Total number of tokens that matched your query. + */ + total: number; + /** + * List of tokens. + */ + tokens: ResourceToken[]; + } + /** * Teams List */ @@ -134,6 +261,76 @@ export namespace Models { memberships: Membership[]; } + /** + * Sites List + */ + export type SiteList = { + /** + * Total number of sites that matched your query. + */ + total: number; + /** + * List of sites. + */ + sites: Site[]; + } + + /** + * Functions List + */ + export type FunctionList = { + /** + * Total number of functions that matched your query. + */ + total: number; + /** + * List of functions. + */ + functions: Function[]; + } + + /** + * Frameworks List + */ + export type FrameworkList = { + /** + * Total number of frameworks that matched your query. + */ + total: number; + /** + * List of frameworks. + */ + frameworks: Framework[]; + } + + /** + * Runtimes List + */ + export type RuntimeList = { + /** + * Total number of runtimes that matched your query. + */ + total: number; + /** + * List of runtimes. + */ + runtimes: Runtime[]; + } + + /** + * Deployments List + */ + export type DeploymentList = { + /** + * Total number of deployments that matched your query. + */ + total: number; + /** + * List of deployments. + */ + deployments: Deployment[]; + } + /** * Executions List */ @@ -148,6 +345,34 @@ export namespace Models { executions: Execution[]; } + /** + * Webhooks List + */ + export type WebhookList = { + /** + * Total number of webhooks that matched your query. + */ + total: number; + /** + * List of webhooks. + */ + webhooks: Webhook[]; + } + + /** + * API Keys List + */ + export type KeyList = { + /** + * Total number of keys that matched your query. + */ + total: number; + /** + * List of keys. + */ + keys: Key[]; + } + /** * Countries List */ @@ -219,1238 +444,6648 @@ export namespace Models { } /** - * Locale codes list + * Variables List */ - export type LocaleCodeList = { + export type VariableList = { /** - * Total number of localeCodes that matched your query. + * Total number of variables that matched your query. */ total: number; /** - * List of localeCodes. + * List of variables. */ - localeCodes: LocaleCode[]; + variables: Variable[]; } /** - * Transaction List + * Mock Numbers List */ - export type TransactionList = { + export type MockNumberList = { /** - * Total number of transactions that matched your query. + * Total number of mockNumbers that matched your query. */ total: number; /** - * List of transactions. + * List of mockNumbers. */ - transactions: Transaction[]; + mockNumbers: MockNumber[]; } /** - * Row + * Policies List */ - export type Row = { - /** - * Row ID. - */ - $id: string; + export type PolicyList = { /** - * Row sequence ID. + * Total number of policies in the given project. */ - $sequence: string; + total: number; /** - * Table ID. + * List of policies. */ - $tableId: string; + policies: (Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordPersonalData | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy)[]; + } + + /** + * Email Templates List + */ + export type EmailTemplateList = { /** - * Database ID. + * Total number of templates that matched your query. */ - $databaseId: string; + total: number; /** - * Row creation date in ISO 8601 format. + * List of templates. */ - $createdAt: string; + templates: EmailTemplate[]; + } + + /** + * Status List + */ + export type HealthStatusList = { /** - * Row update date in ISO 8601 format. + * Total number of statuses that matched your query. */ - $updatedAt: string; + total: number; /** - * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * List of statuses. */ - $permissions: string[]; + statuses: HealthStatus[]; } - export type DefaultRow = Row & { - [key: string]: any; - [__default]: true; - }; - /** - * Document + * Rule List */ - export type Document = { - /** - * Document ID. - */ - $id: string; + export type ProxyRuleList = { /** - * Document sequence ID. + * Total number of rules that matched your query. */ - $sequence: string; + total: number; /** - * Collection ID. + * List of rules. */ - $collectionId: string; + rules: ProxyRule[]; + } + + /** + * Locale codes list + */ + export type LocaleCodeList = { /** - * Database ID. + * Total number of localeCodes that matched your query. */ - $databaseId: string; + total: number; /** - * Document creation date in ISO 8601 format. + * List of localeCodes. */ - $createdAt: string; + localeCodes: LocaleCode[]; + } + + /** + * Provider list + */ + export type ProviderList = { /** - * Document update date in ISO 8601 format. + * Total number of providers that matched your query. */ - $updatedAt: string; + total: number; /** - * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * List of providers. */ - $permissions: string[]; + providers: Provider[]; } - export type DefaultDocument = Document & { - [key: string]: any; - [__default]: true; - }; - /** - * Presence + * Message list */ - export type Presence = { + export type MessageList = { /** - * Presence ID. + * Total number of messages that matched your query. */ - $id: string; + total: number; /** - * Presence creation date in ISO 8601 format. + * List of messages. */ - $createdAt: string; + messages: Message[]; + } + + /** + * Topic list + */ + export type TopicList = { /** - * Presence update date in ISO 8601 format. + * Total number of topics that matched your query. */ - $updatedAt: string; + total: number; /** - * Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * List of topics. */ - $permissions: string[]; + topics: Topic[]; + } + + /** + * Subscriber list + */ + export type SubscriberList = { /** - * User ID. + * Total number of subscribers that matched your query. */ - userId: string; + total: number; /** - * Presence status. + * List of subscribers. */ - status?: string; + subscribers: Subscriber[]; + } + + /** + * Target list + */ + export type TargetList = { /** - * Presence source. + * Total number of targets that matched your query. */ - source: string; + total: number; /** - * Presence expiry date in ISO 8601 format. + * List of targets. */ - expiresAt?: string; + targets: Target[]; } - export type DefaultPresence = Presence & { - [key: string]: any; - [__default]: true; - }; + /** + * Transaction List + */ + export type TransactionList = { + /** + * Total number of transactions that matched your query. + */ + total: number; + /** + * List of transactions. + */ + transactions: Transaction[]; + } /** - * Log + * Specifications List */ - export type Log = { + export type SpecificationList = { /** - * Event name. + * Total number of specifications that matched your query. */ - event: string; + total: number; /** - * User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + * List of specifications. */ - userId: string; + specifications: Specification[]; + } + + /** + * Insights List + */ + export type InsightList = { /** - * User email of the actor recorded for this log. During impersonation, this is the original impersonator. + * Total number of insights that matched your query. */ - userEmail: string; + total: number; /** - * User name of the actor recorded for this log. During impersonation, this is the original impersonator. + * List of insights. */ - userName: string; + insights: Insight[]; + } + + /** + * Reports List + */ + export type ReportList = { /** - * API mode when event triggered. + * Total number of reports that matched your query. */ - mode: string; + total: number; /** - * User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. + * List of reports. */ - userType: string; + reports: Report[]; + } + + /** + * Database + */ + export type Database = { /** - * IP session in use when the session was created. + * Database ID. */ - ip: string; + $id: string; /** - * Log creation date in ISO 8601 format. + * Database name. */ - time: string; + name: string; /** - * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * Database creation date in ISO 8601 format. */ - osCode: string; + $createdAt: string; /** - * Operating system name. + * Database update date in ISO 8601 format. */ - osName: string; + $updatedAt: string; /** - * Operating system version. + * If database is enabled. Can be 'enabled' or 'disabled'. When disabled, the database is inaccessible to users, but remains accessible to Server SDKs using API keys. */ - osVersion: string; + enabled: boolean; /** - * Client type. + * Database type. */ - clientType: string; + type: DatabaseType; /** - * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * Database backup policies. */ - clientCode: string; + policies: BackupPolicy[]; /** - * Client name. + * Database backup archives. */ - clientName: string; + archives: BackupArchive[]; + } + + /** + * Collection + */ + export type Collection = { /** - * Client version. + * Collection ID. */ - clientVersion: string; + $id: string; /** - * Client engine name. + * Collection creation date in ISO 8601 format. */ - clientEngine: string; + $createdAt: string; /** - * Client engine name. + * Collection update date in ISO 8601 format. */ - clientEngineVersion: string; + $updatedAt: string; /** - * Device name. + * Collection permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - deviceName: string; + $permissions: string[]; /** - * Device brand name. + * Database ID. */ - deviceBrand: string; + databaseId: string; /** - * Device model name. + * Collection name. */ - deviceModel: string; + name: string; /** - * Country two-character ISO 3166-1 alpha code. + * Collection enabled. Can be 'enabled' or 'disabled'. When disabled, the collection is inaccessible to users, but remains accessible to Server SDKs using API keys. */ - countryCode: string; + enabled: boolean; /** - * Country name. + * Whether document-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). */ - countryName: string; + documentSecurity: boolean; + /** + * Collection attributes. + */ + attributes: (Models.AttributeBoolean | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + /** + * Collection indexes. + */ + indexes: Index[]; + /** + * Maximum document size in bytes. Returns 0 when no limit applies. + */ + bytesMax: number; + /** + * Currently used document size in bytes based on defined attributes. + */ + bytesUsed: number; } /** - * User + * Attributes List */ - export type User<Preferences extends Models.Preferences = Models.DefaultPreferences> = { + export type AttributeList = { /** - * User ID. + * Total number of attributes in the given collection. */ - $id: string; + total: number; /** - * User creation date in ISO 8601 format. + * List of attributes. */ - $createdAt: string; + attributes: (Models.AttributeBoolean | Models.AttributeBigint | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributePoint | Models.AttributeLine | Models.AttributePolygon | Models.AttributeVarchar | Models.AttributeText | Models.AttributeMediumtext | Models.AttributeLongtext | Models.AttributeString)[]; + } + + /** + * AttributeString + */ + export type AttributeString = { /** - * User update date in ISO 8601 format. + * Attribute Key. */ - $updatedAt: string; + key: string; /** - * User name. + * Attribute type. */ - name: string; + type: string; /** - * Hashed user password. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - password?: string; + status: AttributeStatus; /** - * Password hashing algorithm. + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - hash?: string; + error: string; /** - * Password hashing algorithm configuration. + * Is attribute required? */ - hashOptions?: object; + required: boolean; /** - * User registration date in ISO 8601 format. + * Is attribute an array? */ - registration: string; + array?: boolean; /** - * User status. Pass `true` for enabled and `false` for disabled. + * Attribute creation date in ISO 8601 format. */ - status: boolean; + $createdAt: string; /** - * Labels for the user. + * Attribute update date in ISO 8601 format. */ - labels: string[]; + $updatedAt: string; /** - * Password update time in ISO 8601 format. + * Attribute size. */ - passwordUpdate: string; + size: number; /** - * User email address. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - email: string; + default?: string; /** - * User phone number in E.164 format. + * Defines whether this attribute is encrypted or not. */ - phone: string; + encrypt?: boolean; + } + + /** + * AttributeInteger + */ + export type AttributeInteger = { /** - * Email verification status. + * Attribute Key. */ - emailVerification: boolean; + key: string; /** - * Phone verification status. + * Attribute type. */ - phoneVerification: boolean; + type: string; /** - * Multi factor authentication status. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - mfa: boolean; + status: AttributeStatus; /** - * User preferences as a key-value object + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - prefs: Preferences; + error: string; /** - * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + * Is attribute required? */ - targets: Target[]; + required: boolean; /** - * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + * Is attribute an array? */ - accessedAt: string; + array?: boolean; /** - * Whether the user can impersonate other users. + * Attribute creation date in ISO 8601 format. */ - impersonator?: boolean; + $createdAt: string; /** - * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + * Attribute update date in ISO 8601 format. */ - impersonatorUserId?: string; - } - - /** - * AlgoMD5 - */ - export type AlgoMd5 = { + $updatedAt: string; /** - * Algo type. + * Minimum value to enforce for new documents. */ - type: string; - } - - /** - * AlgoSHA - */ - export type AlgoSha = { + min?: number | bigint; /** - * Algo type. + * Maximum value to enforce for new documents. */ - type: string; - } - - /** - * AlgoPHPass - */ - export type AlgoPhpass = { + max?: number | bigint; /** - * Algo type. + * Default value for attribute when not provided. Cannot be set when attribute is required. */ - type: string; + default?: number; } /** - * AlgoBcrypt + * AttributeBigInt */ - export type AlgoBcrypt = { + export type AttributeBigint = { /** - * Algo type. + * Attribute Key. */ - type: string; - } - - /** - * AlgoScrypt - */ - export type AlgoScrypt = { + key: string; /** - * Algo type. + * Attribute type. */ type: string; /** - * CPU complexity of computed hash. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - costCpu: number; + status: AttributeStatus; /** - * Memory complexity of computed hash. + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - costMemory: number; + error: string; /** - * Parallelization of computed hash. + * Is attribute required? */ - costParallel: number; + required: boolean; /** - * Length used to compute hash. + * Is attribute an array? */ - length: number; - } - - /** - * AlgoScryptModified - */ - export type AlgoScryptModified = { + array?: boolean; /** - * Algo type. + * Attribute creation date in ISO 8601 format. */ - type: string; + $createdAt: string; /** - * Salt used to compute hash. + * Attribute update date in ISO 8601 format. */ - salt: string; + $updatedAt: string; /** - * Separator used to compute hash. + * Minimum value to enforce for new documents. */ - saltSeparator: string; + min?: number | bigint; /** - * Key used to compute hash. + * Maximum value to enforce for new documents. */ - signerKey: string; + max?: number | bigint; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: number | bigint; } /** - * AlgoArgon2 + * AttributeFloat */ - export type AlgoArgon2 = { + export type AttributeFloat = { /** - * Algo type. + * Attribute Key. + */ + key: string; + /** + * Attribute type. */ type: string; /** - * Memory used to compute hash. + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` */ - memoryCost: number; + status: AttributeStatus; /** - * Amount of time consumed to compute hash + * Error message. Displays error generated on failure of creating or deleting an attribute. */ - timeCost: number; + error: string; /** - * Number of threads used to compute hash. + * Is attribute required? */ - threads: number; - } - - /** - * Preferences - */ - export type Preferences = { - } - - export type DefaultPreferences = Preferences & { - [key: string]: any; - [__default]: true; - }; - - /** - * Session - */ - export type Session = { + required: boolean; /** - * Session ID. + * Is attribute an array? */ - $id: string; + array?: boolean; /** - * Session creation date in ISO 8601 format. + * Attribute creation date in ISO 8601 format. */ $createdAt: string; /** - * Session update date in ISO 8601 format. + * Attribute update date in ISO 8601 format. */ $updatedAt: string; /** - * User ID. + * Minimum value to enforce for new documents. */ - userId: string; + min?: number; /** - * Session expiration date in ISO 8601 format. + * Maximum value to enforce for new documents. */ - expire: string; + max?: number; /** - * Session Provider. + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: number; + } + + /** + * AttributeBoolean + */ + export type AttributeBoolean = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: boolean; + } + + /** + * AttributeEmail + */ + export type AttributeEmail = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + } + + /** + * AttributeEnum + */ + export type AttributeEnum = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Array of elements in enumerated type. + */ + elements: string[]; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + } + + /** + * AttributeIP + */ + export type AttributeIp = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + } + + /** + * AttributeURL + */ + export type AttributeUrl = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + } + + /** + * AttributeDatetime + */ + export type AttributeDatetime = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * ISO 8601 format. + */ + format: string; + /** + * Default value for attribute when not provided. Only null is optional + */ + default?: string; + } + + /** + * AttributeRelationship + */ + export type AttributeRelationship = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * The ID of the related collection. + */ + relatedCollection: string; + /** + * The type of the relationship. + */ + relationType: string; + /** + * Is the relationship two-way? + */ + twoWay: boolean; + /** + * The key of the two-way relationship. + */ + twoWayKey: string; + /** + * How deleting the parent document will propagate to child documents. + */ + onDelete: string; + /** + * Whether this is the parent or child side of the relationship + */ + side: string; + } + + /** + * AttributePoint + */ + export type AttributePoint = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: any[]; + } + + /** + * AttributeLine + */ + export type AttributeLine = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: any[]; + } + + /** + * AttributePolygon + */ + export type AttributePolygon = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: any[]; + } + + /** + * AttributeVarchar + */ + export type AttributeVarchar = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Attribute size. + */ + size: number; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; + } + + /** + * AttributeText + */ + export type AttributeText = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; + } + + /** + * AttributeMediumtext + */ + export type AttributeMediumtext = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; + } + + /** + * AttributeLongtext + */ + export type AttributeLongtext = { + /** + * Attribute Key. + */ + key: string; + /** + * Attribute type. + */ + type: string; + /** + * Attribute status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: AttributeStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an attribute. + */ + error: string; + /** + * Is attribute required? + */ + required: boolean; + /** + * Is attribute an array? + */ + array?: boolean; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for attribute when not provided. Cannot be set when attribute is required. + */ + default?: string; + /** + * Defines whether this attribute is encrypted or not. + */ + encrypt?: boolean; + } + + /** + * Table + */ + export type Table = { + /** + * Table ID. + */ + $id: string; + /** + * Table creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Table update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Table permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * Database ID. + */ + databaseId: string; + /** + * Table name. + */ + name: string; + /** + * Table enabled. Can be 'enabled' or 'disabled'. When disabled, the table is inaccessible to users, but remains accessible to Server SDKs using API keys. + */ + enabled: boolean; + /** + * Whether row-level permissions are enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + rowSecurity: boolean; + /** + * Table columns. + */ + columns: (Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; + /** + * Table indexes. + */ + indexes: ColumnIndex[]; + /** + * Maximum row size in bytes. Returns 0 when no limit applies. + */ + bytesMax: number; + /** + * Currently used row size in bytes based on defined columns. + */ + bytesUsed: number; + } + + /** + * Columns List + */ + export type ColumnList = { + /** + * Total number of columns in the given table. + */ + total: number; + /** + * List of columns. + */ + columns: (Models.ColumnBoolean | Models.ColumnBigint | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnPoint | Models.ColumnLine | Models.ColumnPolygon | Models.ColumnVarchar | Models.ColumnText | Models.ColumnMediumtext | Models.ColumnLongtext | Models.ColumnString)[]; + } + + /** + * ColumnString + */ + export type ColumnString = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Column size. + */ + size: number; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + /** + * Defines whether this column is encrypted or not. + */ + encrypt?: boolean; + } + + /** + * ColumnInteger + */ + export type ColumnInteger = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number | bigint; + /** + * Maximum value to enforce for new documents. + */ + max?: number | bigint; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: number; + } + + /** + * ColumnBigInt + */ + export type ColumnBigint = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number | bigint; + /** + * Maximum value to enforce for new documents. + */ + max?: number | bigint; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: number | bigint; + } + + /** + * ColumnFloat + */ + export type ColumnFloat = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Minimum value to enforce for new documents. + */ + min?: number; + /** + * Maximum value to enforce for new documents. + */ + max?: number; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: number; + } + + /** + * ColumnBoolean + */ + export type ColumnBoolean = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: boolean; + } + + /** + * ColumnEmail + */ + export type ColumnEmail = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + } + + /** + * ColumnEnum + */ + export type ColumnEnum = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Array of elements in enumerated type. + */ + elements: string[]; + /** + * String format. + */ + format: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + } + + /** + * ColumnIP + */ + export type ColumnIp = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + } + + /** + * ColumnURL + */ + export type ColumnUrl = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * String format. + */ + format: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + } + + /** + * ColumnDatetime + */ + export type ColumnDatetime = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * ISO 8601 format. + */ + format: string; + /** + * Default value for column when not provided. Only null is optional + */ + default?: string; + } + + /** + * ColumnRelationship + */ + export type ColumnRelationship = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * The ID of the related table. + */ + relatedTable: string; + /** + * The type of the relationship. + */ + relationType: string; + /** + * Is the relationship two-way? + */ + twoWay: boolean; + /** + * The key of the two-way relationship. + */ + twoWayKey: string; + /** + * How deleting the parent document will propagate to child documents. + */ + onDelete: string; + /** + * Whether this is the parent or child side of the relationship + */ + side: string; + } + + /** + * ColumnPoint + */ + export type ColumnPoint = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: any[]; + } + + /** + * ColumnLine + */ + export type ColumnLine = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: any[]; + } + + /** + * ColumnPolygon + */ + export type ColumnPolygon = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: any[]; + } + + /** + * ColumnVarchar + */ + export type ColumnVarchar = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Column size. + */ + size: number; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + /** + * Defines whether this column is encrypted or not. + */ + encrypt?: boolean; + } + + /** + * ColumnText + */ + export type ColumnText = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + /** + * Defines whether this column is encrypted or not. + */ + encrypt?: boolean; + } + + /** + * ColumnMediumtext + */ + export type ColumnMediumtext = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + /** + * Defines whether this column is encrypted or not. + */ + encrypt?: boolean; + } + + /** + * ColumnLongtext + */ + export type ColumnLongtext = { + /** + * Column Key. + */ + key: string; + /** + * Column type. + */ + type: string; + /** + * Column status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: ColumnStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an column. + */ + error: string; + /** + * Is column required? + */ + required: boolean; + /** + * Is column an array? + */ + array?: boolean; + /** + * Column creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Column update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Default value for column when not provided. Cannot be set when column is required. + */ + default?: string; + /** + * Defines whether this column is encrypted or not. + */ + encrypt?: boolean; + } + + /** + * Index + */ + export type Index = { + /** + * Index ID. + */ + $id: string; + /** + * Index creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Index update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Index key. + */ + key: string; + /** + * Index type. + */ + type: string; + /** + * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: IndexStatus; + /** + * Error message. Displays error generated on failure of creating or deleting an index. + */ + error: string; + /** + * Index attributes. + */ + attributes: string[]; + /** + * Index attributes length. + */ + lengths: number[]; + /** + * Index orders. + */ + orders?: string[]; + } + + /** + * Index + */ + export type ColumnIndex = { + /** + * Index ID. + */ + $id: string; + /** + * Index creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Index update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Index Key. + */ + key: string; + /** + * Index type. + */ + type: string; + /** + * Index status. Possible values: `available`, `processing`, `deleting`, `stuck`, or `failed` + */ + status: string; + /** + * Error message. Displays error generated on failure of creating or deleting an index. + */ + error: string; + /** + * Index columns. + */ + columns: string[]; + /** + * Index columns length. + */ + lengths: number[]; + /** + * Index orders. + */ + orders?: string[]; + } + + /** + * Row + */ + export type Row = { + /** + * Row ID. + */ + $id: string; + /** + * Row sequence ID. + */ + $sequence: string; + /** + * Table ID. + */ + $tableId: string; + /** + * Database ID. + */ + $databaseId: string; + /** + * Row creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Row update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Row permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + } + + export type DefaultRow = Row & { + [key: string]: any; + [__default]: true; + }; + + /** + * Document + */ + export type Document = { + /** + * Document ID. + */ + $id: string; + /** + * Document sequence ID. + */ + $sequence: string; + /** + * Collection ID. + */ + $collectionId: string; + /** + * Database ID. + */ + $databaseId: string; + /** + * Document creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Document update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Document permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + } + + export type DefaultDocument = Document & { + [key: string]: any; + [__default]: true; + }; + + /** + * Presence + */ + export type Presence = { + /** + * Presence ID. + */ + $id: string; + /** + * Presence creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Presence update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Presence permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * User ID. + */ + userId: string; + /** + * Presence status. + */ + status?: string; + /** + * Presence source. + */ + source: string; + /** + * Presence expiry date in ISO 8601 format. + */ + expiresAt?: string; + } + + export type DefaultPresence = Presence & { + [key: string]: any; + [__default]: true; + }; + + /** + * Log + */ + export type Log = { + /** + * Event name. + */ + event: string; + /** + * User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user. + */ + userId: string; + /** + * User email of the actor recorded for this log. During impersonation, this is the original impersonator. + */ + userEmail: string; + /** + * User name of the actor recorded for this log. During impersonation, this is the original impersonator. + */ + userName: string; + /** + * API mode when event triggered. + */ + mode: string; + /** + * User type who triggered the audit log. Possible values: user, admin, guest, keyProject, keyAccount, keyOrganization. + */ + userType: string; + /** + * IP session in use when the session was created. + */ + ip: string; + /** + * Log creation date in ISO 8601 format. + */ + time: string; + /** + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + */ + osCode: string; + /** + * Operating system name. + */ + osName: string; + /** + * Operating system version. + */ + osVersion: string; + /** + * Client type. + */ + clientType: string; + /** + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + */ + clientCode: string; + /** + * Client name. + */ + clientName: string; + /** + * Client version. + */ + clientVersion: string; + /** + * Client engine name. + */ + clientEngine: string; + /** + * Client engine name. + */ + clientEngineVersion: string; + /** + * Device name. + */ + deviceName: string; + /** + * Device brand name. + */ + deviceBrand: string; + /** + * Device model name. + */ + deviceModel: string; + /** + * Country two-character ISO 3166-1 alpha code. + */ + countryCode: string; + /** + * Country name. + */ + countryName: string; + } + + /** + * User + */ + export type User<Preferences extends Models.Preferences = Models.DefaultPreferences> = { + /** + * User ID. + */ + $id: string; + /** + * User creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * User name. + */ + name: string; + /** + * Hashed user password. + */ + password?: string; + /** + * Password hashing algorithm. + */ + hash?: string; + /** + * Password hashing algorithm configuration. + */ + hashOptions?: object; + /** + * User registration date in ISO 8601 format. + */ + registration: string; + /** + * User status. Pass `true` for enabled and `false` for disabled. + */ + status: boolean; + /** + * Labels for the user. + */ + labels: string[]; + /** + * Password update time in ISO 8601 format. + */ + passwordUpdate: string; + /** + * User email address. + */ + email: string; + /** + * User phone number in E.164 format. + */ + phone: string; + /** + * Email verification status. + */ + emailVerification: boolean; + /** + * Phone verification status. + */ + phoneVerification: boolean; + /** + * Multi factor authentication status. + */ + mfa: boolean; + /** + * User preferences as a key-value object + */ + prefs: Preferences; + /** + * A user-owned message receiver. A single user may have multiple e.g. emails, phones, and a browser. Each target is registered with a single provider. + */ + targets: Target[]; + /** + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + */ + accessedAt: string; + /** + * Whether the user can impersonate other users. + */ + impersonator?: boolean; + /** + * ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data. + */ + impersonatorUserId?: string; + } + + /** + * AlgoMD5 + */ + export type AlgoMd5 = { + /** + * Algo type. + */ + type: string; + } + + /** + * AlgoSHA + */ + export type AlgoSha = { + /** + * Algo type. + */ + type: string; + } + + /** + * AlgoPHPass + */ + export type AlgoPhpass = { + /** + * Algo type. + */ + type: string; + } + + /** + * AlgoBcrypt + */ + export type AlgoBcrypt = { + /** + * Algo type. + */ + type: string; + } + + /** + * AlgoScrypt + */ + export type AlgoScrypt = { + /** + * Algo type. + */ + type: string; + /** + * CPU complexity of computed hash. + */ + costCpu: number; + /** + * Memory complexity of computed hash. + */ + costMemory: number; + /** + * Parallelization of computed hash. + */ + costParallel: number; + /** + * Length used to compute hash. + */ + length: number; + } + + /** + * AlgoScryptModified + */ + export type AlgoScryptModified = { + /** + * Algo type. + */ + type: string; + /** + * Salt used to compute hash. + */ + salt: string; + /** + * Separator used to compute hash. + */ + saltSeparator: string; + /** + * Key used to compute hash. + */ + signerKey: string; + } + + /** + * AlgoArgon2 + */ + export type AlgoArgon2 = { + /** + * Algo type. + */ + type: string; + /** + * Memory used to compute hash. + */ + memoryCost: number; + /** + * Amount of time consumed to compute hash + */ + timeCost: number; + /** + * Number of threads used to compute hash. + */ + threads: number; + } + + /** + * Preferences + */ + export type Preferences = { + } + + export type DefaultPreferences = Preferences & { + [key: string]: any; + [__default]: true; + }; + + /** + * Session + */ + export type Session = { + /** + * Session ID. + */ + $id: string; + /** + * Session creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Session update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * User ID. + */ + userId: string; + /** + * Session expiration date in ISO 8601 format. + */ + expire: string; + /** + * Session Provider. + */ + provider: string; + /** + * Session Provider User ID. + */ + providerUid: string; + /** + * Session Provider Access Token. + */ + providerAccessToken: string; + /** + * The date of when the access token expires in ISO 8601 format. + */ + providerAccessTokenExpiry: string; + /** + * Session Provider Refresh Token. + */ + providerRefreshToken: string; + /** + * IP in use when the session was created. + */ + ip: string; + /** + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + */ + osCode: string; + /** + * Operating system name. + */ + osName: string; + /** + * Operating system version. + */ + osVersion: string; + /** + * Client type. + */ + clientType: string; + /** + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + */ + clientCode: string; + /** + * Client name. + */ + clientName: string; + /** + * Client version. + */ + clientVersion: string; + /** + * Client engine name. + */ + clientEngine: string; + /** + * Client engine name. + */ + clientEngineVersion: string; + /** + * Device name. + */ + deviceName: string; + /** + * Device brand name. + */ + deviceBrand: string; + /** + * Device model name. + */ + deviceModel: string; + /** + * Country two-character ISO 3166-1 alpha code. + */ + countryCode: string; + /** + * Country name. + */ + countryName: string; + /** + * Returns true if this the current user session. + */ + current: boolean; + /** + * Returns a list of active session factors. + */ + factors: string[]; + /** + * Secret used to authenticate the user. Only included if the request was made with an API key + */ + secret: string; + /** + * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + */ + mfaUpdatedAt: string; + } + + /** + * Identity + */ + export type Identity = { + /** + * Identity ID. + */ + $id: string; + /** + * Identity creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Identity update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * User ID. + */ + userId: string; + /** + * Identity Provider. + */ + provider: string; + /** + * ID of the User in the Identity Provider. + */ + providerUid: string; + /** + * Email of the User in the Identity Provider. + */ + providerEmail: string; + /** + * Identity Provider Access Token. + */ + providerAccessToken: string; + /** + * The date of when the access token expires in ISO 8601 format. + */ + providerAccessTokenExpiry: string; + /** + * Identity Provider Refresh Token. + */ + providerRefreshToken: string; + } + + /** + * Token + */ + export type Token = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + */ + secret: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + /** + * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + */ + phrase: string; + } + + /** + * JWT + */ + export type Jwt = { + /** + * JWT encoded string. + */ + jwt: string; + } + + /** + * Locale + */ + export type Locale = { + /** + * User IP address. + */ + ip: string; + /** + * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + */ + countryCode: string; + /** + * Country name. This field support localization. + */ + country: string; + /** + * Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + */ + continentCode: string; + /** + * Continent name. This field support localization. + */ + continent: string; + /** + * True if country is part of the European Union. + */ + eu: boolean; + /** + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + */ + currency: string; + } + + /** + * LocaleCode + */ + export type LocaleCode = { + /** + * Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + */ + code: string; + /** + * Locale name + */ + name: string; + } + + /** + * File + */ + export type File = { + /** + * File ID. + */ + $id: string; + /** + * Bucket ID. + */ + bucketId: string; + /** + * File creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * File update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * File name. + */ + name: string; + /** + * File MD5 signature. + */ + signature: string; + /** + * File mime type. + */ + mimeType: string; + /** + * File original size in bytes. + */ + sizeOriginal: number; + /** + * File actual stored size in bytes after compression and/or encryption. + */ + sizeActual: number; + /** + * Total number of chunks available + */ + chunksTotal: number; + /** + * Total number of chunks uploaded + */ + chunksUploaded: number; + /** + * Whether file contents are encrypted at rest. + */ + encryption: boolean; + /** + * Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + */ + compression: string; + } + + /** + * Bucket + */ + export type Bucket = { + /** + * Bucket ID. + */ + $id: string; + /** + * Bucket creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Bucket update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Bucket permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + $permissions: string[]; + /** + * Whether file-level security is enabled. [Learn more about permissions](https://appwrite.io/docs/permissions). + */ + fileSecurity: boolean; + /** + * Bucket name. + */ + name: string; + /** + * Bucket enabled. + */ + enabled: boolean; + /** + * Maximum file size supported. + */ + maximumFileSize: number; + /** + * Allowed file extensions. + */ + allowedFileExtensions: string[]; + /** + * Compression algorithm chosen for compression. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + */ + compression: string; + /** + * Bucket is encrypted. + */ + encryption: boolean; + /** + * Virus scanning is enabled. + */ + antivirus: boolean; + /** + * Image transformations are enabled. + */ + transformations: boolean; + /** + * Total size of this bucket in bytes. + */ + totalSize: number; + } + + /** + * ResourceToken + */ + export type ResourceToken = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Resource ID. + */ + resourceId: string; + /** + * Resource type. + */ + resourceType: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + /** + * JWT encoded string. + */ + secret: string; + /** + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + */ + accessedAt: string; + } + + /** + * Team + */ + export type Team<Preferences extends Models.Preferences = Models.DefaultPreferences> = { + /** + * Team ID. + */ + $id: string; + /** + * Team creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Team update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Team name. + */ + name: string; + /** + * Total number of team members. + */ + total: number; + /** + * Team preferences as a key-value object + */ + prefs: Preferences; + } + + /** + * Membership + */ + export type Membership = { + /** + * Membership ID. + */ + $id: string; + /** + * Membership creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Membership update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * User ID. + */ + userId: string; + /** + * User name. Hide this attribute by toggling membership privacy in the Console. + */ + userName: string; + /** + * User email address. Hide this attribute by toggling membership privacy in the Console. + */ + userEmail: string; + /** + * User phone number. Hide this attribute by toggling membership privacy in the Console. + */ + userPhone: string; + /** + * Team ID. + */ + teamId: string; + /** + * Team name. + */ + teamName: string; + /** + * Date, the user has been invited to join the team in ISO 8601 format. + */ + invited: string; + /** + * Date, the user has accepted the invitation to join the team in ISO 8601 format. + */ + joined: string; + /** + * User confirmation status, true if the user has joined the team or false otherwise. + */ + confirm: boolean; + /** + * Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + */ + mfa: boolean; + /** + * User list of roles + */ + roles: string[]; + } + + /** + * Site + */ + export type Site = { + /** + * Site ID. + */ + $id: string; + /** + * Site creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Site update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Site name. + */ + name: string; + /** + * Site enabled. + */ + enabled: boolean; + /** + * Is the site deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the site to update it with the latest configuration. + */ + live: boolean; + /** + * When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + */ + logging: boolean; + /** + * Site framework. + */ + framework: string; + /** + * How many days to keep the non-active deployments before they will be automatically deleted. + */ + deploymentRetention: number; + /** + * Site's active deployment ID. + */ + deploymentId: string; + /** + * Active deployment creation date in ISO 8601 format. + */ + deploymentCreatedAt: string; + /** + * Screenshot of active deployment with light theme preference file ID. + */ + deploymentScreenshotLight: string; + /** + * Screenshot of active deployment with dark theme preference file ID. + */ + deploymentScreenshotDark: string; + /** + * Site's latest deployment ID. + */ + latestDeploymentId: string; + /** + * Latest deployment creation date in ISO 8601 format. + */ + latestDeploymentCreatedAt: string; + /** + * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + */ + latestDeploymentStatus: string; + /** + * Site variables. + */ + vars: Variable[]; + /** + * Site request timeout in seconds. + */ + timeout: number; + /** + * The install command used to install the site dependencies. + */ + installCommand: string; + /** + * The build command used to build the site. + */ + buildCommand: string; + /** + * Custom command to use when starting site runtime. + */ + startCommand: string; + /** + * The directory where the site build output is located. + */ + outputDirectory: string; + /** + * Site VCS (Version Control System) installation id. + */ + installationId: string; + /** + * VCS (Version Control System) Repository ID + */ + providerRepositoryId: string; + /** + * VCS (Version Control System) branch name + */ + providerBranch: string; + /** + * Path to site in VCS (Version Control System) repository + */ + providerRootDirectory: string; + /** + * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + */ + providerSilentMode: boolean; + /** + * Machine specification for deployment builds. + */ + buildSpecification: string; + /** + * Machine specification for SSR executions. + */ + runtimeSpecification: string; + /** + * Site build runtime. + */ + buildRuntime: string; + /** + * Site framework adapter. + */ + adapter: string; + /** + * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + */ + fallbackFile: string; + } + + /** + * Function + */ + export type Function = { + /** + * Function ID. + */ + $id: string; + /** + * Function creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Function update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Execution permissions. + */ + execute: string[]; + /** + * Function name. + */ + name: string; + /** + * Function enabled. + */ + enabled: boolean; + /** + * Is the function deployed with the latest configuration? This is set to false if you've changed an environment variables, entrypoint, commands, or other settings that needs redeploy to be applied. When the value is false, redeploy the function to update it with the latest configuration. + */ + live: boolean; + /** + * When disabled, executions will exclude logs and errors, and will be slightly faster. + */ + logging: boolean; + /** + * Function execution and build runtime. + */ + runtime: string; + /** + * How many days to keep the non-active deployments before they will be automatically deleted. + */ + deploymentRetention: number; + /** + * Function's active deployment ID. + */ + deploymentId: string; + /** + * Active deployment creation date in ISO 8601 format. + */ + deploymentCreatedAt: string; + /** + * Function's latest deployment ID. + */ + latestDeploymentId: string; + /** + * Latest deployment creation date in ISO 8601 format. + */ + latestDeploymentCreatedAt: string; + /** + * Status of latest deployment. Possible values are "waiting", "processing", "building", "ready", and "failed". + */ + latestDeploymentStatus: string; + /** + * Allowed permission scopes. + */ + scopes: string[]; + /** + * Function variables. + */ + vars: Variable[]; + /** + * Function trigger events. + */ + events: string[]; + /** + * Function execution schedule in CRON format. + */ + schedule: string; + /** + * Function execution timeout in seconds. + */ + timeout: number; + /** + * The entrypoint file used to execute the deployment. + */ + entrypoint: string; + /** + * The build command used to build the deployment. + */ + commands: string; + /** + * Version of Open Runtimes used for the function. + */ + version: string; + /** + * Function VCS (Version Control System) installation id. + */ + installationId: string; + /** + * VCS (Version Control System) Repository ID + */ + providerRepositoryId: string; + /** + * VCS (Version Control System) branch name + */ + providerBranch: string; + /** + * Path to function in VCS (Version Control System) repository + */ + providerRootDirectory: string; + /** + * Is VCS (Version Control System) connection is in silent mode? When in silence mode, no comments will be posted on the repository pull or merge requests + */ + providerSilentMode: boolean; + /** + * Machine specification for deployment builds. + */ + buildSpecification: string; + /** + * Machine specification for executions. + */ + runtimeSpecification: string; + } + + /** + * Runtime + */ + export type Runtime = { + /** + * Runtime ID. + */ + $id: string; + /** + * Parent runtime key. + */ + key: string; + /** + * Runtime Name. + */ + name: string; + /** + * Runtime version. + */ + version: string; + /** + * Base Docker image used to build the runtime. + */ + base: string; + /** + * Image name of Docker Hub. + */ + image: string; + /** + * Name of the logo image. + */ + logo: string; + /** + * List of supported architectures. + */ + supports: string[]; + } + + /** + * Framework + */ + export type Framework = { + /** + * Framework key. + */ + key: string; + /** + * Framework Name. + */ + name: string; + /** + * Default runtime version. + */ + buildRuntime: string; + /** + * List of supported runtime versions. + */ + runtimes: string[]; + /** + * List of supported adapters. + */ + adapters: FrameworkAdapter[]; + } + + /** + * Framework Adapter + */ + export type FrameworkAdapter = { + /** + * Adapter key. + */ + key: string; + /** + * Default command to download dependencies. + */ + installCommand: string; + /** + * Default command to build site into output directory. + */ + buildCommand: string; + /** + * Default output directory of build. + */ + outputDirectory: string; + /** + * Name of fallback file to use instead of 404 page. If null, Appwrite 404 page will be displayed. + */ + fallbackFile: string; + } + + /** + * Deployment + */ + export type Deployment = { + /** + * Deployment ID. + */ + $id: string; + /** + * Deployment creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Deployment update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Type of deployment. + */ + type: string; + /** + * Resource ID. + */ + resourceId: string; + /** + * Resource type. + */ + resourceType: string; + /** + * The entrypoint file to use to execute the deployment code. + */ + entrypoint: string; + /** + * The code size in bytes. + */ + sourceSize: number; + /** + * The build output size in bytes. + */ + buildSize: number; + /** + * The total size in bytes (source and build output). + */ + totalSize: number; + /** + * The current build ID. + */ + buildId: string; + /** + * Whether the deployment should be automatically activated. + */ + activate: boolean; + /** + * Screenshot with light theme preference file ID. + */ + screenshotLight: string; + /** + * Screenshot with dark theme preference file ID. + */ + screenshotDark: string; + /** + * The deployment status. Possible values are "waiting", "processing", "building", "ready", "canceled" and "failed". + */ + status: DeploymentStatus; + /** + * The build logs. + */ + buildLogs: string; + /** + * The current build time in seconds. + */ + buildDuration: number; + /** + * The name of the vcs provider repository + */ + providerRepositoryName: string; + /** + * The name of the vcs provider repository owner + */ + providerRepositoryOwner: string; + /** + * The url of the vcs provider repository + */ + providerRepositoryUrl: string; + /** + * The commit hash of the vcs commit + */ + providerCommitHash: string; + /** + * The url of vcs commit author + */ + providerCommitAuthorUrl: string; + /** + * The name of vcs commit author + */ + providerCommitAuthor: string; + /** + * The commit message + */ + providerCommitMessage: string; + /** + * The url of the vcs commit + */ + providerCommitUrl: string; + /** + * The branch of the vcs repository + */ + providerBranch: string; + /** + * The branch of the vcs repository + */ + providerBranchUrl: string; + } + + /** + * Execution + */ + export type Execution = { + /** + * Execution ID. + */ + $id: string; + /** + * Execution creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Execution update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Execution roles. + */ + $permissions: string[]; + /** + * Function ID. + */ + functionId: string; + /** + * Function's deployment ID used to create the execution. + */ + deploymentId: string; + /** + * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + */ + trigger: ExecutionTrigger; + /** + * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + */ + status: ExecutionStatus; + /** + * HTTP request method type. + */ + requestMethod: string; + /** + * HTTP request path and query. + */ + requestPath: string; + /** + * HTTP request headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + */ + requestHeaders: Headers[]; + /** + * HTTP response status code. + */ + responseStatusCode: number; + /** + * HTTP response body. This will return empty unless execution is created as synchronous. + */ + responseBody: string; + /** + * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + */ + responseHeaders: Headers[]; + /** + * Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + */ + logs: string; + /** + * Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + */ + errors: string; + /** + * Resource(function/site) execution duration in seconds. + */ + duration: number; + /** + * The scheduled time for execution. If left empty, execution will be queued immediately. + */ + scheduledAt?: string; + } + + /** + * Project + */ + export type Project = { + /** + * Project ID. + */ + $id: string; + /** + * Project creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Project update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Project name. + */ + name: string; + /** + * Project team ID. + */ + teamId: string; + /** + * Deprecated since 1.9.5: List of dev keys. + */ + devKeys: DevKey[]; + /** + * Status for custom SMTP + */ + smtpEnabled: boolean; + /** + * SMTP sender name + */ + smtpSenderName: string; + /** + * SMTP sender email + */ + smtpSenderEmail: string; + /** + * SMTP reply to name + */ + smtpReplyToName: string; + /** + * SMTP reply to email + */ + smtpReplyToEmail: string; + /** + * SMTP server host name + */ + smtpHost: string; + /** + * SMTP server port + */ + smtpPort: number; + /** + * SMTP server username + */ + smtpUsername: string; + /** + * SMTP server password. This property is write-only and always returned empty. + */ + smtpPassword: string; + /** + * SMTP server secure protocol + */ + smtpSecure: string; + /** + * Number of times the ping was received for this project. + */ + pingCount: number; + /** + * Last ping datetime in ISO 8601 format. + */ + pingedAt: string; + /** + * Labels for the project. + */ + labels: string[]; + /** + * Project status + */ + status: string; + /** + * List of auth methods. + */ + authMethods: ProjectAuthMethod[]; + /** + * List of services. + */ + services: ProjectService[]; + /** + * List of protocols. + */ + protocols: ProjectProtocol[]; + /** + * Project region + */ + region: string; + /** + * Billing limits reached + */ + billingLimits: BillingLimits; + /** + * Project blocks information + */ + blocks: Block[]; + /** + * Last time the project was accessed via console. Used with plan's projectInactivityDays to determine if project is paused. + */ + consoleAccessedAt: string; + } + + /** + * ProjectAuthMethod + */ + export type ProjectAuthMethod = { + /** + * Auth method ID. + */ + $id: ProjectAuthMethodId; + /** + * Auth method status. + */ + enabled: boolean; + } + + /** + * ProjectService + */ + export type ProjectService = { + /** + * Service ID. + */ + $id: ProjectServiceId; + /** + * Service status. + */ + enabled: boolean; + } + + /** + * ProjectProtocol + */ + export type ProjectProtocol = { + /** + * Protocol ID. + */ + $id: ProjectProtocolId; + /** + * Protocol status. + */ + enabled: boolean; + } + + /** + * Webhook + */ + export type Webhook = { + /** + * Webhook ID. + */ + $id: string; + /** + * Webhook creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Webhook update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Webhook name. + */ + name: string; + /** + * Webhook URL endpoint. + */ + url: string; + /** + * Webhook trigger events. + */ + events: string[]; + /** + * Indicates if SSL / TLS certificate verification is enabled. + */ + tls: boolean; + /** + * HTTP basic authentication username. + */ + authUsername: string; + /** + * HTTP basic authentication password. + */ + authPassword: string; + /** + * Signature key which can be used to validate incoming webhook payloads. Only returned on creation and secret rotation. + */ + secret: string; + /** + * Indicates if this webhook is enabled. + */ + enabled: boolean; + /** + * Webhook error logs from the most recent failure. + */ + logs: string; + /** + * Number of consecutive failed webhook attempts. + */ + attempts: number; + } + + /** + * Key + */ + export type Key = { + /** + * Key ID. + */ + $id: string; + /** + * Key creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Key update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Key name. + */ + name: string; + /** + * Key expiration date in ISO 8601 format. + */ + expire: string; + /** + * Allowed permission scopes. + */ + scopes: string[]; + /** + * Secret key. + */ + secret: string; + /** + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + */ + accessedAt: string; + /** + * List of SDK user agents that used this key. + */ + sdks: string[]; + } + + /** + * Ephemeral Key + */ + export type EphemeralKey = { + /** + * Key ID. + */ + $id: string; + /** + * Key creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Key update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Key name. + */ + name: string; + /** + * Key expiration date in ISO 8601 format. + */ + expire: string; + /** + * Allowed permission scopes. + */ + scopes: string[]; + /** + * Secret key. + */ + secret: string; + /** + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + */ + accessedAt: string; + /** + * List of SDK user agents that used this key. + */ + sdks: string[]; + } + + /** + * DevKey + */ + export type DevKey = { + /** + * Key ID. + */ + $id: string; + /** + * Key creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Key update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Key name. + */ + name: string; + /** + * Key expiration date in ISO 8601 format. + */ + expire: string; + /** + * Secret key. + */ + secret: string; + /** + * Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + */ + accessedAt: string; + /** + * List of SDK user agents that used this key. + */ + sdks: string[]; + } + + /** + * Mock Number + */ + export type MockNumber = { + /** + * Mock phone number for testing phone authentication. Useful for testing phone authentication without sending an SMS. + */ + number: string; + /** + * Mock OTP for the number. + */ + otp: string; + /** + * Attribute creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Attribute update date in ISO 8601 format. + */ + $updatedAt: string; + } + + /** + * OAuth2GitHub + */ + export type OAuth2Github = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * GitHub OAuth2 client ID. For GitHub Apps, use the "App ID" when both an App ID and client ID are available. + */ + clientId: string; + /** + * GitHub OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Discord + */ + export type OAuth2Discord = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Discord OAuth2 client ID. + */ + clientId: string; + /** + * Discord OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Figma + */ + export type OAuth2Figma = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Figma OAuth2 client ID. + */ + clientId: string; + /** + * Figma OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Dropbox + */ + export type OAuth2Dropbox = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Dropbox OAuth2 app key. + */ + appKey: string; + /** + * Dropbox OAuth2 app secret. + */ + appSecret: string; + } + + /** + * OAuth2Dailymotion + */ + export type OAuth2Dailymotion = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Dailymotion OAuth2 API key. + */ + apiKey: string; + /** + * Dailymotion OAuth2 API secret. + */ + apiSecret: string; + } + + /** + * OAuth2Bitbucket + */ + export type OAuth2Bitbucket = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Bitbucket OAuth2 key. + */ + key: string; + /** + * Bitbucket OAuth2 secret. + */ + secret: string; + } + + /** + * OAuth2Bitly + */ + export type OAuth2Bitly = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Bitly OAuth2 client ID. + */ + clientId: string; + /** + * Bitly OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Box + */ + export type OAuth2Box = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Box OAuth2 client ID. + */ + clientId: string; + /** + * Box OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Autodesk + */ + export type OAuth2Autodesk = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Autodesk OAuth2 client ID. + */ + clientId: string; + /** + * Autodesk OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Google + */ + export type OAuth2Google = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Google OAuth2 client ID. + */ + clientId: string; + /** + * Google OAuth2 client secret. + */ + clientSecret: string; + /** + * Google OAuth2 prompt values. + */ + prompt: OAuth2GooglePrompt[]; + } + + /** + * OAuth2Zoom + */ + export type OAuth2Zoom = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Zoom OAuth2 client ID. + */ + clientId: string; + /** + * Zoom OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Zoho + */ + export type OAuth2Zoho = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Zoho OAuth2 client ID. + */ + clientId: string; + /** + * Zoho OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Yandex + */ + export type OAuth2Yandex = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Yandex OAuth2 client ID. + */ + clientId: string; + /** + * Yandex OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2X + */ + export type OAuth2X = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * X OAuth2 customer key. + */ + customerKey: string; + /** + * X OAuth2 secret key. + */ + secretKey: string; + } + + /** + * OAuth2WordPress + */ + export type OAuth2WordPress = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * WordPress OAuth2 client ID. + */ + clientId: string; + /** + * WordPress OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Twitch + */ + export type OAuth2Twitch = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Twitch OAuth2 client ID. + */ + clientId: string; + /** + * Twitch OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Stripe + */ + export type OAuth2Stripe = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Stripe OAuth2 client ID. + */ + clientId: string; + /** + * Stripe OAuth2 API secret key. + */ + apiSecretKey: string; + } + + /** + * OAuth2Spotify + */ + export type OAuth2Spotify = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Spotify OAuth2 client ID. + */ + clientId: string; + /** + * Spotify OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Slack + */ + export type OAuth2Slack = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Slack OAuth2 client ID. + */ + clientId: string; + /** + * Slack OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Podio + */ + export type OAuth2Podio = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Podio OAuth2 client ID. + */ + clientId: string; + /** + * Podio OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Notion + */ + export type OAuth2Notion = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Notion OAuth2 client ID. + */ + oauthClientId: string; + /** + * Notion OAuth2 client secret. + */ + oauthClientSecret: string; + } + + /** + * OAuth2Salesforce + */ + export type OAuth2Salesforce = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Salesforce OAuth2 consumer key. + */ + customerKey: string; + /** + * Salesforce OAuth2 consumer secret. + */ + customerSecret: string; + } + + /** + * OAuth2Yahoo + */ + export type OAuth2Yahoo = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Yahoo OAuth2 client ID. + */ + clientId: string; + /** + * Yahoo OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Linkedin + */ + export type OAuth2Linkedin = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * LinkedIn OAuth2 client ID. + */ + clientId: string; + /** + * LinkedIn OAuth2 primary client secret. + */ + primaryClientSecret: string; + } + + /** + * OAuth2Disqus + */ + export type OAuth2Disqus = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Disqus OAuth2 public key. + */ + publicKey: string; + /** + * Disqus OAuth2 secret key. + */ + secretKey: string; + } + + /** + * OAuth2Amazon + */ + export type OAuth2Amazon = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Amazon OAuth2 client ID. + */ + clientId: string; + /** + * Amazon OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Etsy + */ + export type OAuth2Etsy = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Etsy OAuth2 keystring. + */ + keyString: string; + /** + * Etsy OAuth2 shared secret. + */ + sharedSecret: string; + } + + /** + * OAuth2Facebook + */ + export type OAuth2Facebook = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Facebook OAuth2 app ID. + */ + appId: string; + /** + * Facebook OAuth2 app secret. + */ + appSecret: string; + } + + /** + * OAuth2Tradeshift + */ + export type OAuth2Tradeshift = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Tradeshift OAuth2 client ID. + */ + oauth2ClientId: string; + /** + * Tradeshift OAuth2 client secret. + */ + oauth2ClientSecret: string; + } + + /** + * OAuth2Paypal + */ + export type OAuth2Paypal = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * PayPal OAuth2 client ID. + */ + clientId: string; + /** + * PayPal OAuth2 secret key. + */ + secretKey: string; + } + + /** + * OAuth2Gitlab + */ + export type OAuth2Gitlab = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * GitLab OAuth2 application ID. + */ + applicationId: string; + /** + * GitLab OAuth2 secret. + */ + secret: string; + /** + * GitLab OAuth2 endpoint URL. Defaults to https://gitlab.com for self-hosted instances. + */ + endpoint: string; + } + + /** + * OAuth2Authentik + */ + export type OAuth2Authentik = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Authentik OAuth2 client ID. + */ + clientId: string; + /** + * Authentik OAuth2 client secret. + */ + clientSecret: string; + /** + * Authentik OAuth2 endpoint domain. + */ + endpoint: string; + } + + /** + * OAuth2Auth0 + */ + export type OAuth2Auth0 = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Auth0 OAuth2 client ID. + */ + clientId: string; + /** + * Auth0 OAuth2 client secret. + */ + clientSecret: string; + /** + * Auth0 OAuth2 endpoint domain. + */ + endpoint: string; + } + + /** + * OAuth2FusionAuth + */ + export type OAuth2FusionAuth = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * FusionAuth OAuth2 client ID. + */ + clientId: string; + /** + * FusionAuth OAuth2 client secret. + */ + clientSecret: string; + /** + * FusionAuth OAuth2 endpoint domain. + */ + endpoint: string; + } + + /** + * OAuth2Keycloak + */ + export type OAuth2Keycloak = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Keycloak OAuth2 client ID. + */ + clientId: string; + /** + * Keycloak OAuth2 client secret. + */ + clientSecret: string; + /** + * Keycloak OAuth2 endpoint domain. + */ + endpoint: string; + /** + * Keycloak OAuth2 realm name. + */ + realmName: string; + } + + /** + * OAuth2Oidc + */ + export type OAuth2Oidc = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * OpenID Connect OAuth2 client ID. + */ + clientId: string; + /** + * OpenID Connect OAuth2 client secret. + */ + clientSecret: string; + /** + * OpenID Connect well-known configuration URL. When set, authorization, token, and user info endpoints can be discovered automatically. + */ + wellKnownURL: string; + /** + * OpenID Connect authorization endpoint URL. + */ + authorizationURL: string; + /** + * OpenID Connect token endpoint URL. + */ + tokenURL: string; + /** + * OpenID Connect user info endpoint URL. + */ + userInfoURL: string; + } + + /** + * OAuth2Okta + */ + export type OAuth2Okta = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Okta OAuth2 client ID. + */ + clientId: string; + /** + * Okta OAuth2 client secret. + */ + clientSecret: string; + /** + * Okta OAuth2 domain. + */ + domain: string; + /** + * Okta OAuth2 authorization server ID. + */ + authorizationServerId: string; + } + + /** + * OAuth2Kick + */ + export type OAuth2Kick = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Kick OAuth2 client ID. + */ + clientId: string; + /** + * Kick OAuth2 client secret. + */ + clientSecret: string; + } + + /** + * OAuth2Apple + */ + export type OAuth2Apple = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Apple OAuth2 service ID. + */ + serviceId: string; + /** + * Apple OAuth2 key ID. + */ + keyId: string; + /** + * Apple OAuth2 team ID. + */ + teamId: string; + /** + * Apple OAuth2 .p8 private key file contents. The secret key wrapped by the PEM markers is 200 characters long. + */ + p8File: string; + } + + /** + * OAuth2Microsoft + */ + export type OAuth2Microsoft = { + /** + * OAuth2 provider ID. + */ + $id: string; + /** + * OAuth2 provider is active and can be used to create sessions. + */ + enabled: boolean; + /** + * Microsoft OAuth2 application ID. + */ + applicationId: string; + /** + * Microsoft OAuth2 application secret. + */ + applicationSecret: string; + /** + * Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. + */ + tenant: string; + } + + /** + * OAuth2 Providers List + */ + export type OAuth2ProviderList = { + /** + * Total number of OAuth2 providers in the given project. + */ + total: number; + /** + * List of OAuth2 providers. + */ + providers: (Models.OAuth2Github | Models.OAuth2Discord | Models.OAuth2Figma | Models.OAuth2Dropbox | Models.OAuth2Dailymotion | Models.OAuth2Bitbucket | Models.OAuth2Bitly | Models.OAuth2Box | Models.OAuth2Autodesk | Models.OAuth2Google | Models.OAuth2Zoom | Models.OAuth2Zoho | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify | Models.OAuth2Slack | Models.OAuth2Podio | Models.OAuth2Notion | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon | Models.OAuth2Etsy | Models.OAuth2Facebook | Models.OAuth2Tradeshift | Models.OAuth2Paypal | Models.OAuth2Gitlab | Models.OAuth2Authentik | Models.OAuth2Auth0 | Models.OAuth2FusionAuth | Models.OAuth2Keycloak | Models.OAuth2Oidc | Models.OAuth2Apple | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft)[]; + } + + /** + * Policy Password Dictionary + */ + export type PolicyPasswordDictionary = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether password dictionary policy is enabled. + */ + enabled: boolean; + } + + /** + * Policy Password History + */ + export type PolicyPasswordHistory = { + /** + * Policy ID. + */ + $id: string; + /** + * Password history length. A value of 0 means the policy is disabled. + */ + total: number; + } + + /** + * Policy Password Personal Data + */ + export type PolicyPasswordPersonalData = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether password personal data policy is enabled. + */ + enabled: boolean; + } + + /** + * Policy Session Alert + */ + export type PolicySessionAlert = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether session alert policy is enabled. + */ + enabled: boolean; + } + + /** + * Policy Session Duration + */ + export type PolicySessionDuration = { + /** + * Policy ID. + */ + $id: string; + /** + * Session duration in seconds. + */ + duration: number; + } + + /** + * Policy Session Invalidation + */ + export type PolicySessionInvalidation = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether session invalidation policy is enabled. + */ + enabled: boolean; + } + + /** + * Policy Session Limit + */ + export type PolicySessionLimit = { + /** + * Policy ID. + */ + $id: string; + /** + * Maximum number of sessions allowed per user. A value of 0 means the policy is disabled. + */ + total: number; + } + + /** + * Policy User Limit + */ + export type PolicyUserLimit = { + /** + * Policy ID. + */ + $id: string; + /** + * Maximum number of users allowed in the project. A value of 0 means the policy is disabled. + */ + total: number; + } + + /** + * Policy Membership Privacy + */ + export type PolicyMembershipPrivacy = { + /** + * Policy ID. + */ + $id: string; + /** + * Whether user ID is visible in memberships. + */ + userId: boolean; + /** + * Whether user email is visible in memberships. + */ + userEmail: boolean; + /** + * Whether user phone is visible in memberships. + */ + userPhone: boolean; + /** + * Whether user name is visible in memberships. + */ + userName: boolean; + /** + * Whether user MFA status is visible in memberships. + */ + userMFA: boolean; + } + + /** + * Platform Web + */ + export type PlatformWeb = { + /** + * Platform ID. + */ + $id: string; + /** + * Platform creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Platform update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Platform name. + */ + name: string; + /** + * Platform type. Possible values are: windows, apple, android, linux, web. + */ + type: PlatformType; + /** + * Web app hostname. Empty string for other platforms. + */ + hostname: string; + } + + /** + * Platform Apple + */ + export type PlatformApple = { + /** + * Platform ID. + */ + $id: string; + /** + * Platform creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Platform update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Platform name. + */ + name: string; + /** + * Platform type. Possible values are: windows, apple, android, linux, web. + */ + type: PlatformType; + /** + * Apple bundle identifier. + */ + bundleIdentifier: string; + } + + /** + * Platform Android + */ + export type PlatformAndroid = { + /** + * Platform ID. + */ + $id: string; + /** + * Platform creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Platform update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Platform name. + */ + name: string; + /** + * Platform type. Possible values are: windows, apple, android, linux, web. + */ + type: PlatformType; + /** + * Android application ID. + */ + applicationId: string; + } + + /** + * Platform Windows + */ + export type PlatformWindows = { + /** + * Platform ID. + */ + $id: string; + /** + * Platform creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Platform update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Platform name. + */ + name: string; + /** + * Platform type. Possible values are: windows, apple, android, linux, web. + */ + type: PlatformType; + /** + * Windows package identifier name. + */ + packageIdentifierName: string; + } + + /** + * Platform Linux + */ + export type PlatformLinux = { + /** + * Platform ID. + */ + $id: string; + /** + * Platform creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Platform update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Platform name. + */ + name: string; + /** + * Platform type. Possible values are: windows, apple, android, linux, web. + */ + type: PlatformType; + /** + * Linux package name. + */ + packageName: string; + } + + /** + * Platforms List + */ + export type PlatformList = { + /** + * Total number of platforms in the given project. + */ + total: number; + /** + * List of platforms. + */ + platforms: (Models.PlatformWeb | Models.PlatformApple | Models.PlatformAndroid | Models.PlatformWindows | Models.PlatformLinux)[]; + } + + /** + * Variable + */ + export type Variable = { + /** + * Variable ID. + */ + $id: string; + /** + * Variable creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Variable creation date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Variable key. + */ + key: string; + /** + * Variable value. + */ + value: string; + /** + * Variable secret flag. Secret variables can only be updated or deleted, but never read. + */ + secret: boolean; + /** + * Service to which the variable belongs. Possible values are "project", "function" + */ + resourceType: string; + /** + * ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function. + */ + resourceId: string; + } + + /** + * Country + */ + export type Country = { + /** + * Country name. + */ + name: string; + /** + * Country two-character ISO 3166-1 alpha code. + */ + code: string; + } + + /** + * Continent + */ + export type Continent = { + /** + * Continent name. + */ + name: string; + /** + * Continent two letter code. + */ + code: string; + } + + /** + * Language + */ + export type Language = { + /** + * Language name. + */ + name: string; + /** + * Language two-character ISO 639-1 codes. + */ + code: string; + /** + * Language native name. + */ + nativeName: string; + } + + /** + * Currency + */ + export type Currency = { + /** + * Currency symbol. + */ + symbol: string; + /** + * Currency name. + */ + name: string; + /** + * Currency native symbol. + */ + symbolNative: string; + /** + * Number of decimal digits. + */ + decimalDigits: number; + /** + * Currency digit rounding. + */ + rounding: number; + /** + * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + */ + code: string; + /** + * Currency plural name + */ + namePlural: string; + } + + /** + * Phone + */ + export type Phone = { + /** + * Phone code. + */ + code: string; + /** + * Country two-character ISO 3166-1 alpha code. + */ + countryCode: string; + /** + * Country name. + */ + countryName: string; + } + + /** + * Health Antivirus + */ + export type HealthAntivirus = { + /** + * Antivirus version. + */ + version: string; + /** + * Antivirus status. Possible values are: `disabled`, `offline`, `online` + */ + status: HealthAntivirusStatus; + } + + /** + * Health Queue + */ + export type HealthQueue = { + /** + * Amount of actions in the queue. + */ + size: number; + } + + /** + * Health Status + */ + export type HealthStatus = { + /** + * Name of the service. + */ + name: string; + /** + * Duration in milliseconds how long the health check took. + */ + ping: number; + /** + * Service status. Possible values are: `pass`, `fail` + */ + status: HealthCheckStatus; + } + + /** + * Health Certificate + */ + export type HealthCertificate = { + /** + * Certificate name + */ + name: string; + /** + * Subject SN + */ + subjectSN: string; + /** + * Issuer organisation + */ + issuerOrganisation: string; + /** + * Valid from + */ + validFrom: string; + /** + * Valid to + */ + validTo: string; + /** + * Signature type SN + */ + signatureTypeSN: string; + } + + /** + * Health Time + */ + export type HealthTime = { + /** + * Current unix timestamp on trustful remote server. + */ + remoteTime: number; + /** + * Current unix timestamp of local server where Appwrite runs. + */ + localTime: number; + /** + * Difference of unix remote and local timestamps in milliseconds. + */ + diff: number; + } + + /** + * Headers + */ + export type Headers = { + /** + * Header name. + */ + name: string; + /** + * Header value. + */ + value: string; + } + + /** + * Specification + */ + export type Specification = { + /** + * Memory size in MB. + */ + memory: number; + /** + * Number of CPUs. + */ + cpus: number; + /** + * Is size enabled. + */ + enabled: boolean; + /** + * Size slug. + */ + slug: string; + } + + /** + * Rule + */ + export type ProxyRule = { + /** + * Rule ID. + */ + $id: string; + /** + * Rule creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * Rule update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Domain name. + */ + domain: string; + /** + * Action definition for the rule. Possible values are "api", "deployment", or "redirect" + */ + type: string; + /** + * Defines how the rule was created. Possible values are "manual" or "deployment" + */ + trigger: string; + /** + * URL to redirect to. Used if type is "redirect" + */ + redirectUrl: string; + /** + * Status code to apply during redirect. Used if type is "redirect" + */ + redirectStatusCode: number; + /** + * ID of deployment. Used if type is "deployment" + */ + deploymentId: string; + /** + * Type of deployment. Possible values are "function", "site". Used if rule's type is "deployment". + */ + deploymentResourceType?: ProxyRuleDeploymentResourceType; + /** + * ID of deployment's resource (site or function ID). Used if type is "deployment" + */ + deploymentResourceId: string; + /** + * Name of Git branch that updates rule. Used if type is "deployment" + */ + deploymentVcsProviderBranch: string; + /** + * Domain verification status. Possible values are "unverified", "verifying", "verified" + */ + status: ProxyRuleStatus; + /** + * Logs from rule verification or certificate generation. Certificate generation logs are prioritized if both are available. + */ + logs: string; + /** + * Certificate auto-renewal date in ISO 8601 format. + */ + renewAt: string; + } + + /** + * EmailTemplate + */ + export type EmailTemplate = { + /** + * Template type + */ + templateId: string; + /** + * Template locale + */ + locale: string; + /** + * Template message + */ + message: string; + /** + * Name of the sender + */ + senderName: string; + /** + * Email of the sender + */ + senderEmail: string; + /** + * Reply to email address + */ + replyToEmail: string; + /** + * Reply to name + */ + replyToName: string; + /** + * Email subject + */ + subject: string; + } + + /** + * MFA Challenge + */ + export type MfaChallenge = { + /** + * Token ID. + */ + $id: string; + /** + * Token creation date in ISO 8601 format. + */ + $createdAt: string; + /** + * User ID. + */ + userId: string; + /** + * Token expiration date in ISO 8601 format. + */ + expire: string; + } + + /** + * MFA Recovery Codes + */ + export type MfaRecoveryCodes = { + /** + * Recovery codes. + */ + recoveryCodes: string[]; + } + + /** + * MFAType + */ + export type MfaType = { + /** + * Secret token used for TOTP factor. + */ + secret: string; + /** + * URI for authenticator apps. + */ + uri: string; + } + + /** + * MFAFactors + */ + export type MfaFactors = { + /** + * Can TOTP be used for MFA challenge for this account. + */ + totp: boolean; + /** + * Can phone (SMS) be used for MFA challenge for this account. + */ + phone: boolean; + /** + * Can email be used for MFA challenge for this account. + */ + email: boolean; + /** + * Can recovery code be used for MFA challenge for this account. + */ + recoveryCode: boolean; + } + + /** + * Provider + */ + export type Provider = { + /** + * Provider ID. + */ + $id: string; + /** + * Provider creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Provider update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * The name for the provider instance. + */ + name: string; + /** + * The name of the provider service. */ provider: string; /** - * Session Provider User ID. + * Is provider enabled? */ - providerUid: string; + enabled: boolean; /** - * Session Provider Access Token. + * Type of provider. */ - providerAccessToken: string; + type: string; /** - * The date of when the access token expires in ISO 8601 format. + * Provider credentials. */ - providerAccessTokenExpiry: string; + credentials: object; /** - * Session Provider Refresh Token. + * Provider options. */ - providerRefreshToken: string; + options?: object; + } + + /** + * Message + */ + export type Message = { /** - * IP in use when the session was created. + * Message ID. */ - ip: string; + $id: string; /** - * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). + * Message creation time in ISO 8601 format. */ - osCode: string; + $createdAt: string; /** - * Operating system name. + * Message update date in ISO 8601 format. */ - osName: string; + $updatedAt: string; /** - * Operating system version. + * Message provider type. */ - osVersion: string; + providerType: string; /** - * Client type. + * Topic IDs set as recipients. */ - clientType: string; + topics: string[]; /** - * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). + * User IDs set as recipients. */ - clientCode: string; + users: string[]; /** - * Client name. + * Target IDs set as recipients. */ - clientName: string; + targets: string[]; /** - * Client version. + * The scheduled time for message. */ - clientVersion: string; + scheduledAt?: string; /** - * Client engine name. + * The time when the message was delivered. */ - clientEngine: string; + deliveredAt?: string; /** - * Client engine name. + * Delivery errors if any. */ - clientEngineVersion: string; + deliveryErrors?: string[]; + /** + * Number of recipients the message was delivered to. + */ + deliveredTotal: number; + /** + * Data of the message. + */ + data: object; + /** + * Status of delivery. + */ + status: MessageStatus; + } + + /** + * Topic + */ + export type Topic = { + /** + * Topic ID. + */ + $id: string; + /** + * Topic creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Topic update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * The name of the topic. + */ + name: string; + /** + * Total count of email subscribers subscribed to the topic. + */ + emailTotal: number; + /** + * Total count of SMS subscribers subscribed to the topic. + */ + smsTotal: number; + /** + * Total count of push subscribers subscribed to the topic. + */ + pushTotal: number; + /** + * Subscribe permissions. + */ + subscribe: string[]; + } + + /** + * Transaction + */ + export type Transaction = { + /** + * Transaction ID. + */ + $id: string; + /** + * Transaction creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Transaction update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + */ + status: string; + /** + * Number of operations in the transaction. + */ + operations: number; + /** + * Expiration time in ISO 8601 format. + */ + expiresAt: string; + } + + /** + * Subscriber + */ + export type Subscriber = { + /** + * Subscriber ID. + */ + $id: string; + /** + * Subscriber creation time in ISO 8601 format. + */ + $createdAt: string; + /** + * Subscriber update date in ISO 8601 format. + */ + $updatedAt: string; + /** + * Target ID. + */ + targetId: string; + /** + * Target. + */ + target: Target; + /** + * Topic ID. + */ + userId: string; + /** + * User Name. + */ + userName: string; + /** + * Topic ID. + */ + topicId: string; + /** + * The target provider type. Can be one of the following: `email`, `sms` or `push`. + */ + providerType: string; + } + + /** + * Target + */ + export type Target = { /** - * Device name. + * Target ID. */ - deviceName: string; + $id: string; /** - * Device brand name. + * Target creation time in ISO 8601 format. */ - deviceBrand: string; + $createdAt: string; /** - * Device model name. + * Target update date in ISO 8601 format. */ - deviceModel: string; + $updatedAt: string; /** - * Country two-character ISO 3166-1 alpha code. + * Target Name. */ - countryCode: string; + name: string; /** - * Country name. + * User ID. */ - countryName: string; + userId: string; /** - * Returns true if this the current user session. + * Provider ID. */ - current: boolean; + providerId?: string; /** - * Returns a list of active session factors. + * The target provider type. Can be one of the following: `email`, `sms` or `push`. */ - factors: string[]; + providerType: string; /** - * Secret used to authenticate the user. Only included if the request was made with an API key + * The target identifier. */ - secret: string; + identifier: string; /** - * Most recent date in ISO 8601 format when the session successfully passed MFA challenge. + * Is the target expired. */ - mfaUpdatedAt: string; + expired: boolean; } /** - * Identity + * Insight */ - export type Identity = { + export type Insight = { /** - * Identity ID. + * Insight ID. */ $id: string; /** - * Identity creation date in ISO 8601 format. + * Insight creation date in ISO 8601 format. */ $createdAt: string; /** - * Identity update date in ISO 8601 format. + * Insight update date in ISO 8601 format. */ $updatedAt: string; /** - * User ID. + * Parent report ID. Insights always belong to a report. */ - userId: string; + reportId: string; /** - * Identity Provider. + * Insight type. One of databaseIndex (legacy), tablesDBIndex, documentsDBIndex, vectorsDBIndex, databasePerformance, sitePerformance, siteAccessibility, siteSeo, functionPerformance. The index types are engine-specific so each CTA can pair the right service+method (databases.createIndex, tablesDB.createIndex, documentsDB.createIndex, or vectorsDB.createIndex). */ - provider: string; + type: string; /** - * ID of the User in the Identity Provider. + * Insight severity. One of info, warning, critical. */ - providerUid: string; + severity: string; /** - * Email of the User in the Identity Provider. + * Insight status. One of active, dismissed. */ - providerEmail: string; + status: string; /** - * Identity Provider Access Token. + * Type of the resource the insight is about. Plural noun, e.g. databases, sites, functions. */ - providerAccessToken: string; + resourceType: string; /** - * The date of when the access token expires in ISO 8601 format. + * ID of the resource the insight is about. */ - providerAccessTokenExpiry: string; + resourceId: string; /** - * Identity Provider Refresh Token. + * Plural noun for the parent resource that contains the insight's resource, e.g. an insight about a column index on a table → resourceType=indexes, parentResourceType=tables. Empty when the resource has no parent. */ - providerRefreshToken: string; - } - - /** - * Token - */ - export type Token = { + parentResourceType: string; /** - * Token ID. + * ID of the parent resource. Empty when the resource has no parent. */ - $id: string; + parentResourceId: string; /** - * Token creation date in ISO 8601 format. + * Insight title. */ - $createdAt: string; + title: string; /** - * User ID. + * Short markdown summary describing the insight. */ - userId: string; + summary: string; /** - * Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * List of call-to-action buttons attached to this insight. */ - secret: string; + ctas: InsightCTA[]; /** - * Token expiration date in ISO 8601 format. + * Time the insight was analyzed in ISO 8601 format. */ - expire: string; + analyzedAt?: string; /** - * Security phrase of a token. Empty if security phrase was not requested when creating a token. It includes randomly generated phrase which is also sent in the external resource such as email. + * Time the insight was dismissed in ISO 8601 format. Empty when not dismissed. */ - phrase: string; + dismissedAt?: string; + /** + * User ID that dismissed the insight. Empty when not dismissed. + */ + dismissedBy?: string; } /** - * JWT + * InsightCTA */ - export type Jwt = { + export type InsightCTA = { /** - * JWT encoded string. + * Human-readable label for the CTA, used in UI. */ - jwt: string; + label: string; + /** + * Public API service (SDK namespace) the client should invoke. Must match the engine that owns the resource — for index suggestions: databases (legacy), tablesDB, documentsDB, or vectorsDB. + */ + service: string; + /** + * Public API method on the chosen service the client should invoke when this CTA is triggered. + */ + method: string; + /** + * Parameter map the client should pass to the service method when this CTA is triggered. Keys match the target API's parameter names (e.g. databaseId/tableId/columns for tablesDB, databaseId/collectionId/attributes for the legacy Databases API). + */ + params: object; } /** - * Locale + * Report */ - export type Locale = { + export type Report = { /** - * User IP address. + * Report ID. */ - ip: string; + $id: string; /** - * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format + * Report creation date in ISO 8601 format. */ - countryCode: string; + $createdAt: string; /** - * Country name. This field support localization. + * Report update date in ISO 8601 format. */ - country: string; + $updatedAt: string; /** - * Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America. + * ID of the third-party app that submitted the report. */ - continentCode: string; + appId: string; /** - * Continent name. This field support localization. + * Analyzer that produced this report. e.g. lighthouse, audit, databaseAnalyzer. */ - continent: string; + type: string; /** - * True if country is part of the European Union. + * Short, human-readable title for the report. */ - eu: boolean; + title: string; /** - * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format + * Markdown summary describing the report. */ - currency: string; - } - - /** - * LocaleCode - */ - export type LocaleCode = { + summary: string; /** - * Locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) + * Plural noun describing what the report analyzes, e.g. databases, sites, urls. */ - code: string; + targetType: string; /** - * Locale name + * Free-form target identifier (URL for lighthouse, resource ID for db). */ - name: string; + target: string; + /** + * Categories covered by the report, e.g. performance, accessibility. + */ + categories: string[]; + /** + * Insights nested under this report. + */ + insights: Insight[]; + /** + * Time the report was analyzed in ISO 8601 format. + */ + analyzedAt?: string; } /** - * File + * ActivityEvent */ - export type File = { + export type ActivityEvent = { /** - * File ID. + * Event ID. */ $id: string; /** - * Bucket ID. - */ - bucketId: string; - /** - * File creation date in ISO 8601 format. - */ - $createdAt: string; - /** - * File update date in ISO 8601 format. + * User type. */ - $updatedAt: string; + userType: string; /** - * File permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * User ID. */ - $permissions: string[]; + userId: string; /** - * File name. + * User Email. */ - name: string; + userEmail: string; /** - * File MD5 signature. + * User Name. */ - signature: string; + userName: string; /** - * File mime type. + * Resource parent. */ - mimeType: string; + resourceParent: string; /** - * File original size in bytes. + * Resource type. */ - sizeOriginal: number; + resourceType: string; /** - * File actual stored size in bytes after compression and/or encryption. + * Resource ID. */ - sizeActual: number; + resourceId: string; /** - * Total number of chunks available + * Resource. */ - chunksTotal: number; + resource: string; /** - * Total number of chunks uploaded + * Event name. */ - chunksUploaded: number; + event: string; /** - * Whether file contents are encrypted at rest. + * User agent. */ - encryption: boolean; + userAgent: string; /** - * Compression algorithm used for the file. Will be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd). + * IP address. */ - compression: string; - } - - /** - * Team - */ - export type Team<Preferences extends Models.Preferences = Models.DefaultPreferences> = { + ip: string; /** - * Team ID. + * API mode when event triggered. */ - $id: string; + mode: string; /** - * Team creation date in ISO 8601 format. + * Location. */ - $createdAt: string; + country: string; /** - * Team update date in ISO 8601 format. + * Log creation date in ISO 8601 format. */ - $updatedAt: string; + time: string; /** - * Team name. + * Project ID. */ - name: string; + projectId: string; /** - * Total number of team members. + * Team ID. */ - total: number; + teamId: string; /** - * Team preferences as a key-value object + * Hostname. */ - prefs: Preferences; - } - - /** - * Membership - */ - export type Membership = { + hostname: string; /** - * Membership ID. + * Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). */ - $id: string; + osCode: string; /** - * Membership creation date in ISO 8601 format. + * Operating system name. */ - $createdAt: string; + osName: string; /** - * Membership update date in ISO 8601 format. + * Operating system version. */ - $updatedAt: string; + osVersion: string; /** - * User ID. + * Client type. */ - userId: string; + clientType: string; /** - * User name. Hide this attribute by toggling membership privacy in the Console. + * Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json). */ - userName: string; + clientCode: string; /** - * User email address. Hide this attribute by toggling membership privacy in the Console. + * Client name. */ - userEmail: string; + clientName: string; /** - * User phone number. Hide this attribute by toggling membership privacy in the Console. + * Client version. */ - userPhone: string; + clientVersion: string; /** - * Team ID. + * Client engine name. */ - teamId: string; + clientEngine: string; /** - * Team name. + * Client engine name. */ - teamName: string; + clientEngineVersion: string; /** - * Date, the user has been invited to join the team in ISO 8601 format. + * Device name. */ - invited: string; + deviceName: string; /** - * Date, the user has accepted the invitation to join the team in ISO 8601 format. + * Device brand name. */ - joined: string; + deviceBrand: string; /** - * User confirmation status, true if the user has joined the team or false otherwise. + * Device model name. */ - confirm: boolean; + deviceModel: string; /** - * Multi factor authentication status, true if the user has MFA enabled or false otherwise. Hide this attribute by toggling membership privacy in the Console. + * Country two-character ISO 3166-1 alpha code. */ - mfa: boolean; + countryCode: string; /** - * User list of roles + * Country name. */ - roles: string[]; + countryName: string; } /** - * Execution + * Archive */ - export type Execution = { + export type BackupArchive = { /** - * Execution ID. + * Archive ID. */ $id: string; /** - * Execution creation date in ISO 8601 format. + * Archive creation time in ISO 8601 format. */ $createdAt: string; /** - * Execution update date in ISO 8601 format. + * Archive update date in ISO 8601 format. */ $updatedAt: string; /** - * Execution roles. + * Archive policy ID. */ - $permissions: string[]; + policyId: string; /** - * Function ID. + * Archive size in bytes. */ - functionId: string; + size: number; /** - * Function's deployment ID used to create the execution. + * The status of the archive creation. Possible values: pending, processing, uploading, completed, failed, skipped. */ - deploymentId: string; + status: string; /** - * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`. + * The backup start time. */ - trigger: ExecutionTrigger; + startedAt: string; /** - * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. + * Migration ID. */ - status: ExecutionStatus; + migrationId: string; /** - * HTTP request method type. + * The services that are backed up by this archive. */ - requestMethod: string; + services: string[]; /** - * HTTP request path and query. + * The resources that are backed up by this archive. */ - requestPath: string; + resources: string[]; /** - * HTTP request headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + * The resource ID to backup. Set only if this archive should backup a single resource. */ - requestHeaders: Headers[]; + resourceId?: string; /** - * HTTP response status code. + * The resource type to backup. Set only if this archive should backup a single resource. */ - responseStatusCode: number; + resourceType?: string; + } + + /** + * BillingLimits + */ + export type BillingLimits = { /** - * HTTP response body. This will return empty unless execution is created as synchronous. + * Bandwidth limit */ - responseBody: string; + bandwidth: number; /** - * HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous. + * Storage limit */ - responseHeaders: Headers[]; + storage: number; /** - * Function logs. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Users limit */ - logs: string; + users: number; /** - * Function errors. Includes the last 4,000 characters. This will return an empty string unless the response is returned using an API key or as part of a webhook payload. + * Executions limit */ - errors: string; + executions: number; /** - * Resource(function/site) execution duration in seconds. + * GBHours limit */ - duration: number; + GBHours: number; /** - * The scheduled time for execution. If left empty, execution will be queued immediately. + * Image transformations limit */ - scheduledAt?: string; - } - - /** - * Country - */ - export type Country = { + imageTransformations: number; /** - * Country name. + * Auth phone limit */ - name: string; + authPhone: number; /** - * Country two-character ISO 3166-1 alpha code. + * Budget limit percentage */ - code: string; + budgetLimit: number; } /** - * Continent + * Block */ - export type Continent = { + export type Block = { /** - * Continent name. + * Block creation date in ISO 8601 format. */ - name: string; + $createdAt: string; /** - * Continent two letter code. + * Resource type that is blocked */ - code: string; - } - - /** - * Language - */ - export type Language = { + resourceType: string; /** - * Language name. + * Resource identifier that is blocked */ - name: string; + resourceId: string; /** - * Language two-character ISO 639-1 codes. + * Reason for the block. Can be null if no reason was provided. */ - code: string; + reason?: string; /** - * Language native name. + * Block expiration date in ISO 8601 format. Can be null if the block does not expire. */ - nativeName: string; + expiredAt?: string; + /** + * Name of the project this block applies to. + */ + projectName: string; + /** + * Region of the project this block applies to. + */ + region: string; + /** + * Name of the organization that owns the project. + */ + organizationName: string; + /** + * ID of the organization that owns the project. + */ + organizationId: string; + /** + * Billing plan of the organization that owns the project. + */ + billingPlan: string; } /** - * Currency + * backup */ - export type Currency = { + export type BackupPolicy = { /** - * Currency symbol. + * Backup policy ID. */ - symbol: string; + $id: string; /** - * Currency name. + * Backup policy name. */ name: string; /** - * Currency native symbol. - */ - symbolNative: string; - /** - * Number of decimal digits. + * Policy creation date in ISO 8601 format. */ - decimalDigits: number; + $createdAt: string; /** - * Currency digit rounding. + * Policy update date in ISO 8601 format. */ - rounding: number; + $updatedAt: string; /** - * Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format. + * The services that are backed up by this policy. */ - code: string; + services: string[]; /** - * Currency plural name + * The resources that are backed up by this policy. */ - namePlural: string; - } - - /** - * Phone - */ - export type Phone = { + resources: string[]; /** - * Phone code. + * The resource ID to backup. Set only if this policy should backup a single resource. */ - code: string; + resourceId?: string; /** - * Country two-character ISO 3166-1 alpha code. + * The resource type to backup. Set only if this policy should backup a single resource. */ - countryCode: string; + resourceType?: string; /** - * Country name. + * How many days to keep the backup before it will be automatically deleted. */ - countryName: string; - } - - /** - * Headers - */ - export type Headers = { + retention: number; /** - * Header name. + * Policy backup schedule in CRON format. */ - name: string; + schedule: string; /** - * Header value. + * Is this policy enabled. */ - value: string; + enabled: boolean; } /** - * MFA Challenge + * Restoration */ - export type MfaChallenge = { + export type BackupRestoration = { /** - * Token ID. + * Restoration ID. */ $id: string; /** - * Token creation date in ISO 8601 format. + * Restoration creation time in ISO 8601 format. */ $createdAt: string; /** - * User ID. + * Restoration update date in ISO 8601 format. */ - userId: string; + $updatedAt: string; /** - * Token expiration date in ISO 8601 format. + * Backup archive ID. */ - expire: string; - } - - /** - * MFA Recovery Codes - */ - export type MfaRecoveryCodes = { + archiveId: string; /** - * Recovery codes. + * Backup policy ID. */ - recoveryCodes: string[]; - } - - /** - * MFAType - */ - export type MfaType = { + policyId: string; /** - * Secret token used for TOTP factor. + * The status of the restoration. Possible values: pending, downloading, processing, completed, failed. */ - secret: string; + status: string; /** - * URI for authenticator apps. + * The backup start time. */ - uri: string; - } - - /** - * MFAFactors - */ - export type MfaFactors = { + startedAt: string; /** - * Can TOTP be used for MFA challenge for this account. + * Migration ID. */ - totp: boolean; + migrationId: string; /** - * Can phone (SMS) be used for MFA challenge for this account. + * The services that are backed up by this policy. */ - phone: boolean; + services: string[]; /** - * Can email be used for MFA challenge for this account. + * The resources that are backed up by this policy. */ - email: boolean; + resources: string[]; /** - * Can recovery code be used for MFA challenge for this account. + * Optional data in key-value object. */ - recoveryCode: boolean; + options: string; } /** - * Transaction + * usageEvent */ - export type Transaction = { + export type UsageEvent = { /** - * Transaction ID. + * The metric key. */ - $id: string; + metric: string; /** - * Transaction creation time in ISO 8601 format. + * The metric value. */ - $createdAt: string; + value: number; /** - * Transaction update date in ISO 8601 format. + * The event timestamp. */ - $updatedAt: string; + time: string; /** - * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + * The API endpoint path. */ - status: string; + path: string; /** - * Number of operations in the transaction. + * The HTTP method. */ - operations: number; + method: string; /** - * Expiration time in ISO 8601 format. + * HTTP status code. Stored as string to preserve unset state (empty string = not available). */ - expiresAt: string; - } - - /** - * Subscriber - */ - export type Subscriber = { + status: string; /** - * Subscriber ID. + * The resource type. */ - $id: string; + resourceType: string; /** - * Subscriber creation time in ISO 8601 format. + * The resource ID. */ - $createdAt: string; + resourceId: string; /** - * Subscriber update date in ISO 8601 format. + * Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format. */ - $updatedAt: string; + countryCode: string; /** - * Target ID. + * The user agent string. */ - targetId: string; + userAgent: string; + } + + /** + * Usage events list + */ + export type UsageEventList = { /** - * Target. + * Total number of events that matched your query. */ - target: Target; + total: number; /** - * Topic ID. + * List of events. */ - userId: string; + events: UsageEvent[]; + } + + /** + * usageGauge + */ + export type UsageGauge = { /** - * User Name. + * The metric key. */ - userName: string; + metric: string; /** - * Topic ID. + * The current snapshot value. */ - topicId: string; + value: number; /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. + * The snapshot timestamp. */ - providerType: string; + time: string; } /** - * Target + * Usage gauges list */ - export type Target = { + export type UsageGaugeList = { /** - * Target ID. + * Total number of gauges that matched your query. */ - $id: string; + total: number; /** - * Target creation time in ISO 8601 format. + * List of gauges. */ - $createdAt: string; + gauges: UsageGauge[]; + } + + /** + * Activity event list + */ + export type ActivityEventList = { /** - * Target update date in ISO 8601 format. + * Total number of events that matched your query. */ - $updatedAt: string; + total: number; /** - * Target Name. + * List of events. */ - name: string; + events: ActivityEvent[]; + } + + /** + * Backup archive list + */ + export type BackupArchiveList = { /** - * User ID. + * Total number of archives that matched your query. */ - userId: string; + total: number; /** - * Provider ID. + * List of archives. */ - providerId?: string; + archives: BackupArchive[]; + } + + /** + * Backup policy list + */ + export type BackupPolicyList = { /** - * The target provider type. Can be one of the following: `email`, `sms` or `push`. + * Total number of policies that matched your query. */ - providerType: string; + total: number; /** - * The target identifier. + * List of policies. */ - identifier: string; + policies: BackupPolicy[]; + } + + /** + * Backup restoration list + */ + export type BackupRestorationList = { /** - * Is the target expired. + * Total number of restorations that matched your query. */ - expired: boolean; + total: number; + /** + * List of restorations. + */ + restorations: BackupRestoration[]; } } diff --git a/src/services/account.ts b/src/services/account.ts index 5a3f7926..2ef0d393 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,15 +1,25 @@ import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload } from '../client'; import type { Models } from '../models'; import { AuthenticatorType } from '../enums/authenticator-type'; import { AuthenticationFactor } from '../enums/authentication-factor'; import { OAuthProvider } from '../enums/o-auth-provider'; -export class Account { - client: Client; +type AccountServerOnlyMethod = never; +type AccountClientOnlyMethod = never; - constructor(client: Client) { +export type Account<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<AccountRuntime<TAuth>, 'client' | AccountServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<AccountRuntime<TAuth>, 'client' | AccountClientOnlyMethod> + : Omit<AccountRuntime<TAuth>, 'client'>; + +class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } @@ -519,58 +529,6 @@ export class Account { ); } - /** - * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. - * - * @param {AuthenticatorType} params.type - Type of authenticator. Must be `totp` - * @throws {AppwriteException} - * @returns {Promise<Models.MfaType>} - */ - createMFAAuthenticator(params: { type: AuthenticatorType }): Promise<Models.MfaType>; - /** - * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. - * - * @param {AuthenticatorType} type - Type of authenticator. Must be `totp` - * @throws {AppwriteException} - * @returns {Promise<Models.MfaType>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createMFAAuthenticator(type: AuthenticatorType): Promise<Models.MfaType>; - createMFAAuthenticator( - paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType - ): Promise<Models.MfaType> { - let params: { type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { type: AuthenticatorType }; - } else { - params = { - type: paramsOrFirst as AuthenticatorType - }; - } - - const type = params.type; - - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); - } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); - } - /** * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -635,69 +593,6 @@ export class Account { ); } - /** - * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. - * - * @param {AuthenticatorType} params.type - Type of authenticator. - * @param {string} params.otp - Valid verification token. - * @throws {AppwriteException} - * @returns {Promise<Models.User<Preferences>>} - */ - updateMFAAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { type: AuthenticatorType, otp: string }): Promise<Models.User<Preferences>>; - /** - * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. - * - * @param {AuthenticatorType} type - Type of authenticator. - * @param {string} otp - Valid verification token. - * @throws {AppwriteException} - * @returns {Promise<Models.User<Preferences>>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateMFAAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>>; - updateMFAAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>( - paramsOrFirst: { type: AuthenticatorType, otp: string } | AuthenticatorType, - ...rest: [(string)?] - ): Promise<Models.User<Preferences>> { - let params: { type: AuthenticatorType, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string }; - } else { - params = { - type: paramsOrFirst as AuthenticatorType, - otp: rest[0] as string - }; - } - - const type = params.type; - const otp = params.otp; - - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); - } - if (typeof otp === 'undefined') { - throw new AppwriteException('Missing required parameter: "otp"'); - } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); - const payload: Payload = {}; - if (typeof otp !== 'undefined') { - payload['otp'] = otp; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); - } - /** * Delete an authenticator for a user by ID. * @@ -751,58 +646,6 @@ export class Account { ); } - /** - * Delete an authenticator for a user by ID. - * - * @param {AuthenticatorType} params.type - Type of authenticator. - * @throws {AppwriteException} - * @returns {Promise<{}>} - */ - deleteMFAAuthenticator(params: { type: AuthenticatorType }): Promise<{}>; - /** - * Delete an authenticator for a user by ID. - * - * @param {AuthenticatorType} type - Type of authenticator. - * @throws {AppwriteException} - * @returns {Promise<{}>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - deleteMFAAuthenticator(type: AuthenticatorType): Promise<{}>; - deleteMFAAuthenticator( - paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType - ): Promise<{}> { - let params: { type: AuthenticatorType }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { type: AuthenticatorType }; - } else { - params = { - type: paramsOrFirst as AuthenticatorType - }; - } - - const type = params.type; - - if (typeof type === 'undefined') { - throw new AppwriteException('Missing required parameter: "type"'); - } - - const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'delete', - uri, - apiHeaders, - payload - ); - } - /** * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * @@ -859,61 +702,6 @@ export class Account { ); } - /** - * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. - * - * @param {AuthenticationFactor} params.factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. - * @throws {AppwriteException} - * @returns {Promise<Models.MfaChallenge>} - */ - createMFAChallenge(params: { factor: AuthenticationFactor }): Promise<Models.MfaChallenge>; - /** - * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. - * - * @param {AuthenticationFactor} factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. - * @throws {AppwriteException} - * @returns {Promise<Models.MfaChallenge>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createMFAChallenge(factor: AuthenticationFactor): Promise<Models.MfaChallenge>; - createMFAChallenge( - paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor - ): Promise<Models.MfaChallenge> { - let params: { factor: AuthenticationFactor }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) { - params = (paramsOrFirst || {}) as { factor: AuthenticationFactor }; - } else { - params = { - factor: paramsOrFirst as AuthenticationFactor - }; - } - - const factor = params.factor; - - if (typeof factor === 'undefined') { - throw new AppwriteException('Missing required parameter: "factor"'); - } - - const apiPath = '/account/mfa/challenges'; - const payload: Payload = {}; - if (typeof factor !== 'undefined') { - payload['factor'] = factor; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); - } - /** * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -981,72 +769,6 @@ export class Account { ); } - /** - * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. - * - * @param {string} params.challengeId - ID of the challenge. - * @param {string} params.otp - Valid verification token. - * @throws {AppwriteException} - * @returns {Promise<Models.Session>} - */ - updateMFAChallenge(params: { challengeId: string, otp: string }): Promise<Models.Session>; - /** - * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. - * - * @param {string} challengeId - ID of the challenge. - * @param {string} otp - Valid verification token. - * @throws {AppwriteException} - * @returns {Promise<Models.Session>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateMFAChallenge(challengeId: string, otp: string): Promise<Models.Session>; - updateMFAChallenge( - paramsOrFirst: { challengeId: string, otp: string } | string, - ...rest: [(string)?] - ): Promise<Models.Session> { - let params: { challengeId: string, otp: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { challengeId: string, otp: string }; - } else { - params = { - challengeId: paramsOrFirst as string, - otp: rest[0] as string - }; - } - - const challengeId = params.challengeId; - const otp = params.otp; - - if (typeof challengeId === 'undefined') { - throw new AppwriteException('Missing required parameter: "challengeId"'); - } - if (typeof otp === 'undefined') { - throw new AppwriteException('Missing required parameter: "otp"'); - } - - const apiPath = '/account/mfa/challenges'; - const payload: Payload = {}; - if (typeof challengeId !== 'undefined') { - payload['challengeId'] = challengeId; - } - if (typeof otp !== 'undefined') { - payload['otp'] = otp; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); - } - /** * List the factors available on the account to be used as a MFA challange. * @@ -1071,29 +793,6 @@ export class Account { ); } - /** - * List the factors available on the account to be used as a MFA challange. - * - * @throws {AppwriteException} - * @returns {Promise<Models.MfaFactors>} - */ - listMFAFactors(): Promise<Models.MfaFactors> { - - const apiPath = '/account/mfa/factors'; - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); - } - /** * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. * @@ -1118,29 +817,6 @@ export class Account { ); } - /** - * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. - * - * @throws {AppwriteException} - * @returns {Promise<Models.MfaRecoveryCodes>} - */ - getMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { - - const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - } - - return this.client.call( - 'get', - uri, - apiHeaders, - payload - ); - } - /** * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -1166,30 +842,6 @@ export class Account { ); } - /** - * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. - * - * @throws {AppwriteException} - * @returns {Promise<Models.MfaRecoveryCodes>} - */ - createMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { - - const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); - } - /** * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. * @@ -1215,30 +867,6 @@ export class Account { ); } - /** - * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. - * - * @throws {AppwriteException} - * @returns {Promise<Models.MfaRecoveryCodes>} - */ - updateMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { - - const apiPath = '/account/mfa/recovery-codes'; - const payload: Payload = {}; - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'patch', - uri, - apiHeaders, - payload - ); - } - /** * Update currently logged in user account name. * @@ -1930,7 +1558,7 @@ export class Account { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -2682,7 +2310,7 @@ export class Account { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -2827,68 +2455,6 @@ export class Account { ); } - /** - * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - * - * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - * - * - * @param {string} params.url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. - * @throws {AppwriteException} - * @returns {Promise<Models.Token>} - * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead. - */ - createVerification(params: { url: string }): Promise<Models.Token>; - /** - * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. - * - * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. - * - * - * @param {string} url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. - * @throws {AppwriteException} - * @returns {Promise<Models.Token>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - createVerification(url: string): Promise<Models.Token>; - createVerification( - paramsOrFirst: { url: string } | string - ): Promise<Models.Token> { - let params: { url: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { url: string }; - } else { - params = { - url: paramsOrFirst as string - }; - } - - const url = params.url; - - if (typeof url === 'undefined') { - throw new AppwriteException('Missing required parameter: "url"'); - } - - const apiPath = '/account/verifications/email'; - const payload: Payload = {}; - if (typeof url !== 'undefined') { - payload['url'] = url; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'post', - uri, - apiHeaders, - payload - ); - } - /** * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. * @@ -2955,73 +2521,6 @@ export class Account { ); } - /** - * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. - * - * @param {string} params.userId - User ID. - * @param {string} params.secret - Valid verification token. - * @throws {AppwriteException} - * @returns {Promise<Models.Token>} - * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead. - */ - updateVerification(params: { userId: string, secret: string }): Promise<Models.Token>; - /** - * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. - * - * @param {string} userId - User ID. - * @param {string} secret - Valid verification token. - * @throws {AppwriteException} - * @returns {Promise<Models.Token>} - * @deprecated Use the object parameter style method for a better developer experience. - */ - updateVerification(userId: string, secret: string): Promise<Models.Token>; - updateVerification( - paramsOrFirst: { userId: string, secret: string } | string, - ...rest: [(string)?] - ): Promise<Models.Token> { - let params: { userId: string, secret: string }; - - if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { userId: string, secret: string }; - } else { - params = { - userId: paramsOrFirst as string, - secret: rest[0] as string - }; - } - - const userId = params.userId; - const secret = params.secret; - - if (typeof userId === 'undefined') { - throw new AppwriteException('Missing required parameter: "userId"'); - } - if (typeof secret === 'undefined') { - throw new AppwriteException('Missing required parameter: "secret"'); - } - - const apiPath = '/account/verifications/email'; - const payload: Payload = {}; - if (typeof userId !== 'undefined') { - payload['userId'] = userId; - } - if (typeof secret !== 'undefined') { - payload['secret'] = secret; - } - const uri = new URL(this.client.config.endpoint + apiPath); - - const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', - } - - return this.client.call( - 'put', - uri, - apiHeaders, - payload - ); - } - /** * Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. * @@ -3112,3 +2611,9 @@ export class Account { ); } } + +const Account = AccountRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): Account<TAuth>; +}; + +export { Account }; diff --git a/src/services/activities.ts b/src/services/activities.ts new file mode 100644 index 00000000..fa15e6dc --- /dev/null +++ b/src/services/activities.ts @@ -0,0 +1,123 @@ +import { AppwriteException, Client, type ServerAuth, type Payload } from '../client'; +import type { Models } from '../models'; + + +export type Activities = Omit<ActivitiesRuntime, 'client'>; + +class ActivitiesRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * List all events for selected filters. + * + * @param {string} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc. + * @throws {AppwriteException} + * @returns {Promise<Models.ActivityEventList>} + */ + listEvents(params?: { queries?: string }): Promise<Models.ActivityEventList>; + /** + * List all events for selected filters. + * + * @param {string} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc. + * @throws {AppwriteException} + * @returns {Promise<Models.ActivityEventList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listEvents(queries?: string): Promise<Models.ActivityEventList>; + listEvents( + paramsOrFirst?: { queries?: string } | string + ): Promise<Models.ActivityEventList> { + let params: { queries?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string }; + } else { + params = { + queries: paramsOrFirst as string + }; + } + + const queries = params.queries; + + + const apiPath = '/activities/events'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get event by ID. + * + * + * @param {string} params.eventId - Event ID. + * @throws {AppwriteException} + * @returns {Promise<Models.ActivityEvent>} + */ + getEvent(params: { eventId: string }): Promise<Models.ActivityEvent>; + /** + * Get event by ID. + * + * + * @param {string} eventId - Event ID. + * @throws {AppwriteException} + * @returns {Promise<Models.ActivityEvent>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getEvent(eventId: string): Promise<Models.ActivityEvent>; + getEvent( + paramsOrFirst: { eventId: string } | string + ): Promise<Models.ActivityEvent> { + let params: { eventId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { eventId: string }; + } else { + params = { + eventId: paramsOrFirst as string + }; + } + + const eventId = params.eventId; + + if (typeof eventId === 'undefined') { + throw new AppwriteException('Missing required parameter: "eventId"'); + } + + const apiPath = '/activities/events/{eventId}'.replace('{eventId}', eventId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } +} + +const Activities = ActivitiesRuntime as unknown as { + new (client: Client<ServerAuth>): Activities; +}; + +export { Activities }; diff --git a/src/services/advisor.ts b/src/services/advisor.ts new file mode 100644 index 00000000..ffba49d1 --- /dev/null +++ b/src/services/advisor.ts @@ -0,0 +1,316 @@ +import { AppwriteException, Client, type ServerAuth, type Payload } from '../client'; +import type { Models } from '../models'; + + +export type Advisor = Omit<AdvisorRuntime, 'client'>; + +class AdvisorRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * Get a list of all the project's analyzer reports. You can use the query params to filter your results. + * + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: appId, type, targetType, target, analyzedAt + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ReportList>} + */ + listReports(params?: { queries?: string[], total?: boolean }): Promise<Models.ReportList>; + /** + * Get a list of all the project's analyzer reports. You can use the query params to filter your results. + * + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: appId, type, targetType, target, analyzedAt + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ReportList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listReports(queries?: string[], total?: boolean): Promise<Models.ReportList>; + listReports( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.ReportList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/reports'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced. + * + * + * @param {string} params.reportId - Report ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Report>} + */ + getReport(params: { reportId: string }): Promise<Models.Report>; + /** + * Get an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced. + * + * + * @param {string} reportId - Report ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Report>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getReport(reportId: string): Promise<Models.Report>; + getReport( + paramsOrFirst: { reportId: string } | string + ): Promise<Models.Report> { + let params: { reportId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { reportId: string }; + } else { + params = { + reportId: paramsOrFirst as string + }; + } + + const reportId = params.reportId; + + if (typeof reportId === 'undefined') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + + const apiPath = '/reports/{reportId}'.replace('{reportId}', reportId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker. + * + * + * @param {string} params.reportId - Report ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteReport(params: { reportId: string }): Promise<{}>; + /** + * Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker. + * + * + * @param {string} reportId - Report ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteReport(reportId: string): Promise<{}>; + deleteReport( + paramsOrFirst: { reportId: string } | string + ): Promise<{}> { + let params: { reportId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { reportId: string }; + } else { + params = { + reportId: paramsOrFirst as string + }; + } + + const reportId = params.reportId; + + if (typeof reportId === 'undefined') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + + const apiPath = '/reports/{reportId}'.replace('{reportId}', reportId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * List the insights produced under a single analyzer report. You can use the query params to filter your results further. + * + * + * @param {string} params.reportId - Parent report ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.InsightList>} + */ + listInsights(params: { reportId: string, queries?: string[], total?: boolean }): Promise<Models.InsightList>; + /** + * List the insights produced under a single analyzer report. You can use the query params to filter your results further. + * + * + * @param {string} reportId - Parent report ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.InsightList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listInsights(reportId: string, queries?: string[], total?: boolean): Promise<Models.InsightList>; + listInsights( + paramsOrFirst: { reportId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.InsightList> { + let params: { reportId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { reportId: string, queries?: string[], total?: boolean }; + } else { + params = { + reportId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const reportId = params.reportId; + const queries = params.queries; + const total = params.total; + + if (typeof reportId === 'undefined') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + + const apiPath = '/reports/{reportId}/insights'.replace('{reportId}', reportId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get an insight by its unique ID, scoped to its parent report. + * + * + * @param {string} params.reportId - Parent report ID. + * @param {string} params.insightId - Insight ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Insight>} + */ + getInsight(params: { reportId: string, insightId: string }): Promise<Models.Insight>; + /** + * Get an insight by its unique ID, scoped to its parent report. + * + * + * @param {string} reportId - Parent report ID. + * @param {string} insightId - Insight ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Insight>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getInsight(reportId: string, insightId: string): Promise<Models.Insight>; + getInsight( + paramsOrFirst: { reportId: string, insightId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Insight> { + let params: { reportId: string, insightId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { reportId: string, insightId: string }; + } else { + params = { + reportId: paramsOrFirst as string, + insightId: rest[0] as string + }; + } + + const reportId = params.reportId; + const insightId = params.insightId; + + if (typeof reportId === 'undefined') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + if (typeof insightId === 'undefined') { + throw new AppwriteException('Missing required parameter: "insightId"'); + } + + const apiPath = '/reports/{reportId}/insights/{insightId}'.replace('{reportId}', reportId).replace('{insightId}', insightId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } +} + +const Advisor = AdvisorRuntime as unknown as { + new (client: Client<ServerAuth>): Advisor; +}; + +export { Advisor }; diff --git a/src/services/avatars.ts b/src/services/avatars.ts index eea5a0f8..5e91655e 100644 --- a/src/services/avatars.ts +++ b/src/services/avatars.ts @@ -1,5 +1,5 @@ import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload } from '../client'; import type { Models } from '../models'; import { Browser } from '../enums/browser'; @@ -10,10 +10,20 @@ import { Timezone } from '../enums/timezone'; import { BrowserPermission } from '../enums/browser-permission'; import { ImageFormat } from '../enums/image-format'; -export class Avatars { - client: Client; +type AvatarsServerOnlyMethod = never; +type AvatarsClientOnlyMethod = never; - constructor(client: Client) { +export type Avatars<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<AvatarsRuntime<TAuth>, 'client' | AvatarsServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<AvatarsRuntime<TAuth>, 'client' | AvatarsClientOnlyMethod> + : Omit<AvatarsRuntime<TAuth>, 'client'>; + +class AvatarsRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } @@ -86,7 +96,7 @@ export class Avatars { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -166,7 +176,7 @@ export class Avatars { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -225,7 +235,7 @@ export class Avatars { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -305,7 +315,7 @@ export class Avatars { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -383,7 +393,7 @@ export class Avatars { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -467,7 +477,7 @@ export class Avatars { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -546,7 +556,7 @@ export class Avatars { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -743,7 +753,7 @@ export class Avatars { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -752,3 +762,9 @@ export class Avatars { return uri.toString(); } } + +const Avatars = AvatarsRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): Avatars<TAuth>; +}; + +export { Avatars }; diff --git a/src/services/backups.ts b/src/services/backups.ts new file mode 100644 index 00000000..29005f77 --- /dev/null +++ b/src/services/backups.ts @@ -0,0 +1,761 @@ +import { AppwriteException, Client, type ServerAuth, type Payload } from '../client'; +import type { Models } from '../models'; + +import { BackupServices } from '../enums/backup-services'; + +export type Backups = Omit<BackupsRuntime, 'client'>; + +class BackupsRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * List all archives for a project. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupArchiveList>} + */ + listArchives(params?: { queries?: string[] }): Promise<Models.BackupArchiveList>; + /** + * List all archives for a project. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupArchiveList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listArchives(queries?: string[]): Promise<Models.BackupArchiveList>; + listArchives( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise<Models.BackupArchiveList> { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/backups/archives'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new archive asynchronously for a project. + * + * @param {BackupServices[]} params.services - Array of services to backup + * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupArchive>} + */ + createArchive(params: { services: BackupServices[], resourceId?: string }): Promise<Models.BackupArchive>; + /** + * Create a new archive asynchronously for a project. + * + * @param {BackupServices[]} services - Array of services to backup + * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupArchive>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createArchive(services: BackupServices[], resourceId?: string): Promise<Models.BackupArchive>; + createArchive( + paramsOrFirst: { services: BackupServices[], resourceId?: string } | BackupServices[], + ...rest: [(string)?] + ): Promise<Models.BackupArchive> { + let params: { services: BackupServices[], resourceId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('services' in paramsOrFirst || 'resourceId' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { services: BackupServices[], resourceId?: string }; + } else { + params = { + services: paramsOrFirst as BackupServices[], + resourceId: rest[0] as string + }; + } + + const services = params.services; + const resourceId = params.resourceId; + + if (typeof services === 'undefined') { + throw new AppwriteException('Missing required parameter: "services"'); + } + + const apiPath = '/backups/archives'; + const payload: Payload = {}; + if (typeof services !== 'undefined') { + payload['services'] = services; + } + if (typeof resourceId !== 'undefined') { + payload['resourceId'] = resourceId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a backup archive using it's ID. + * + * @param {string} params.archiveId - Archive ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupArchive>} + */ + getArchive(params: { archiveId: string }): Promise<Models.BackupArchive>; + /** + * Get a backup archive using it's ID. + * + * @param {string} archiveId - Archive ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupArchive>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getArchive(archiveId: string): Promise<Models.BackupArchive>; + getArchive( + paramsOrFirst: { archiveId: string } | string + ): Promise<Models.BackupArchive> { + let params: { archiveId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { archiveId: string }; + } else { + params = { + archiveId: paramsOrFirst as string + }; + } + + const archiveId = params.archiveId; + + if (typeof archiveId === 'undefined') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + + const apiPath = '/backups/archives/{archiveId}'.replace('{archiveId}', archiveId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete an existing archive for a project. + * + * @param {string} params.archiveId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteArchive(params: { archiveId: string }): Promise<{}>; + /** + * Delete an existing archive for a project. + * + * @param {string} archiveId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteArchive(archiveId: string): Promise<{}>; + deleteArchive( + paramsOrFirst: { archiveId: string } | string + ): Promise<{}> { + let params: { archiveId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { archiveId: string }; + } else { + params = { + archiveId: paramsOrFirst as string + }; + } + + const archiveId = params.archiveId; + + if (typeof archiveId === 'undefined') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + + const apiPath = '/backups/archives/{archiveId}'.replace('{archiveId}', archiveId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * List all policies for a project. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupPolicyList>} + */ + listPolicies(params?: { queries?: string[] }): Promise<Models.BackupPolicyList>; + /** + * List all policies for a project. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupPolicyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPolicies(queries?: string[]): Promise<Models.BackupPolicyList>; + listPolicies( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise<Models.BackupPolicyList> { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/backups/policies'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new backup policy. + * + * @param {string} params.policyId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {BackupServices[]} params.services - Array of services to backup + * @param {number} params.retention - Days to keep backups before deletion + * @param {string} params.schedule - Schedule CRON syntax. + * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {string} params.resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {boolean} params.enabled - Is policy enabled? When set to 'disabled', no backups will be taken + * @throws {AppwriteException} + * @returns {Promise<Models.BackupPolicy>} + */ + createPolicy(params: { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }): Promise<Models.BackupPolicy>; + /** + * Create a new backup policy. + * + * @param {string} policyId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {BackupServices[]} services - Array of services to backup + * @param {number} retention - Days to keep backups before deletion + * @param {string} schedule - Schedule CRON syntax. + * @param {string} name - Policy name. Max length: 128 chars. + * @param {string} resourceId - Resource ID. When set, only this single resource will be backed up. + * @param {boolean} enabled - Is policy enabled? When set to 'disabled', no backups will be taken + * @throws {AppwriteException} + * @returns {Promise<Models.BackupPolicy>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPolicy(policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean): Promise<Models.BackupPolicy>; + createPolicy( + paramsOrFirst: { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean } | string, + ...rest: [(BackupServices[])?, (number)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.BackupPolicy> { + let params: { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { policyId: string, services: BackupServices[], retention: number, schedule: string, name?: string, resourceId?: string, enabled?: boolean }; + } else { + params = { + policyId: paramsOrFirst as string, + services: rest[0] as BackupServices[], + retention: rest[1] as number, + schedule: rest[2] as string, + name: rest[3] as string, + resourceId: rest[4] as string, + enabled: rest[5] as boolean + }; + } + + const policyId = params.policyId; + const services = params.services; + const retention = params.retention; + const schedule = params.schedule; + const name = params.name; + const resourceId = params.resourceId; + const enabled = params.enabled; + + if (typeof policyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + if (typeof services === 'undefined') { + throw new AppwriteException('Missing required parameter: "services"'); + } + if (typeof retention === 'undefined') { + throw new AppwriteException('Missing required parameter: "retention"'); + } + if (typeof schedule === 'undefined') { + throw new AppwriteException('Missing required parameter: "schedule"'); + } + + const apiPath = '/backups/policies'; + const payload: Payload = {}; + if (typeof policyId !== 'undefined') { + payload['policyId'] = policyId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof services !== 'undefined') { + payload['services'] = services; + } + if (typeof resourceId !== 'undefined') { + payload['resourceId'] = resourceId; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof retention !== 'undefined') { + payload['retention'] = retention; + } + if (typeof schedule !== 'undefined') { + payload['schedule'] = schedule; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a backup policy using it's ID. + * + * @param {string} params.policyId - Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupPolicy>} + */ + getPolicy(params: { policyId: string }): Promise<Models.BackupPolicy>; + /** + * Get a backup policy using it's ID. + * + * @param {string} policyId - Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupPolicy>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPolicy(policyId: string): Promise<Models.BackupPolicy>; + getPolicy( + paramsOrFirst: { policyId: string } | string + ): Promise<Models.BackupPolicy> { + let params: { policyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { policyId: string }; + } else { + params = { + policyId: paramsOrFirst as string + }; + } + + const policyId = params.policyId; + + if (typeof policyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + + const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', policyId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an existing policy using it's ID. + * + * @param {string} params.policyId - Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Policy name. Max length: 128 chars. + * @param {number} params.retention - Days to keep backups before deletion + * @param {string} params.schedule - Cron expression + * @param {boolean} params.enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @throws {AppwriteException} + * @returns {Promise<Models.BackupPolicy>} + */ + updatePolicy(params: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }): Promise<Models.BackupPolicy>; + /** + * Update an existing policy using it's ID. + * + * @param {string} policyId - Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Policy name. Max length: 128 chars. + * @param {number} retention - Days to keep backups before deletion + * @param {string} schedule - Cron expression + * @param {boolean} enabled - Is Backup enabled? When set to 'disabled', No backup will be taken + * @throws {AppwriteException} + * @returns {Promise<Models.BackupPolicy>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePolicy(policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean): Promise<Models.BackupPolicy>; + updatePolicy( + paramsOrFirst: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean } | string, + ...rest: [(string)?, (number)?, (string)?, (boolean)?] + ): Promise<Models.BackupPolicy> { + let params: { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { policyId: string, name?: string, retention?: number, schedule?: string, enabled?: boolean }; + } else { + params = { + policyId: paramsOrFirst as string, + name: rest[0] as string, + retention: rest[1] as number, + schedule: rest[2] as string, + enabled: rest[3] as boolean + }; + } + + const policyId = params.policyId; + const name = params.name; + const retention = params.retention; + const schedule = params.schedule; + const enabled = params.enabled; + + if (typeof policyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + + const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', policyId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof retention !== 'undefined') { + payload['retention'] = retention; + } + if (typeof schedule !== 'undefined') { + payload['schedule'] = schedule; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a policy using it's ID. + * + * @param {string} params.policyId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePolicy(params: { policyId: string }): Promise<{}>; + /** + * Delete a policy using it's ID. + * + * @param {string} policyId - Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePolicy(policyId: string): Promise<{}>; + deletePolicy( + paramsOrFirst: { policyId: string } | string + ): Promise<{}> { + let params: { policyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { policyId: string }; + } else { + params = { + policyId: paramsOrFirst as string + }; + } + + const policyId = params.policyId; + + if (typeof policyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + + const apiPath = '/backups/policies/{policyId}'.replace('{policyId}', policyId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Create and trigger a new restoration for a backup on a project. + * + * @param {string} params.archiveId - Backup archive ID to restore + * @param {BackupServices[]} params.services - Array of services to restore + * @param {string} params.newResourceId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.newResourceName - Database name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupRestoration>} + */ + createRestoration(params: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }): Promise<Models.BackupRestoration>; + /** + * Create and trigger a new restoration for a backup on a project. + * + * @param {string} archiveId - Backup archive ID to restore + * @param {BackupServices[]} services - Array of services to restore + * @param {string} newResourceId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} newResourceName - Database name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRestoration(archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string): Promise<Models.BackupRestoration>; + createRestoration( + paramsOrFirst: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string } | string, + ...rest: [(BackupServices[])?, (string)?, (string)?] + ): Promise<Models.BackupRestoration> { + let params: { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { archiveId: string, services: BackupServices[], newResourceId?: string, newResourceName?: string }; + } else { + params = { + archiveId: paramsOrFirst as string, + services: rest[0] as BackupServices[], + newResourceId: rest[1] as string, + newResourceName: rest[2] as string + }; + } + + const archiveId = params.archiveId; + const services = params.services; + const newResourceId = params.newResourceId; + const newResourceName = params.newResourceName; + + if (typeof archiveId === 'undefined') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + if (typeof services === 'undefined') { + throw new AppwriteException('Missing required parameter: "services"'); + } + + const apiPath = '/backups/restoration'; + const payload: Payload = {}; + if (typeof archiveId !== 'undefined') { + payload['archiveId'] = archiveId; + } + if (typeof services !== 'undefined') { + payload['services'] = services; + } + if (typeof newResourceId !== 'undefined') { + payload['newResourceId'] = newResourceId; + } + if (typeof newResourceName !== 'undefined') { + payload['newResourceName'] = newResourceName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * List all backup restorations for a project. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupRestorationList>} + */ + listRestorations(params?: { queries?: string[] }): Promise<Models.BackupRestorationList>; + /** + * List all backup restorations for a project. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupRestorationList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRestorations(queries?: string[]): Promise<Models.BackupRestorationList>; + listRestorations( + paramsOrFirst?: { queries?: string[] } | string[] + ): Promise<Models.BackupRestorationList> { + let params: { queries?: string[] }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[] }; + } else { + params = { + queries: paramsOrFirst as string[] + }; + } + + const queries = params.queries; + + + const apiPath = '/backups/restorations'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the current status of a backup restoration. + * + * @param {string} params.restorationId - Restoration ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupRestoration>} + */ + getRestoration(params: { restorationId: string }): Promise<Models.BackupRestoration>; + /** + * Get the current status of a backup restoration. + * + * @param {string} restorationId - Restoration ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.BackupRestoration>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRestoration(restorationId: string): Promise<Models.BackupRestoration>; + getRestoration( + paramsOrFirst: { restorationId: string } | string + ): Promise<Models.BackupRestoration> { + let params: { restorationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { restorationId: string }; + } else { + params = { + restorationId: paramsOrFirst as string + }; + } + + const restorationId = params.restorationId; + + if (typeof restorationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + + const apiPath = '/backups/restorations/{restorationId}'.replace('{restorationId}', restorationId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } +} + +const Backups = BackupsRuntime as unknown as { + new (client: Client<ServerAuth>): Backups; +}; + +export { Backups }; diff --git a/src/services/databases.ts b/src/services/databases.ts index 51a58d81..e4c5ef0d 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -1,15 +1,171 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload } from '../client'; import type { Models } from '../models'; +import { RelationshipType } from '../enums/relationship-type'; +import { RelationMutate } from '../enums/relation-mutate'; +import { DatabasesIndexType } from '../enums/databases-index-type'; +import { OrderBy } from '../enums/order-by'; -export class Databases { - client: Client; +type DatabasesServerOnlyMethod = 'list' | 'create' | 'get' | 'update' | 'delete' | 'listCollections' | 'createCollection' | 'getCollection' | 'updateCollection' | 'deleteCollection' | 'listAttributes' | 'createBigIntAttribute' | 'updateBigIntAttribute' | 'createBooleanAttribute' | 'updateBooleanAttribute' | 'createDatetimeAttribute' | 'updateDatetimeAttribute' | 'createEmailAttribute' | 'updateEmailAttribute' | 'createEnumAttribute' | 'updateEnumAttribute' | 'createFloatAttribute' | 'updateFloatAttribute' | 'createIntegerAttribute' | 'updateIntegerAttribute' | 'createIpAttribute' | 'updateIpAttribute' | 'createLineAttribute' | 'updateLineAttribute' | 'createLongtextAttribute' | 'updateLongtextAttribute' | 'createMediumtextAttribute' | 'updateMediumtextAttribute' | 'createPointAttribute' | 'updatePointAttribute' | 'createPolygonAttribute' | 'updatePolygonAttribute' | 'createRelationshipAttribute' | 'updateRelationshipAttribute' | 'createStringAttribute' | 'updateStringAttribute' | 'createTextAttribute' | 'updateTextAttribute' | 'createUrlAttribute' | 'updateUrlAttribute' | 'createVarcharAttribute' | 'updateVarcharAttribute' | 'getAttribute' | 'deleteAttribute' | 'upsertDocuments' | 'updateDocuments' | 'deleteDocuments' | 'listIndexes' | 'createIndex' | 'getIndex' | 'deleteIndex'; +type DatabasesClientOnlyMethod = never; - constructor(client: Client) { +export type Databases<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<DatabasesRuntime<TAuth>, 'client' | DatabasesServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<DatabasesRuntime<TAuth>, 'client' | DatabasesClientOnlyMethod> + : Omit<DatabasesRuntime<TAuth>, 'client'>; + +class DatabasesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.DatabaseList>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.list` instead. + */ + list(this: Databases<ServerAuth>, params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.DatabaseList>; + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.DatabaseList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(this: Databases<ServerAuth>, queries?: string[], search?: string, total?: boolean): Promise<Models.DatabaseList>; + list( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise<Models.DatabaseList> { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/databases'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Database. + * + * + * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.create` instead. + */ + create(this: Databases<ServerAuth>, params: { databaseId: string, name: string, enabled?: boolean }): Promise<Models.Database>; + /** + * Create a new Database. + * + * + * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(this: Databases<ServerAuth>, databaseId: string, name: string, enabled?: boolean): Promise<Models.Database>; + create( + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.Database> { + let params: { databaseId: string, name: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/databases'; + const payload: Payload = {}; + if (typeof databaseId !== 'undefined') { + payload['databaseId'] = databaseId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + /** * List transactions across all databases. * @@ -344,80 +500,239 @@ export class Databases { } /** - * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. * * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.get` instead. + */ + get(this: Databases<ServerAuth>, params: { databaseId: string }): Promise<Models.Database>; + /** + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(this: Databases<ServerAuth>, databaseId: string): Promise<Models.Database>; + get( + paramsOrFirst: { databaseId: string } | string + ): Promise<Models.Database> { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a database by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.update` instead. + */ + update(this: Databases<ServerAuth>, params: { databaseId: string, name?: string, enabled?: boolean }): Promise<Models.Database>; + /** + * Update a database by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(this: Databases<ServerAuth>, databaseId: string, name?: string, enabled?: boolean): Promise<Models.Database>; + update( + paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.Database> { + let params: { databaseId: string, name?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.delete` instead. + */ + delete(this: Databases<ServerAuth>, params: { databaseId: string }): Promise<{}>; + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(this: Databases<ServerAuth>, databaseId: string): Promise<{}>; + delete( + paramsOrFirst: { databaseId: string } | string + ): Promise<{}> { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/databases/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} params.databaseId - Database ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. - * @param {number} params.ttl - TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). * @throws {AppwriteException} - * @returns {Promise<Models.DocumentList<Document>>} - * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead. + * @returns {Promise<Models.CollectionList>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listTables` instead. */ - listDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise<Models.DocumentList<Document>>; + listCollections(this: Databases<ServerAuth>, params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise<Models.CollectionList>; /** - * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * Get a list of all collections that belong to the provided databaseId. You can use the search parameter to filter your results. * * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. - * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, documentSecurity + * @param {string} search - Search term to filter your list results. Max length: 256 chars. * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. - * @param {number} ttl - TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). * @throws {AppwriteException} - * @returns {Promise<Models.DocumentList<Document>>} + * @returns {Promise<Models.CollectionList>} * @deprecated Use the object parameter style method for a better developer experience. */ - listDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise<Models.DocumentList<Document>>; - listDocuments<Document extends Models.Document = Models.DefaultDocument>( - paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, - ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] - ): Promise<Models.DocumentList<Document>> { - let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + listCollections(this: Databases<ServerAuth>, databaseId: string, queries?: string[], search?: string, total?: boolean): Promise<Models.CollectionList>; + listCollections( + paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, + ...rest: [(string[])?, (string)?, (boolean)?] + ): Promise<Models.CollectionList> { + let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; } else { params = { databaseId: paramsOrFirst as string, - collectionId: rest[0] as string, - queries: rest[1] as string[], - transactionId: rest[2] as string, - total: rest[3] as boolean, - ttl: rest[4] as number + queries: rest[0] as string[], + search: rest[1] as string, + total: rest[2] as boolean }; } const databaseId = params.databaseId; - const collectionId = params.collectionId; const queries = params.queries; - const transactionId = params.transactionId; + const search = params.search; const total = params.total; - const ttl = params.ttl; if (typeof databaseId === 'undefined') { throw new AppwriteException('Missing required parameter: "databaseId"'); } - if (typeof collectionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "collectionId"'); - } - const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; } - if (typeof transactionId !== 'undefined') { - payload['transactionId'] = transactionId; + if (typeof search !== 'undefined') { + payload['search'] = search; } if (typeof total !== 'undefined') { payload['total'] = total; } - if (typeof ttl !== 'undefined') { - payload['ttl'] = ttl; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -432,57 +747,4540 @@ export class Databases { } /** - * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * * @param {string} params.databaseId - Database ID. - * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} params.data - Document data as JSON object. - * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Collection name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @param {object[]} params.attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @throws {AppwriteException} + * @returns {Promise<Models.Collection>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createTable` instead. + */ + createCollection(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }): Promise<Models.Collection>; + /** + * Create a new Collection. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Collection name. Max length: 128 chars. + * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @param {object[]} attributes - Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @throws {AppwriteException} + * @returns {Promise<Models.Collection>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createCollection(this: Databases<ServerAuth>, databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[]): Promise<Models.Collection>; + createCollection( + paramsOrFirst: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (object[])?, (object[])?] + ): Promise<Models.Collection> { + let params: { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, attributes?: object[], indexes?: object[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + documentSecurity: rest[3] as boolean, + enabled: rest[4] as boolean, + attributes: rest[5] as object[], + indexes: rest[6] as object[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + const attributes = params.attributes; + const indexes = params.indexes; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof collectionId !== 'undefined') { + payload['collectionId'] = collectionId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof documentSecurity !== 'undefined') { + payload['documentSecurity'] = documentSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof attributes !== 'undefined') { + payload['attributes'] = attributes; + } + if (typeof indexes !== 'undefined') { + payload['indexes'] = indexes; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Collection>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getTable` instead. + */ + getCollection(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string }): Promise<Models.Collection>; + /** + * Get a collection by its unique ID. This endpoint response returns a JSON object with the collection metadata. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Collection>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getCollection(this: Databases<ServerAuth>, databaseId: string, collectionId: string): Promise<Models.Collection>; + getCollection( + paramsOrFirst: { databaseId: string, collectionId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Collection> { + let params: { databaseId: string, collectionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a collection by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.name - Collection name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @param {boolean} params.purge - When true, purge all cached list responses for this collection as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. + * @throws {AppwriteException} + * @returns {Promise<Models.Collection>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTable` instead. + */ + updateCollection(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }): Promise<Models.Collection>; + /** + * Update a collection by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} name - Collection name. Max length: 128 chars. + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} documentSecurity - Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + * @param {boolean} purge - When true, purge all cached list responses for this collection as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. + * @throws {AppwriteException} + * @returns {Promise<Models.Collection>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateCollection(this: Databases<ServerAuth>, databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean): Promise<Models.Collection>; + updateCollection( + paramsOrFirst: { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (boolean)?] + ): Promise<Models.Collection> { + let params: { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, name?: string, permissions?: string[], documentSecurity?: boolean, enabled?: boolean, purge?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + documentSecurity: rest[3] as boolean, + enabled: rest[4] as boolean, + purge: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const name = params.name; + const permissions = params.permissions; + const documentSecurity = params.documentSecurity; + const enabled = params.enabled; + const purge = params.purge; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof documentSecurity !== 'undefined') { + payload['documentSecurity'] = documentSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof purge !== 'undefined') { + payload['purge'] = purge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteTable` instead. + */ + deleteCollection(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string }): Promise<{}>; + /** + * Delete a collection by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteCollection(this: Databases<ServerAuth>, databaseId: string, collectionId: string): Promise<{}>; + deleteCollection( + paramsOrFirst: { databaseId: string, collectionId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * List attributes in the collection. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, size, required, array, status, error + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeList>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listColumns` instead. + */ + listAttributes(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise<Models.AttributeList>; + /** + * List attributes in the collection. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, size, required, array, status, error + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listAttributes(this: Databases<ServerAuth>, databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise<Models.AttributeList>; + listAttributes( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?] + ): Promise<Models.AttributeList> { + let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + total: rest[2] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const total = params.total; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a bigint attribute. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBigint>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBigIntColumn` instead. + */ + createBigIntAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise<Models.AttributeBigint>; + /** + * Create a bigint attribute. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBigint>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBigIntAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise<Models.AttributeBigint>; + createBigIntAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + ): Promise<Models.AttributeBigint> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number | bigint, + max: rest[4] as number | bigint, + xdefault: rest[5] as number | bigint, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a bigint attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBigint>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead. + */ + updateBigIntAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise<Models.AttributeBigint>; + /** + * Update a bigint attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBigint>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBigIntAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise<Models.AttributeBigint>; + updateBigIntAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + ): Promise<Models.AttributeBigint> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number | bigint, + min: rest[4] as number | bigint, + max: rest[5] as number | bigint, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a boolean attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBoolean>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBooleanColumn` instead. + */ + createBooleanAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }): Promise<Models.AttributeBoolean>; + /** + * Create a boolean attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBoolean>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBooleanAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise<Models.AttributeBoolean>; + createBooleanAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (boolean)?] + ): Promise<Models.AttributeBoolean> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as boolean, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a boolean attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {boolean} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBoolean>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBooleanColumn` instead. + */ + updateBooleanAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }): Promise<Models.AttributeBoolean>; + /** + * Update a boolean attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {boolean} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBoolean>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBooleanAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise<Models.AttributeBoolean>; + updateBooleanAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (string)?] + ): Promise<Models.AttributeBoolean> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as boolean, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a date time attribute according to the ISO 8601 standard. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeDatetime>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createDatetimeColumn` instead. + */ + createDatetimeAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.AttributeDatetime>; + /** + * Create a date time attribute according to the ISO 8601 standard. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeDatetime>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDatetimeAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeDatetime>; + createDatetimeAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.AttributeDatetime> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a date time attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeDatetime>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateDatetimeColumn` instead. + */ + updateDatetimeAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeDatetime>; + /** + * Update a date time attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeDatetime>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDatetimeAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeDatetime>; + updateDatetimeAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeDatetime> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create an email attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEmail>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createEmailColumn` instead. + */ + createEmailAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.AttributeEmail>; + /** + * Create an email attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEmail>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEmailAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeEmail>; + createEmailAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.AttributeEmail> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an email attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEmail>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEmailColumn` instead. + */ + updateEmailAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeEmail>; + /** + * Update an email attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEmail>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmailAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeEmail>; + updateEmailAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeEmail> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/email/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {string[]} params.elements - Array of enum values. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEnum>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createEnumColumn` instead. + */ + createEnumAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }): Promise<Models.AttributeEnum>; + /** + * Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {string[]} elements - Array of enum values. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEnum>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEnumAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeEnum>; + createEnumAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.AttributeEnum> { + let params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + elements: rest[2] as string[], + required: rest[3] as boolean, + xdefault: rest[4] as string, + array: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const elements = params.elements; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof elements === 'undefined') { + throw new AppwriteException('Missing required parameter: "elements"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof elements !== 'undefined') { + payload['elements'] = elements; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an enum attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {string[]} params.elements - Updated list of enum values. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEnum>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateEnumColumn` instead. + */ + updateEnumAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeEnum>; + /** + * Update an enum attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {string[]} elements - Updated list of enum values. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeEnum>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEnumAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeEnum>; + updateEnumAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeEnum> { + let params: { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + elements: rest[2] as string[], + required: rest[3] as boolean, + xdefault: rest[4] as string, + newKey: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const elements = params.elements; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof elements === 'undefined') { + throw new AppwriteException('Missing required parameter: "elements"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/enum/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof elements !== 'undefined') { + payload['elements'] = elements; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a float attribute. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number} params.min - Minimum value. + * @param {number} params.max - Maximum value. + * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeFloat>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createFloatColumn` instead. + */ + createFloatAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise<Models.AttributeFloat>; + /** + * Create a float attribute. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number} min - Minimum value. + * @param {number} max - Maximum value. + * @param {number} xdefault - Default value. Cannot be set when required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeFloat>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFloatAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.AttributeFloat>; + createFloatAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + ): Promise<Models.AttributeFloat> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number, + max: rest[4] as number, + xdefault: rest[5] as number, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a float attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number} params.min - Minimum value. + * @param {number} params.max - Maximum value. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeFloat>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateFloatColumn` instead. + */ + updateFloatAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise<Models.AttributeFloat>; + /** + * Update a float attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number} min - Minimum value. + * @param {number} max - Maximum value. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeFloat>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateFloatAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.AttributeFloat>; + updateFloatAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + ): Promise<Models.AttributeFloat> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number, + min: rest[4] as number, + max: rest[5] as number, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/float/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create an integer attribute. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeInteger>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIntegerColumn` instead. + */ + createIntegerAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise<Models.AttributeInteger>; + /** + * Create an integer attribute. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeInteger>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIntegerAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise<Models.AttributeInteger>; + createIntegerAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + ): Promise<Models.AttributeInteger> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number | bigint, + max: rest[4] as number | bigint, + xdefault: rest[5] as number | bigint, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an integer attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {number | bigint} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeInteger>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIntegerColumn` instead. + */ + updateIntegerAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise<Models.AttributeInteger>; + /** + * Update an integer attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {number | bigint} xdefault - Default value. Cannot be set when attribute is required. + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeInteger>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateIntegerAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise<Models.AttributeInteger>; + updateIntegerAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + ): Promise<Models.AttributeInteger> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number | bigint, + min: rest[4] as number | bigint, + max: rest[5] as number | bigint, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/integer/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create IP address attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeIp>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIpColumn` instead. + */ + createIpAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.AttributeIp>; + /** + * Create IP address attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeIp>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIpAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeIp>; + createIpAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.AttributeIp> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an ip attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeIp>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateIpColumn` instead. + */ + updateIpAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeIp>; + /** + * Update an ip attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeIp>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateIpAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeIp>; + updateIpAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeIp> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/ip/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a geometric line attribute. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {any[]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeLine>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createLineColumn` instead. + */ + createLineAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] }): Promise<Models.AttributeLine>; + /** + * Create a geometric line attribute. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {any[]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeLine>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createLineAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[]): Promise<Models.AttributeLine>; + createLineAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?] + ): Promise<Models.AttributeLine> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/line'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a line attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {any[]} params.xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string} params.newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeLine>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateLineColumn` instead. + */ + updateLineAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }): Promise<Models.AttributeLine>; + /** + * Update a line attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {any[]} xdefault - Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. + * @param {string} newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeLine>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateLineAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string): Promise<Models.AttributeLine>; + updateLineAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?, (string)?] + ): Promise<Models.AttributeLine> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[], + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a longtext attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeLongtext>} + */ + createLongtextAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.AttributeLongtext>; + /** + * Create a longtext attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeLongtext>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createLongtextAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.AttributeLongtext>; + createLongtextAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.AttributeLongtext> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean, + encrypt: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a longtext attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeLongtext>} + */ + updateLongtextAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeLongtext>; + /** + * Update a longtext attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeLongtext>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateLongtextAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeLongtext>; + updateLongtextAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeLongtext> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a mediumtext attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeMediumtext>} + */ + createMediumtextAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.AttributeMediumtext>; + /** + * Create a mediumtext attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeMediumtext>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMediumtextAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.AttributeMediumtext>; + createMediumtextAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.AttributeMediumtext> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean, + encrypt: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeMediumtext>} + */ + updateMediumtextAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeMediumtext>; + /** + * Update a mediumtext attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeMediumtext>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMediumtextAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeMediumtext>; + updateMediumtextAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeMediumtext> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a geometric point attribute. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {any[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributePoint>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead. + */ + createPointAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] }): Promise<Models.AttributePoint>; + /** + * Create a geometric point attribute. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {any[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributePoint>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPointAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[]): Promise<Models.AttributePoint>; + createPointAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?] + ): Promise<Models.AttributePoint> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/point'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a point attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {any[]} params.xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string} params.newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributePoint>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePointColumn` instead. + */ + updatePointAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }): Promise<Models.AttributePoint>; + /** + * Update a point attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {any[]} xdefault - Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. + * @param {string} newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributePoint>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePointAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string): Promise<Models.AttributePoint>; + updatePointAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?, (string)?] + ): Promise<Models.AttributePoint> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[], + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a geometric polygon attribute. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {any[]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributePolygon>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPolygonColumn` instead. + */ + createPolygonAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] }): Promise<Models.AttributePolygon>; + /** + * Create a geometric polygon attribute. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {any[]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributePolygon>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPolygonAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[]): Promise<Models.AttributePolygon>; + createPolygonAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?] + ): Promise<Models.AttributePolygon> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a polygon attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {any[]} params.xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string} params.newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributePolygon>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updatePolygonColumn` instead. + */ + updatePolygonAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }): Promise<Models.AttributePolygon>; + /** + * Update a polygon attribute. Changing the `default` value will not update already existing documents. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {any[]} xdefault - Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. + * @param {string} newKey - New attribute key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributePolygon>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePolygonAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string): Promise<Models.AttributePolygon>; + updatePolygonAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?, (string)?] + ): Promise<Models.AttributePolygon> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[], + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.relatedCollectionId - Related Collection ID. + * @param {RelationshipType} params.type - Relation type + * @param {boolean} params.twoWay - Is Two Way? + * @param {string} params.key - Attribute Key. + * @param {string} params.twoWayKey - Two Way Attribute Key. + * @param {RelationMutate} params.onDelete - Constraints option + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeRelationship>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRelationshipColumn` instead. + */ + createRelationshipAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }): Promise<Models.AttributeRelationship>; + /** + * Create relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} relatedCollectionId - Related Collection ID. + * @param {RelationshipType} type - Relation type + * @param {boolean} twoWay - Is Two Way? + * @param {string} key - Attribute Key. + * @param {string} twoWayKey - Two Way Attribute Key. + * @param {RelationMutate} onDelete - Constraints option + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeRelationship>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRelationshipAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise<Models.AttributeRelationship>; + createRelationshipAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate } | string, + ...rest: [(string)?, (string)?, (RelationshipType)?, (boolean)?, (string)?, (string)?, (RelationMutate)?] + ): Promise<Models.AttributeRelationship> { + let params: { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, relatedCollectionId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + relatedCollectionId: rest[1] as string, + type: rest[2] as RelationshipType, + twoWay: rest[3] as boolean, + key: rest[4] as string, + twoWayKey: rest[5] as string, + onDelete: rest[6] as RelationMutate + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const relatedCollectionId = params.relatedCollectionId; + const type = params.type; + const twoWay = params.twoWay; + const key = params.key; + const twoWayKey = params.twoWayKey; + const onDelete = params.onDelete; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof relatedCollectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "relatedCollectionId"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof relatedCollectionId !== 'undefined') { + payload['relatedCollectionId'] = relatedCollectionId; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof twoWay !== 'undefined') { + payload['twoWay'] = twoWay; + } + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof twoWayKey !== 'undefined') { + payload['twoWayKey'] = twoWayKey; + } + if (typeof onDelete !== 'undefined') { + payload['onDelete'] = onDelete; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {RelationMutate} params.onDelete - Constraints option + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeRelationship>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRelationshipColumn` instead. + */ + updateRelationshipAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }): Promise<Models.AttributeRelationship>; + /** + * Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {RelationMutate} onDelete - Constraints option + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeRelationship>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRelationshipAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.AttributeRelationship>; + updateRelationshipAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string } | string, + ...rest: [(string)?, (string)?, (RelationMutate)?, (string)?] + ): Promise<Models.AttributeRelationship> { + let params: { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + onDelete: rest[2] as RelationMutate, + newKey: rest[3] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const onDelete = params.onDelete; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof onDelete !== 'undefined') { + payload['onDelete'] = onDelete; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a string attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {number} params.size - Attribute size for text attributes, in number of characters. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeString>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createStringColumn` instead. + */ + createStringAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.AttributeString>; + /** + * Create a string attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {number} size - Attribute size for text attributes, in number of characters. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeString>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createStringAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.AttributeString>; + createStringAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.AttributeString> { + let params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + size: rest[2] as number, + required: rest[3] as boolean, + xdefault: rest[4] as string, + array: rest[5] as boolean, + encrypt: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const size = params.size; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof size === 'undefined') { + throw new AppwriteException('Missing required parameter: "size"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a string attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number} params.size - Maximum size of the string attribute. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeString>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateStringColumn` instead. + */ + updateStringAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise<Models.AttributeString>; + /** + * Update a string attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number} size - Maximum size of the string attribute. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeString>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateStringAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise<Models.AttributeString>; + updateStringAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + ): Promise<Models.AttributeString> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + size: rest[4] as number, + newKey: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const size = params.size; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/string/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a text attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeText>} + */ + createTextAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.AttributeText>; + /** + * Create a text attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeText>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTextAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.AttributeText>; + createTextAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.AttributeText> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean, + encrypt: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/text'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a text attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeText>} + */ + updateTextAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeText>; + /** + * Update a text attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeText>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTextAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeText>; + updateTextAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeText> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a URL attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeUrl>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createUrlColumn` instead. + */ + createUrlAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.AttributeUrl>; + /** + * Create a URL attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeUrl>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createUrlAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.AttributeUrl>; + createUrlAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.AttributeUrl> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an url attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeUrl>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateUrlColumn` instead. + */ + updateUrlAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.AttributeUrl>; + /** + * Update an url attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeUrl>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateUrlAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.AttributeUrl>; + updateUrlAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.AttributeUrl> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/url/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a varchar attribute. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {number} params.size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} params.array - Is attribute an array? + * @param {boolean} params.encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeVarchar>} + */ + createVarcharAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.AttributeVarchar>; + /** + * Create a varchar attribute. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {number} size - Attribute size for varchar attributes, in number of characters. Maximum size is 16381. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {boolean} array - Is attribute an array? + * @param {boolean} encrypt - Toggle encryption for the attribute. Encryption enhances security by not storing any plain text values in the database. However, encrypted attributes cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeVarchar>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVarcharAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.AttributeVarchar>; + createVarcharAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.AttributeVarchar> { + let params: { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + size: rest[2] as number, + required: rest[3] as boolean, + xdefault: rest[4] as string, + array: rest[5] as boolean, + encrypt: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const size = params.size; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof size === 'undefined') { + throw new AppwriteException('Missing required parameter: "size"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a varchar attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Attribute Key. + * @param {boolean} params.required - Is attribute required? + * @param {string} params.xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number} params.size - Maximum size of the varchar attribute. + * @param {string} params.newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeVarchar>} + */ + updateVarcharAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise<Models.AttributeVarchar>; + /** + * Update a varchar attribute. Changing the `default` value will not update already existing documents. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Attribute Key. + * @param {boolean} required - Is attribute required? + * @param {string} xdefault - Default value for attribute when not provided. Cannot be set when attribute is required. + * @param {number} size - Maximum size of the varchar attribute. + * @param {string} newKey - New Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeVarchar>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateVarcharAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise<Models.AttributeVarchar>; + updateVarcharAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + ): Promise<Models.AttributeVarchar> { + let params: { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + size: rest[4] as number, + newKey: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const size = params.size; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get attribute by ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead. + */ + getAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string }): Promise<Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString>; + /** + * Get attribute by ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string): Promise<Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString>; + getAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.AttributeBoolean | Models.AttributeInteger | Models.AttributeFloat | Models.AttributeEmail | Models.AttributeEnum | Models.AttributeUrl | Models.AttributeIp | Models.AttributeDatetime | Models.AttributeRelationship | Models.AttributeString> { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Deletes an attribute. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {string} params.key - Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteColumn` instead. + */ + deleteAttribute(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + /** + * Deletes an attribute. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {string} key - Attribute Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteAttribute(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string): Promise<{}>; + deleteAttribute( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} params.ttl - TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead. + */ + listDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }): Promise<Models.DocumentList<Document>>; + /** + * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {number} ttl - TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number): Promise<Models.DocumentList<Document>>; + listDocuments<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number } | string, + ...rest: [(string)?, (string[])?, (string)?, (boolean)?, (number)?] + ): Promise<Models.DocumentList<Document>> { + let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string, total?: boolean, ttl?: number }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string, + total: rest[3] as boolean, + ttl: rest[4] as number + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const transactionId = params.transactionId; + const total = params.total; + const ttl = params.ttl; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + if (typeof ttl !== 'undefined') { + payload['ttl'] = ttl; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} params.data - Document data as JSON object. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {object[]} params.documents - Array of documents data as JSON objects. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Document>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. + */ + createDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId?: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], documents?: object[], transactionId?: string }): Promise<Document>; + /** + * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} data - Document data as JSON object. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {object[]} documents - Array of documents data as JSON objects. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Document>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId?: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], documents?: object[], transactionId?: string): Promise<Document>; + createDocument<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documentId?: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], documents?: object[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, (string[])?, (object[])?, (string)?] + ): Promise<Document> { + let params: { databaseId: string, collectionId: string, documentId?: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], documents?: object[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId?: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], documents?: object[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documentId: rest[1] as string, + data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, + permissions: rest[3] as string[], + documents: rest[4] as object[], + transactionId: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documentId = params.documentId; + const data = params.data; + const permissions = params.permissions; + const documents = params.documents; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof documentId !== 'undefined') { + payload['documentId'] = documentId; + } + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof documents !== 'undefined') { + payload['documents'] = documents; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object[]} params.documents - Array of document data as JSON objects. May contain partial documents. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRows` instead. + */ + upsertDocuments<Document extends Models.Document = Models.DefaultDocument>(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise<Models.DocumentList<Document>>; + /** + * Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object[]} documents - Array of document data as JSON objects. May contain partial documents. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertDocuments<Document extends Models.Document = Models.DefaultDocument>(this: Databases<ServerAuth>, databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise<Models.DocumentList<Document>>; + upsertDocuments<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, + ...rest: [(string)?, (object[])?, (string)?] + ): Promise<Models.DocumentList<Document>> { + let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[], + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documents === 'undefined') { + throw new AppwriteException('Missing required parameter: "documents"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof documents !== 'undefined') { + payload['documents'] = documents; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. + * @param {object} params.data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateRows` instead. + */ + updateDocuments<Document extends Models.Document = Models.DefaultDocument>(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }): Promise<Models.DocumentList<Document>>; + /** + * Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. + * @param {object} data - Document data as JSON object. Include only attribute and value pairs to be updated. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDocuments<Document extends Models.Document = Models.DefaultDocument>(this: Databases<ServerAuth>, databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string): Promise<Models.DocumentList<Document>>; + updateDocuments<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (object)?, (string[])?, (string)?] + ): Promise<Models.DocumentList<Document>> { + let params: { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, data?: object, queries?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + data: rest[1] as object, + queries: rest[2] as string[], + transactionId: rest[3] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const data = params.data; + const queries = params.queries; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} - * @returns {Promise<Document>} - * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRows` instead. */ - createDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], transactionId?: string }): Promise<Document>; + deleteDocuments<Document extends Models.Document = Models.DefaultDocument>(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise<Models.DocumentList<Document>>; /** - * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * Bulk delete documents using queries, if no queries are passed then all documents are deleted. * * @param {string} databaseId - Database ID. - * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. - * @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. - * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} data - Document data as JSON object. - * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} - * @returns {Promise<Document>} + * @returns {Promise<Models.DocumentList<Document>>} * @deprecated Use the object parameter style method for a better developer experience. */ - createDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], transactionId?: string): Promise<Document>; - createDocument<Document extends Models.Document = Models.DefaultDocument>( - paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, (string[])?, (string)?] - ): Promise<Document> { - let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], transactionId?: string }; + deleteDocuments<Document extends Models.Document = Models.DefaultDocument>(this: Databases<ServerAuth>, databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise<Models.DocumentList<Document>>; + deleteDocuments<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string[])?, (string)?] + ): Promise<Models.DocumentList<Document>> { + let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], transactionId?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, collectionId: rest[0] as string, - documentId: rest[1] as string, - data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, - permissions: rest[3] as string[], - transactionId: rest[4] as string + queries: rest[1] as string[], + transactionId: rest[2] as string }; } const databaseId = params.databaseId; const collectionId = params.collectionId; - const documentId = params.documentId; - const data = params.data; - const permissions = params.permissions; + const queries = params.queries; const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { @@ -491,23 +5289,11 @@ export class Databases { if (typeof collectionId === 'undefined') { throw new AppwriteException('Missing required parameter: "collectionId"'); } - if (typeof documentId === 'undefined') { - throw new AppwriteException('Missing required parameter: "documentId"'); - } - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; - if (typeof documentId !== 'undefined') { - payload['documentId'] = documentId; - } - if (typeof data !== 'undefined') { - payload['data'] = data; - } - if (typeof permissions !== 'undefined') { - payload['permissions'] = permissions; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; } if (typeof transactionId !== 'undefined') { payload['transactionId'] = transactionId; @@ -519,7 +5305,7 @@ export class Databases { } return this.client.call( - 'post', + 'delete', uri, apiHeaders, payload @@ -1051,4 +5837,326 @@ export class Databases { payload ); } + + /** + * List indexes in the collection. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.IndexList>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listIndexes` instead. + */ + listIndexes(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }): Promise<Models.IndexList>; + /** + * List indexes in the collection. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.IndexList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listIndexes(this: Databases<ServerAuth>, databaseId: string, collectionId: string, queries?: string[], total?: boolean): Promise<Models.IndexList>; + listIndexes( + paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?] + ): Promise<Models.IndexList> { + let params: { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], total?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + queries: rest[1] as string[], + total: rest[2] as boolean + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const queries = params.queries; + const total = params.total; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @param {DatabasesIndexType} params.type - Index type. + * @param {string[]} params.attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} params.lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise<Models.Index>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createIndex` instead. + */ + createIndex(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }): Promise<Models.Index>; + /** + * Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @param {DatabasesIndexType} type - Index type. + * @param {string[]} attributes - Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long. + * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise<Models.Index>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIndex(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[]): Promise<Models.Index>; + createIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] } | string, + ...rest: [(string)?, (string)?, (DatabasesIndexType)?, (string[])?, (OrderBy[])?, (number[])?] + ): Promise<Models.Index> { + let params: { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string, type: DatabasesIndexType, attributes: string[], orders?: OrderBy[], lengths?: number[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string, + type: rest[2] as DatabasesIndexType, + attributes: rest[3] as string[], + orders: rest[4] as OrderBy[], + lengths: rest[5] as number[] + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + const type = params.type; + const attributes = params.attributes; + const orders = params.orders; + const lengths = params.lengths; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof attributes === 'undefined') { + throw new AppwriteException('Missing required parameter: "attributes"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof attributes !== 'undefined') { + payload['attributes'] = attributes; + } + if (typeof orders !== 'undefined') { + payload['orders'] = orders; + } + if (typeof lengths !== 'undefined') { + payload['lengths'] = lengths; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get an index by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<Models.Index>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getIndex` instead. + */ + getIndex(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string }): Promise<Models.Index>; + /** + * Get an index by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<Models.Index>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getIndex(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string): Promise<Models.Index>; + getIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.Index> { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete an index. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.deleteIndex` instead. + */ + deleteIndex(this: Databases<ServerAuth>, params: { databaseId: string, collectionId: string, key: string }): Promise<{}>; + /** + * Delete an index. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteIndex(this: Databases<ServerAuth>, databaseId: string, collectionId: string, key: string): Promise<{}>; + deleteIndex( + paramsOrFirst: { databaseId: string, collectionId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, collectionId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } } + +const Databases = DatabasesRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): Databases<TAuth>; +}; + +export { Databases }; diff --git a/src/services/functions.ts b/src/services/functions.ts index fc3f50ce..00e2e474 100644 --- a/src/services/functions.ts +++ b/src/services/functions.ts @@ -1,41 +1,1686 @@ import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; +import { Runtime } from '../enums/runtime'; +import { Scopes } from '../enums/scopes'; +import { TemplateReferenceType } from '../enums/template-reference-type'; +import { VCSReferenceType } from '../enums/vcs-reference-type'; +import { DeploymentDownloadType } from '../enums/deployment-download-type'; import { ExecutionMethod } from '../enums/execution-method'; -export class Functions { - client: Client; +type FunctionsServerOnlyMethod = 'list' | 'create' | 'listRuntimes' | 'listSpecifications' | 'get' | 'update' | 'delete' | 'updateFunctionDeployment' | 'listDeployments' | 'createDeployment' | 'createDuplicateDeployment' | 'createTemplateDeployment' | 'createVcsDeployment' | 'getDeployment' | 'deleteDeployment' | 'getDeploymentDownload' | 'updateDeploymentStatus' | 'deleteExecution' | 'listVariables' | 'createVariable' | 'getVariable' | 'updateVariable' | 'deleteVariable'; +type FunctionsClientOnlyMethod = never; - constructor(client: Client) { +export type Functions<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<FunctionsRuntime<TAuth>, 'client' | FunctionsServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<FunctionsRuntime<TAuth>, 'client' | FunctionsClientOnlyMethod> + : Omit<FunctionsRuntime<TAuth>, 'client'>; + +class FunctionsRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } /** - * Get a list of all the current user function execution logs. You can use the query params to filter your results. + * Get a list of all the project's functions. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.FunctionList>} + */ + list(this: Functions<ServerAuth>, params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.FunctionList>; + /** + * Get a list of all the project's functions. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.FunctionList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(this: Functions<ServerAuth>, queries?: string[], search?: string, total?: boolean): Promise<Models.FunctionList>; + list( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise<Models.FunctionList> { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/functions'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. + * + * @param {string} params.functionId - Function ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Function name. Max length: 128 chars. + * @param {Runtime} params.runtime - Execution runtime. + * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. + * @param {string} params.schedule - Schedule CRON syntax. + * @param {number} params.timeout - Function maximum execution time in seconds. + * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. + * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. + * @param {string} params.entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". + * @param {string} params.commands - Build Commands. + * @param {Scopes[]} params.scopes - List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function. + * @param {string} params.providerBranch - Production branch for the repo linked to the function. + * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. + * @param {string} params.providerRootDirectory - Path to function code in the linked repo. + * @param {string} params.buildSpecification - Build specification for the function deployments. + * @param {string} params.runtimeSpecification - Runtime specification for the function executions. + * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + */ + create(this: Functions<ServerAuth>, params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise<Models.Function>; + /** + * Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API. + * + * @param {string} functionId - Function ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Function name. Max length: 128 chars. + * @param {Runtime} runtime - Execution runtime. + * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {string[]} events - Events list. Maximum of 100 events are allowed. + * @param {string} schedule - Schedule CRON syntax. + * @param {number} timeout - Function maximum execution time in seconds. + * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. + * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. + * @param {string} entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". + * @param {string} commands - Build Commands. + * @param {Scopes[]} scopes - List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} providerRepositoryId - Repository ID of the repo linked to the function. + * @param {string} providerBranch - Production branch for the repo linked to the function. + * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. + * @param {string} providerRootDirectory - Path to function code in the linked repo. + * @param {string} buildSpecification - Build specification for the function deployments. + * @param {string} runtimeSpecification - Runtime specification for the function executions. + * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(this: Functions<ServerAuth>, functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise<Models.Function>; + create( + paramsOrFirst: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (Scopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] + ): Promise<Models.Function> { + let params: { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + } else { + params = { + functionId: paramsOrFirst as string, + name: rest[0] as string, + runtime: rest[1] as Runtime, + execute: rest[2] as string[], + events: rest[3] as string[], + schedule: rest[4] as string, + timeout: rest[5] as number, + enabled: rest[6] as boolean, + logging: rest[7] as boolean, + entrypoint: rest[8] as string, + commands: rest[9] as string, + scopes: rest[10] as Scopes[], + installationId: rest[11] as string, + providerRepositoryId: rest[12] as string, + providerBranch: rest[13] as string, + providerSilentMode: rest[14] as boolean, + providerRootDirectory: rest[15] as string, + buildSpecification: rest[16] as string, + runtimeSpecification: rest[17] as string, + deploymentRetention: rest[18] as number + }; + } + + const functionId = params.functionId; + const name = params.name; + const runtime = params.runtime; + const execute = params.execute; + const events = params.events; + const schedule = params.schedule; + const timeout = params.timeout; + const enabled = params.enabled; + const logging = params.logging; + const entrypoint = params.entrypoint; + const commands = params.commands; + const scopes = params.scopes; + const installationId = params.installationId; + const providerRepositoryId = params.providerRepositoryId; + const providerBranch = params.providerBranch; + const providerSilentMode = params.providerSilentMode; + const providerRootDirectory = params.providerRootDirectory; + const buildSpecification = params.buildSpecification; + const runtimeSpecification = params.runtimeSpecification; + const deploymentRetention = params.deploymentRetention; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof runtime === 'undefined') { + throw new AppwriteException('Missing required parameter: "runtime"'); + } + + const apiPath = '/functions'; + const payload: Payload = {}; + if (typeof functionId !== 'undefined') { + payload['functionId'] = functionId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof runtime !== 'undefined') { + payload['runtime'] = runtime; + } + if (typeof execute !== 'undefined') { + payload['execute'] = execute; + } + if (typeof events !== 'undefined') { + payload['events'] = events; + } + if (typeof schedule !== 'undefined') { + payload['schedule'] = schedule; + } + if (typeof timeout !== 'undefined') { + payload['timeout'] = timeout; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof logging !== 'undefined') { + payload['logging'] = logging; + } + if (typeof entrypoint !== 'undefined') { + payload['entrypoint'] = entrypoint; + } + if (typeof commands !== 'undefined') { + payload['commands'] = commands; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof installationId !== 'undefined') { + payload['installationId'] = installationId; + } + if (typeof providerRepositoryId !== 'undefined') { + payload['providerRepositoryId'] = providerRepositoryId; + } + if (typeof providerBranch !== 'undefined') { + payload['providerBranch'] = providerBranch; + } + if (typeof providerSilentMode !== 'undefined') { + payload['providerSilentMode'] = providerSilentMode; + } + if (typeof providerRootDirectory !== 'undefined') { + payload['providerRootDirectory'] = providerRootDirectory; + } + if (typeof buildSpecification !== 'undefined') { + payload['buildSpecification'] = buildSpecification; + } + if (typeof runtimeSpecification !== 'undefined') { + payload['runtimeSpecification'] = runtimeSpecification; + } + if (typeof deploymentRetention !== 'undefined') { + payload['deploymentRetention'] = deploymentRetention; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all runtimes that are currently active on your instance. + * + * @throws {AppwriteException} + * @returns {Promise<Models.RuntimeList>} + */ + listRuntimes(this: Functions<ServerAuth>, ): Promise<Models.RuntimeList>; + listRuntimes(): Promise<Models.RuntimeList> { + + const apiPath = '/functions/runtimes'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * List allowed function specifications for this instance. + * + * @throws {AppwriteException} + * @returns {Promise<Models.SpecificationList>} + */ + listSpecifications(this: Functions<ServerAuth>, ): Promise<Models.SpecificationList>; + listSpecifications(): Promise<Models.SpecificationList> { + + const apiPath = '/functions/specifications'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a function by its unique ID. + * + * @param {string} params.functionId - Function ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + */ + get(this: Functions<ServerAuth>, params: { functionId: string }): Promise<Models.Function>; + /** + * Get a function by its unique ID. + * + * @param {string} functionId - Function ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(this: Functions<ServerAuth>, functionId: string): Promise<Models.Function>; + get( + paramsOrFirst: { functionId: string } | string + ): Promise<Models.Function> { + let params: { functionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string }; + } else { + params = { + functionId: paramsOrFirst as string + }; + } + + const functionId = params.functionId; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update function by its unique ID. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.name - Function name. Max length: 128 chars. + * @param {Runtime} params.runtime - Execution runtime. + * @param {string[]} params.execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. + * @param {string} params.schedule - Schedule CRON syntax. + * @param {number} params.timeout - Maximum execution time in seconds. + * @param {boolean} params.enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. + * @param {boolean} params.logging - When disabled, executions will exclude logs and errors, and will be slightly faster. + * @param {string} params.entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". + * @param {string} params.commands - Build Commands. + * @param {Scopes[]} params.scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. + * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the function + * @param {string} params.providerBranch - Production branch for the repo linked to the function + * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. + * @param {string} params.providerRootDirectory - Path to function code in the linked repo. + * @param {string} params.buildSpecification - Build specification for the function deployments. + * @param {string} params.runtimeSpecification - Runtime specification for the function executions. + * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + */ + update(this: Functions<ServerAuth>, params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise<Models.Function>; + /** + * Update function by its unique ID. + * + * @param {string} functionId - Function ID. + * @param {string} name - Function name. Max length: 128 chars. + * @param {Runtime} runtime - Execution runtime. + * @param {string[]} execute - An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @param {string[]} events - Events list. Maximum of 100 events are allowed. + * @param {string} schedule - Schedule CRON syntax. + * @param {number} timeout - Maximum execution time in seconds. + * @param {boolean} enabled - Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled. + * @param {boolean} logging - When disabled, executions will exclude logs and errors, and will be slightly faster. + * @param {string} entrypoint - Entrypoint File. This path is relative to the "providerRootDirectory". + * @param {string} commands - Build Commands. + * @param {Scopes[]} scopes - List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. + * @param {string} installationId - Appwrite Installation ID for VCS (Version Controle System) deployment. + * @param {string} providerRepositoryId - Repository ID of the repo linked to the function + * @param {string} providerBranch - Production branch for the repo linked to the function + * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests. + * @param {string} providerRootDirectory - Path to function code in the linked repo. + * @param {string} buildSpecification - Build specification for the function deployments. + * @param {string} runtimeSpecification - Runtime specification for the function executions. + * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(this: Functions<ServerAuth>, functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise<Models.Function>; + update( + paramsOrFirst: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (Runtime)?, (string[])?, (string[])?, (string)?, (number)?, (boolean)?, (boolean)?, (string)?, (string)?, (Scopes[])?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] + ): Promise<Models.Function> { + let params: { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, scopes?: Scopes[], installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + } else { + params = { + functionId: paramsOrFirst as string, + name: rest[0] as string, + runtime: rest[1] as Runtime, + execute: rest[2] as string[], + events: rest[3] as string[], + schedule: rest[4] as string, + timeout: rest[5] as number, + enabled: rest[6] as boolean, + logging: rest[7] as boolean, + entrypoint: rest[8] as string, + commands: rest[9] as string, + scopes: rest[10] as Scopes[], + installationId: rest[11] as string, + providerRepositoryId: rest[12] as string, + providerBranch: rest[13] as string, + providerSilentMode: rest[14] as boolean, + providerRootDirectory: rest[15] as string, + buildSpecification: rest[16] as string, + runtimeSpecification: rest[17] as string, + deploymentRetention: rest[18] as number + }; + } + + const functionId = params.functionId; + const name = params.name; + const runtime = params.runtime; + const execute = params.execute; + const events = params.events; + const schedule = params.schedule; + const timeout = params.timeout; + const enabled = params.enabled; + const logging = params.logging; + const entrypoint = params.entrypoint; + const commands = params.commands; + const scopes = params.scopes; + const installationId = params.installationId; + const providerRepositoryId = params.providerRepositoryId; + const providerBranch = params.providerBranch; + const providerSilentMode = params.providerSilentMode; + const providerRootDirectory = params.providerRootDirectory; + const buildSpecification = params.buildSpecification; + const runtimeSpecification = params.runtimeSpecification; + const deploymentRetention = params.deploymentRetention; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof runtime !== 'undefined') { + payload['runtime'] = runtime; + } + if (typeof execute !== 'undefined') { + payload['execute'] = execute; + } + if (typeof events !== 'undefined') { + payload['events'] = events; + } + if (typeof schedule !== 'undefined') { + payload['schedule'] = schedule; + } + if (typeof timeout !== 'undefined') { + payload['timeout'] = timeout; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof logging !== 'undefined') { + payload['logging'] = logging; + } + if (typeof entrypoint !== 'undefined') { + payload['entrypoint'] = entrypoint; + } + if (typeof commands !== 'undefined') { + payload['commands'] = commands; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof installationId !== 'undefined') { + payload['installationId'] = installationId; + } + if (typeof providerRepositoryId !== 'undefined') { + payload['providerRepositoryId'] = providerRepositoryId; + } + if (typeof providerBranch !== 'undefined') { + payload['providerBranch'] = providerBranch; + } + if (typeof providerSilentMode !== 'undefined') { + payload['providerSilentMode'] = providerSilentMode; + } + if (typeof providerRootDirectory !== 'undefined') { + payload['providerRootDirectory'] = providerRootDirectory; + } + if (typeof buildSpecification !== 'undefined') { + payload['buildSpecification'] = buildSpecification; + } + if (typeof runtimeSpecification !== 'undefined') { + payload['runtimeSpecification'] = runtimeSpecification; + } + if (typeof deploymentRetention !== 'undefined') { + payload['deploymentRetention'] = deploymentRetention; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a function by its unique ID. + * + * @param {string} params.functionId - Function ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(this: Functions<ServerAuth>, params: { functionId: string }): Promise<{}>; + /** + * Delete a function by its unique ID. + * + * @param {string} functionId - Function ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(this: Functions<ServerAuth>, functionId: string): Promise<{}>; + delete( + paramsOrFirst: { functionId: string } | string + ): Promise<{}> { + let params: { functionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string }; + } else { + params = { + functionId: paramsOrFirst as string + }; + } + + const functionId = params.functionId; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + */ + updateFunctionDeployment(this: Functions<ServerAuth>, params: { functionId: string, deploymentId: string }): Promise<Models.Function>; + /** + * Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Function>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateFunctionDeployment(this: Functions<ServerAuth>, functionId: string, deploymentId: string): Promise<Models.Function>; + updateFunctionDeployment( + paramsOrFirst: { functionId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Function> { + let params: { functionId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/functions/{functionId}/deployment'.replace('{functionId}', functionId); + const payload: Payload = {}; + if (typeof deploymentId !== 'undefined') { + payload['deploymentId'] = deploymentId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all the function's code deployments. You can use the query params to filter your results. + * + * @param {string} params.functionId - Function ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.DeploymentList>} + */ + listDeployments(this: Functions<ServerAuth>, params: { functionId: string, queries?: string[], search?: string, total?: boolean }): Promise<Models.DeploymentList>; + /** + * Get a list of all the function's code deployments. You can use the query params to filter your results. + * + * @param {string} functionId - Function ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.DeploymentList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listDeployments(this: Functions<ServerAuth>, functionId: string, queries?: string[], search?: string, total?: boolean): Promise<Models.DeploymentList>; + listDeployments( + paramsOrFirst: { functionId: string, queries?: string[], search?: string, total?: boolean } | string, + ...rest: [(string[])?, (string)?, (boolean)?] + ): Promise<Models.DeploymentList> { + let params: { functionId: string, queries?: string[], search?: string, total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, queries?: string[], search?: string, total?: boolean }; + } else { + params = { + functionId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string, + total: rest[2] as boolean + }; + } + + const functionId = params.functionId; + const queries = params.queries; + const search = params.search; + const total = params.total; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. + * + * This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). + * + * Use the "command" param to set the entrypoint used to execute your code. + * + * @param {string} params.functionId - Function ID. + * @param {File} params.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. + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. + * @param {string} params.entrypoint - Entrypoint File. + * @param {string} params.commands - Build Commands. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createDeployment(this: Functions<ServerAuth>, params: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void }): Promise<Models.Deployment>; + /** + * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. + * + * This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). + * + * Use the "command" param to set the entrypoint used to execute your code. + * + * @param {string} functionId - Function ID. + * @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. + * @param {boolean} activate - Automatically activate the deployment when it is finished building. + * @param {string} entrypoint - Entrypoint File. + * @param {string} commands - Build Commands. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDeployment(this: Functions<ServerAuth>, functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void): Promise<Models.Deployment>; + createDeployment( + paramsOrFirst: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress?: (progress: UploadProgress) => void } | string, + ...rest: [(File)?, (boolean)?, (string)?, (string)?,((progress: UploadProgress) => void)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string }; + let onProgress: ((progress: UploadProgress) => void); + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string }; + onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + } else { + params = { + functionId: paramsOrFirst as string, + code: rest[0] as File, + activate: rest[1] as boolean, + entrypoint: rest[2] as string, + commands: rest[3] as string + }; + onProgress = rest[4] as ((progress: UploadProgress) => void); + } + + const functionId = params.functionId; + const code = params.code; + const activate = params.activate; + const entrypoint = params.entrypoint; + const commands = params.commands; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof code === 'undefined') { + throw new AppwriteException('Missing required parameter: "code"'); + } + if (typeof activate === 'undefined') { + throw new AppwriteException('Missing required parameter: "activate"'); + } + + const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); + const payload: Payload = {}; + if (typeof entrypoint !== 'undefined') { + payload['entrypoint'] = entrypoint; + } + if (typeof commands !== 'undefined') { + payload['commands'] = commands; + } + if (typeof code !== 'undefined') { + payload['code'] = code; + } + if (typeof activate !== 'undefined') { + payload['activate'] = activate; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'multipart/form-data', + } + + return this.client.chunkedUpload( + 'post', + uri, + apiHeaders, + payload, + onProgress + ); + } + + /** + * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. + * @param {string} params.buildId - Build unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createDuplicateDeployment(this: Functions<ServerAuth>, params: { functionId: string, deploymentId: string, buildId?: string }): Promise<Models.Deployment>; + /** + * Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. + * @param {string} buildId - Build unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDuplicateDeployment(this: Functions<ServerAuth>, functionId: string, deploymentId: string, buildId?: string): Promise<Models.Deployment>; + createDuplicateDeployment( + paramsOrFirst: { functionId: string, deploymentId: string, buildId?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, deploymentId: string, buildId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string, buildId?: string }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string, + buildId: rest[1] as string + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + const buildId = params.buildId; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/functions/{functionId}/deployments/duplicate'.replace('{functionId}', functionId); + const payload: Payload = {}; + if (typeof deploymentId !== 'undefined') { + payload['deploymentId'] = deploymentId; + } + if (typeof buildId !== 'undefined') { + payload['buildId'] = buildId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a deployment based on a template. + * + * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.repository - Repository name of the template. + * @param {string} params.owner - The name of the owner of the template. + * @param {string} params.rootDirectory - Path to function code in the template repo. + * @param {TemplateReferenceType} params.type - Type for the reference provided. Can be commit, branch, or tag + * @param {string} params.reference - Reference value, can be a commit hash, branch name, or release tag + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createTemplateDeployment(this: Functions<ServerAuth>, params: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }): Promise<Models.Deployment>; + /** + * Create a deployment based on a template. + * + * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/functions/templates) to find the template details. + * + * @param {string} functionId - Function ID. + * @param {string} repository - Repository name of the template. + * @param {string} owner - The name of the owner of the template. + * @param {string} rootDirectory - Path to function code in the template repo. + * @param {TemplateReferenceType} type - Type for the reference provided. Can be commit, branch, or tag + * @param {string} reference - Reference value, can be a commit hash, branch name, or release tag + * @param {boolean} activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTemplateDeployment(this: Functions<ServerAuth>, functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean): Promise<Models.Deployment>; + createTemplateDeployment( + paramsOrFirst: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (TemplateReferenceType)?, (string)?, (boolean)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; + } else { + params = { + functionId: paramsOrFirst as string, + repository: rest[0] as string, + owner: rest[1] as string, + rootDirectory: rest[2] as string, + type: rest[3] as TemplateReferenceType, + reference: rest[4] as string, + activate: rest[5] as boolean + }; + } + + const functionId = params.functionId; + const repository = params.repository; + const owner = params.owner; + const rootDirectory = params.rootDirectory; + const type = params.type; + const reference = params.reference; + const activate = params.activate; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof repository === 'undefined') { + throw new AppwriteException('Missing required parameter: "repository"'); + } + if (typeof owner === 'undefined') { + throw new AppwriteException('Missing required parameter: "owner"'); + } + if (typeof rootDirectory === 'undefined') { + throw new AppwriteException('Missing required parameter: "rootDirectory"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof reference === 'undefined') { + throw new AppwriteException('Missing required parameter: "reference"'); + } + + const apiPath = '/functions/{functionId}/deployments/template'.replace('{functionId}', functionId); + const payload: Payload = {}; + if (typeof repository !== 'undefined') { + payload['repository'] = repository; + } + if (typeof owner !== 'undefined') { + payload['owner'] = owner; + } + if (typeof rootDirectory !== 'undefined') { + payload['rootDirectory'] = rootDirectory; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof reference !== 'undefined') { + payload['reference'] = reference; + } + if (typeof activate !== 'undefined') { + payload['activate'] = activate; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a deployment when a function is connected to VCS. + * + * This endpoint lets you create deployment from a branch, commit, or a tag. + * + * @param {string} params.functionId - Function ID. + * @param {VCSReferenceType} params.type - Type of reference passed. Allowed values are: branch, commit + * @param {string} params.reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createVcsDeployment(this: Functions<ServerAuth>, params: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }): Promise<Models.Deployment>; + /** + * Create a deployment when a function is connected to VCS. + * + * This endpoint lets you create deployment from a branch, commit, or a tag. + * + * @param {string} functionId - Function ID. + * @param {VCSReferenceType} type - Type of reference passed. Allowed values are: branch, commit + * @param {string} reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + * @param {boolean} activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVcsDeployment(this: Functions<ServerAuth>, functionId: string, type: VCSReferenceType, reference: string, activate?: boolean): Promise<Models.Deployment>; + createVcsDeployment( + paramsOrFirst: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean } | string, + ...rest: [(VCSReferenceType)?, (string)?, (boolean)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, type: VCSReferenceType, reference: string, activate?: boolean }; + } else { + params = { + functionId: paramsOrFirst as string, + type: rest[0] as VCSReferenceType, + reference: rest[1] as string, + activate: rest[2] as boolean + }; + } + + const functionId = params.functionId; + const type = params.type; + const reference = params.reference; + const activate = params.activate; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof reference === 'undefined') { + throw new AppwriteException('Missing required parameter: "reference"'); + } + + const apiPath = '/functions/{functionId}/deployments/vcs'.replace('{functionId}', functionId); + const payload: Payload = {}; + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof reference !== 'undefined') { + payload['reference'] = reference; + } + if (typeof activate !== 'undefined') { + payload['activate'] = activate; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a function deployment by its unique ID. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + getDeployment(this: Functions<ServerAuth>, params: { functionId: string, deploymentId: string }): Promise<Models.Deployment>; + /** + * Get a function deployment by its unique ID. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDeployment(this: Functions<ServerAuth>, functionId: string, deploymentId: string): Promise<Models.Deployment>; + getDeployment( + paramsOrFirst: { functionId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a code deployment by its unique ID. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteDeployment(this: Functions<ServerAuth>, params: { functionId: string, deploymentId: string }): Promise<{}>; + /** + * Delete a code deployment by its unique ID. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDeployment(this: Functions<ServerAuth>, functionId: string, deploymentId: string): Promise<{}>; + deleteDeployment( + paramsOrFirst: { functionId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { functionId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. + * @param {DeploymentDownloadType} params.type - Deployment file to download. Can be: "source", "output". + * @throws {AppwriteException} + * @returns {string} + */ + getDeploymentDownload(this: Functions<ServerAuth>, params: { functionId: string, deploymentId: string, type?: DeploymentDownloadType }): string; + /** + * Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. + * @param {DeploymentDownloadType} type - Deployment file to download. Can be: "source", "output". + * @throws {AppwriteException} + * @returns {string} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDeploymentDownload(this: Functions<ServerAuth>, functionId: string, deploymentId: string, type?: DeploymentDownloadType): string; + getDeploymentDownload( + paramsOrFirst: { functionId: string, deploymentId: string, type?: DeploymentDownloadType } | string, + ...rest: [(string)?, (DeploymentDownloadType)?] + ): string { + let params: { functionId: string, deploymentId: string, type?: DeploymentDownloadType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string, type?: DeploymentDownloadType }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string, + type: rest[1] as DeploymentDownloadType + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + const type = params.type; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); + const payload: Payload = {}; + if (typeof type !== 'undefined') { + payload['type'] = type; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; + + for (const [key, value] of Object.entries(Service.flatten(payload))) { + uri.searchParams.append(key, value); + } + + return uri.toString(); + } + + /** + * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + updateDeploymentStatus(this: Functions<ServerAuth>, params: { functionId: string, deploymentId: string }): Promise<Models.Deployment>; + /** + * Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * + * @param {string} functionId - Function ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDeploymentStatus(this: Functions<ServerAuth>, functionId: string, deploymentId: string): Promise<Models.Deployment>; + updateDeploymentStatus( + paramsOrFirst: { functionId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Deployment> { + let params: { functionId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, deploymentId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const functionId = params.functionId; + const deploymentId = params.deploymentId; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/functions/{functionId}/deployments/{deploymentId}/status'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all the current user function execution logs. You can use the query params to filter your results. + * + * @param {string} params.functionId - Function ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ExecutionList>} + */ + listExecutions(params: { functionId: string, queries?: string[], total?: boolean }): Promise<Models.ExecutionList>; + /** + * Get a list of all the current user function execution logs. You can use the query params to filter your results. + * + * @param {string} functionId - Function ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ExecutionList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listExecutions(functionId: string, queries?: string[], total?: boolean): Promise<Models.ExecutionList>; + listExecutions( + paramsOrFirst: { functionId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.ExecutionList> { + let params: { functionId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, queries?: string[], total?: boolean }; + } else { + params = { + functionId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const functionId = params.functionId; + const queries = params.queries; + const total = params.total; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.body - HTTP body of execution. Default value is empty string. + * @param {boolean} params.async - Execute code in the background. Default value is false. + * @param {string} params.xpath - HTTP path of execution. Path can include query params. Default value is / + * @param {ExecutionMethod} params.method - HTTP method of execution. Default value is POST. + * @param {object} params.headers - HTTP headers of execution. Defaults to empty. + * @param {string} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @throws {AppwriteException} + * @returns {Promise<Models.Execution>} + */ + createExecution(params: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }): Promise<Models.Execution>; + /** + * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. + * + * @param {string} functionId - Function ID. + * @param {string} body - HTTP body of execution. Default value is empty string. + * @param {boolean} async - Execute code in the background. Default value is false. + * @param {string} xpath - HTTP path of execution. Path can include query params. Default value is / + * @param {ExecutionMethod} method - HTTP method of execution. Default value is POST. + * @param {object} headers - HTTP headers of execution. Defaults to empty. + * @param {string} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @throws {AppwriteException} + * @returns {Promise<Models.Execution>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise<Models.Execution>; + createExecution( + paramsOrFirst: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (ExecutionMethod)?, (object)?, (string)?] + ): Promise<Models.Execution> { + let params: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }; + } else { + params = { + functionId: paramsOrFirst as string, + body: rest[0] as string, + async: rest[1] as boolean, + xpath: rest[2] as string, + method: rest[3] as ExecutionMethod, + headers: rest[4] as object, + scheduledAt: rest[5] as string + }; + } + + const functionId = params.functionId; + const body = params.body; + const async = params.async; + const xpath = params.xpath; + const method = params.method; + const headers = params.headers; + const scheduledAt = params.scheduledAt; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId); + const payload: Payload = {}; + if (typeof body !== 'undefined') { + payload['body'] = body; + } + if (typeof async !== 'undefined') { + payload['async'] = async; + } + if (typeof xpath !== 'undefined') { + payload['path'] = xpath; + } + if (typeof method !== 'undefined') { + payload['method'] = method; + } + if (typeof headers !== 'undefined') { + payload['headers'] = headers; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a function execution log by its unique ID. + * + * @param {string} params.functionId - Function ID. + * @param {string} params.executionId - Execution ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Execution>} + */ + getExecution(params: { functionId: string, executionId: string }): Promise<Models.Execution>; + /** + * Get a function execution log by its unique ID. + * + * @param {string} functionId - Function ID. + * @param {string} executionId - Execution ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Execution>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getExecution(functionId: string, executionId: string): Promise<Models.Execution>; + getExecution( + paramsOrFirst: { functionId: string, executionId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Execution> { + let params: { functionId: string, executionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, executionId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + executionId: rest[0] as string + }; + } + + const functionId = params.functionId; + const executionId = params.executionId; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof executionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + + const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a function execution by its unique ID. * * @param {string} params.functionId - Function ID. - * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId - * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @param {string} params.executionId - Execution ID. * @throws {AppwriteException} - * @returns {Promise<Models.ExecutionList>} + * @returns {Promise<{}>} */ - listExecutions(params: { functionId: string, queries?: string[], total?: boolean }): Promise<Models.ExecutionList>; + deleteExecution(this: Functions<ServerAuth>, params: { functionId: string, executionId: string }): Promise<{}>; /** - * Get a list of all the current user function execution logs. You can use the query params to filter your results. + * Delete a function execution by its unique ID. * * @param {string} functionId - Function ID. - * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + * @param {string} executionId - Execution ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteExecution(this: Functions<ServerAuth>, functionId: string, executionId: string): Promise<{}>; + deleteExecution( + paramsOrFirst: { functionId: string, executionId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { functionId: string, executionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, executionId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + executionId: rest[0] as string + }; + } + + const functionId = params.functionId; + const executionId = params.executionId; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof executionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + + const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all variables of a specific function. + * + * @param {string} params.functionId - Function unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.VariableList>} + */ + listVariables(this: Functions<ServerAuth>, params: { functionId: string, queries?: string[], total?: boolean }): Promise<Models.VariableList>; + /** + * Get a list of all variables of a specific function. + * + * @param {string} functionId - Function unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. * @throws {AppwriteException} - * @returns {Promise<Models.ExecutionList>} + * @returns {Promise<Models.VariableList>} * @deprecated Use the object parameter style method for a better developer experience. */ - listExecutions(functionId: string, queries?: string[], total?: boolean): Promise<Models.ExecutionList>; - listExecutions( + listVariables(this: Functions<ServerAuth>, functionId: string, queries?: string[], total?: boolean): Promise<Models.VariableList>; + listVariables( paramsOrFirst: { functionId: string, queries?: string[], total?: boolean } | string, ...rest: [(string[])?, (boolean)?] - ): Promise<Models.ExecutionList> { + ): Promise<Models.VariableList> { let params: { functionId: string, queries?: string[], total?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { @@ -56,7 +1701,7 @@ export class Functions { throw new AppwriteException('Missing required parameter: "functionId"'); } - const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId); + const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId); const payload: Payload = {}; if (typeof queries !== 'undefined') { payload['queries'] = queries; @@ -78,85 +1723,80 @@ export class Functions { } /** - * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. + * Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. * - * @param {string} params.functionId - Function ID. - * @param {string} params.body - HTTP body of execution. Default value is empty string. - * @param {boolean} params.async - Execute code in the background. Default value is false. - * @param {string} params.xpath - HTTP path of execution. Path can include query params. Default value is / - * @param {ExecutionMethod} params.method - HTTP method of execution. Default value is POST. - * @param {object} params.headers - HTTP headers of execution. Defaults to empty. - * @param {string} params.scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string} params.functionId - Function unique ID. + * @param {string} params.variableId - Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} - * @returns {Promise<Models.Execution>} + * @returns {Promise<Models.Variable>} */ - createExecution(params: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }): Promise<Models.Execution>; + createVariable(this: Functions<ServerAuth>, params: { functionId: string, variableId: string, key: string, value: string, secret?: boolean }): Promise<Models.Variable>; /** - * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously. + * Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables. * - * @param {string} functionId - Function ID. - * @param {string} body - HTTP body of execution. Default value is empty string. - * @param {boolean} async - Execute code in the background. Default value is false. - * @param {string} xpath - HTTP path of execution. Path can include query params. Default value is / - * @param {ExecutionMethod} method - HTTP method of execution. Default value is POST. - * @param {object} headers - HTTP headers of execution. Defaults to empty. - * @param {string} scheduledAt - Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. + * @param {string} functionId - Function unique ID. + * @param {string} variableId - Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. * @throws {AppwriteException} - * @returns {Promise<Models.Execution>} + * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. */ - createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string): Promise<Models.Execution>; - createExecution( - paramsOrFirst: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (ExecutionMethod)?, (object)?, (string)?] - ): Promise<Models.Execution> { - let params: { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }; + createVariable(this: Functions<ServerAuth>, functionId: string, variableId: string, key: string, value: string, secret?: boolean): Promise<Models.Variable>; + createVariable( + paramsOrFirst: { functionId: string, variableId: string, key: string, value: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Variable> { + let params: { functionId: string, variableId: string, key: string, value: string, secret?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object, scheduledAt?: string }; + params = (paramsOrFirst || {}) as { functionId: string, variableId: string, key: string, value: string, secret?: boolean }; } else { params = { functionId: paramsOrFirst as string, - body: rest[0] as string, - async: rest[1] as boolean, - xpath: rest[2] as string, - method: rest[3] as ExecutionMethod, - headers: rest[4] as object, - scheduledAt: rest[5] as string + variableId: rest[0] as string, + key: rest[1] as string, + value: rest[2] as string, + secret: rest[3] as boolean }; } const functionId = params.functionId; - const body = params.body; - const async = params.async; - const xpath = params.xpath; - const method = params.method; - const headers = params.headers; - const scheduledAt = params.scheduledAt; + const variableId = params.variableId; + const key = params.key; + const value = params.value; + const secret = params.secret; if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } - - const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId); - const payload: Payload = {}; - if (typeof body !== 'undefined') { - payload['body'] = body; + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); } - if (typeof async !== 'undefined') { - payload['async'] = async; + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); } - if (typeof xpath !== 'undefined') { - payload['path'] = xpath; + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); } - if (typeof method !== 'undefined') { - payload['method'] = method; + + const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId); + const payload: Payload = {}; + if (typeof variableId !== 'undefined') { + payload['variableId'] = variableId; } - if (typeof headers !== 'undefined') { - payload['headers'] = headers; + if (typeof key !== 'undefined') { + payload['key'] = key; } - if (typeof scheduledAt !== 'undefined') { - payload['scheduledAt'] = scheduledAt; + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; } const uri = new URL(this.client.config.endpoint + apiPath); @@ -173,50 +1813,50 @@ export class Functions { } /** - * Get a function execution log by its unique ID. + * Get a variable by its unique ID. * - * @param {string} params.functionId - Function ID. - * @param {string} params.executionId - Execution ID. + * @param {string} params.functionId - Function unique ID. + * @param {string} params.variableId - Variable unique ID. * @throws {AppwriteException} - * @returns {Promise<Models.Execution>} + * @returns {Promise<Models.Variable>} */ - getExecution(params: { functionId: string, executionId: string }): Promise<Models.Execution>; + getVariable(this: Functions<ServerAuth>, params: { functionId: string, variableId: string }): Promise<Models.Variable>; /** - * Get a function execution log by its unique ID. + * Get a variable by its unique ID. * - * @param {string} functionId - Function ID. - * @param {string} executionId - Execution ID. + * @param {string} functionId - Function unique ID. + * @param {string} variableId - Variable unique ID. * @throws {AppwriteException} - * @returns {Promise<Models.Execution>} + * @returns {Promise<Models.Variable>} * @deprecated Use the object parameter style method for a better developer experience. */ - getExecution(functionId: string, executionId: string): Promise<Models.Execution>; - getExecution( - paramsOrFirst: { functionId: string, executionId: string } | string, + getVariable(this: Functions<ServerAuth>, functionId: string, variableId: string): Promise<Models.Variable>; + getVariable( + paramsOrFirst: { functionId: string, variableId: string } | string, ...rest: [(string)?] - ): Promise<Models.Execution> { - let params: { functionId: string, executionId: string }; + ): Promise<Models.Variable> { + let params: { functionId: string, variableId: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { functionId: string, executionId: string }; + params = (paramsOrFirst || {}) as { functionId: string, variableId: string }; } else { params = { functionId: paramsOrFirst as string, - executionId: rest[0] as string + variableId: rest[0] as string }; } const functionId = params.functionId; - const executionId = params.executionId; + const variableId = params.variableId; if (typeof functionId === 'undefined') { throw new AppwriteException('Missing required parameter: "functionId"'); } - if (typeof executionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "executionId"'); + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); } - const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); + const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); @@ -230,4 +1870,151 @@ export class Functions { payload ); } + + /** + * Update variable by its unique ID. + * + * @param {string} params.functionId - Function unique ID. + * @param {string} params.variableId - Variable unique ID. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + */ + updateVariable(this: Functions<ServerAuth>, params: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }): Promise<Models.Variable>; + /** + * Update variable by its unique ID. + * + * @param {string} functionId - Function unique ID. + * @param {string} variableId - Variable unique ID. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only functions can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateVariable(this: Functions<ServerAuth>, functionId: string, variableId: string, key?: string, value?: string, secret?: boolean): Promise<Models.Variable>; + updateVariable( + paramsOrFirst: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Variable> { + let params: { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, variableId: string, key?: string, value?: string, secret?: boolean }; + } else { + params = { + functionId: paramsOrFirst as string, + variableId: rest[0] as string, + key: rest[1] as string, + value: rest[2] as string, + secret: rest[3] as boolean + }; + } + + const functionId = params.functionId; + const variableId = params.variableId; + const key = params.key; + const value = params.value; + const secret = params.secret; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a variable by its unique ID. + * + * @param {string} params.functionId - Function unique ID. + * @param {string} params.variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteVariable(this: Functions<ServerAuth>, params: { functionId: string, variableId: string }): Promise<{}>; + /** + * Delete a variable by its unique ID. + * + * @param {string} functionId - Function unique ID. + * @param {string} variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteVariable(this: Functions<ServerAuth>, functionId: string, variableId: string): Promise<{}>; + deleteVariable( + paramsOrFirst: { functionId: string, variableId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { functionId: string, variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { functionId: string, variableId: string }; + } else { + params = { + functionId: paramsOrFirst as string, + variableId: rest[0] as string + }; + } + + const functionId = params.functionId; + const variableId = params.variableId; + + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } } + +const Functions = FunctionsRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): Functions<TAuth>; +}; + +export { Functions }; diff --git a/src/services/graphql.ts b/src/services/graphql.ts index e995f66e..5068c21d 100644 --- a/src/services/graphql.ts +++ b/src/services/graphql.ts @@ -1,12 +1,21 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload } from '../client'; import type { Models } from '../models'; -export class Graphql { - client: Client; +type GraphqlServerOnlyMethod = never; +type GraphqlClientOnlyMethod = never; - constructor(client: Client) { +export type Graphql<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<GraphqlRuntime<TAuth>, 'client' | GraphqlServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<GraphqlRuntime<TAuth>, 'client' | GraphqlClientOnlyMethod> + : Omit<GraphqlRuntime<TAuth>, 'client'>; + +class GraphqlRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } @@ -122,3 +131,9 @@ export class Graphql { ); } } + +const Graphql = GraphqlRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): Graphql<TAuth>; +}; + +export { Graphql }; diff --git a/src/services/health.ts b/src/services/health.ts new file mode 100644 index 00000000..32578a39 --- /dev/null +++ b/src/services/health.ts @@ -0,0 +1,1050 @@ +import { AppwriteException, Client, type ServerAuth, type Payload } from '../client'; +import type { Models } from '../models'; + +import { Name } from '../enums/name'; + +export type Health = Omit<HealthRuntime, 'client'>; + +class HealthRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * Check the Appwrite HTTP server is up and responsive. + * + * @throws {AppwriteException} + * @returns {Promise<Models.HealthStatus>} + */ + get(): Promise<Models.HealthStatus> { + + const apiPath = '/health'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Check the Appwrite Antivirus server is up and connection is successful. + * + * @throws {AppwriteException} + * @returns {Promise<Models.HealthAntivirus>} + */ + getAntivirus(): Promise<Models.HealthAntivirus> { + + const apiPath = '/health/anti-virus'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Check the Appwrite in-memory cache servers are up and connection is successful. + * + * @throws {AppwriteException} + * @returns {Promise<Models.HealthStatusList>} + */ + getCache(): Promise<Models.HealthStatusList> { + + const apiPath = '/health/cache'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the SSL certificate for a domain + * + * @param {string} params.domain - string + * @throws {AppwriteException} + * @returns {Promise<Models.HealthCertificate>} + */ + getCertificate(params?: { domain?: string }): Promise<Models.HealthCertificate>; + /** + * Get the SSL certificate for a domain + * + * @param {string} domain - string + * @throws {AppwriteException} + * @returns {Promise<Models.HealthCertificate>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getCertificate(domain?: string): Promise<Models.HealthCertificate>; + getCertificate( + paramsOrFirst?: { domain?: string } | string + ): Promise<Models.HealthCertificate> { + let params: { domain?: string }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain?: string }; + } else { + params = { + domain: paramsOrFirst as string + }; + } + + const domain = params.domain; + + + const apiPath = '/health/certificate'; + const payload: Payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get console pausing health status. Monitors projects approaching the pause threshold to detect potential issues with console access tracking. + * + * + * @param {number} params.threshold - Percentage threshold of projects approaching pause. When hit (equal or higher), endpoint returns server error. Default value is 10. + * @param {number} params.inactivityDays - Number of days of inactivity before a project is paused. Should match the plan's projectInactivityDays setting. Default value is 7. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthStatus>} + */ + getConsolePausing(params?: { threshold?: number, inactivityDays?: number }): Promise<Models.HealthStatus>; + /** + * Get console pausing health status. Monitors projects approaching the pause threshold to detect potential issues with console access tracking. + * + * + * @param {number} threshold - Percentage threshold of projects approaching pause. When hit (equal or higher), endpoint returns server error. Default value is 10. + * @param {number} inactivityDays - Number of days of inactivity before a project is paused. Should match the plan's projectInactivityDays setting. Default value is 7. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthStatus>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getConsolePausing(threshold?: number, inactivityDays?: number): Promise<Models.HealthStatus>; + getConsolePausing( + paramsOrFirst?: { threshold?: number, inactivityDays?: number } | number, + ...rest: [(number)?] + ): Promise<Models.HealthStatus> { + let params: { threshold?: number, inactivityDays?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number, inactivityDays?: number }; + } else { + params = { + threshold: paramsOrFirst as number, + inactivityDays: rest[0] as number + }; + } + + const threshold = params.threshold; + const inactivityDays = params.inactivityDays; + + + const apiPath = '/health/console-pausing'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + if (typeof inactivityDays !== 'undefined') { + payload['inactivityDays'] = inactivityDays; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Check the Appwrite database servers are up and connection is successful. + * + * @throws {AppwriteException} + * @returns {Promise<Models.HealthStatusList>} + */ + getDB(): Promise<Models.HealthStatusList> { + + const apiPath = '/health/db'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Check the Appwrite pub-sub servers are up and connection is successful. + * + * @throws {AppwriteException} + * @returns {Promise<Models.HealthStatusList>} + */ + getPubSub(): Promise<Models.HealthStatusList> { + + const apiPath = '/health/pubsub'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of audit logs that are waiting to be processed in the Appwrite internal queue server. + * + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueAudits(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of audit logs that are waiting to be processed in the Appwrite internal queue server. + * + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueAudits(threshold?: number): Promise<Models.HealthQueue>; + getQueueAudits( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/audits'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of builds that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueBuilds(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of builds that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueBuilds(threshold?: number): Promise<Models.HealthQueue>; + getQueueBuilds( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/builds'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueCertificates(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueCertificates(threshold?: number): Promise<Models.HealthQueue>; + getQueueCertificates( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/certificates'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of database changes that are waiting to be processed in the Appwrite internal queue server. + * + * @param {string} params.name - Queue name for which to check the queue size + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueDatabases(params?: { name?: string, threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of database changes that are waiting to be processed in the Appwrite internal queue server. + * + * @param {string} name - Queue name for which to check the queue size + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueDatabases(name?: string, threshold?: number): Promise<Models.HealthQueue>; + getQueueDatabases( + paramsOrFirst?: { name?: string, threshold?: number } | string, + ...rest: [(number)?] + ): Promise<Models.HealthQueue> { + let params: { name?: string, threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { name?: string, threshold?: number }; + } else { + params = { + name: paramsOrFirst as string, + threshold: rest[0] as number + }; + } + + const name = params.name; + const threshold = params.threshold; + + + const apiPath = '/health/queue/databases'; + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of background destructive changes that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueDeletes(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of background destructive changes that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueDeletes(threshold?: number): Promise<Models.HealthQueue>; + getQueueDeletes( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/deletes'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Returns the amount of failed jobs in a given queue. + * + * + * @param {Name} params.name - The name of the queue + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getFailedJobs(params: { name: Name, threshold?: number }): Promise<Models.HealthQueue>; + /** + * Returns the amount of failed jobs in a given queue. + * + * + * @param {Name} name - The name of the queue + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getFailedJobs(name: Name, threshold?: number): Promise<Models.HealthQueue>; + getFailedJobs( + paramsOrFirst: { name: Name, threshold?: number } | Name, + ...rest: [(number)?] + ): Promise<Models.HealthQueue> { + let params: { name: Name, threshold?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('name' in paramsOrFirst || 'threshold' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { name: Name, threshold?: number }; + } else { + params = { + name: paramsOrFirst as Name, + threshold: rest[0] as number + }; + } + + const name = params.name; + const threshold = params.threshold; + + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/health/queue/failed/{name}'.replace('{name}', name); + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of function executions that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueFunctions(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of function executions that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueFunctions(threshold?: number): Promise<Models.HealthQueue>; + getQueueFunctions( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/functions'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of logs that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueLogs(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of logs that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueLogs(threshold?: number): Promise<Models.HealthQueue>; + getQueueLogs( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/logs'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of mails that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueMails(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of mails that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueMails(threshold?: number): Promise<Models.HealthQueue>; + getQueueMails( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/mails'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of messages that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueMessaging(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of messages that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueMessaging(threshold?: number): Promise<Models.HealthQueue>; + getQueueMessaging( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/messaging'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of migrations that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueMigrations(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of migrations that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueMigrations(threshold?: number): Promise<Models.HealthQueue>; + getQueueMigrations( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/migrations'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueStatsResources(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueStatsResources(threshold?: number): Promise<Models.HealthQueue>; + getQueueStatsResources( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/stats-resources'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of metrics that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueUsage(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of metrics that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueUsage(threshold?: number): Promise<Models.HealthQueue>; + getQueueUsage( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/stats-usage'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} params.threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + */ + getQueueWebhooks(params?: { threshold?: number }): Promise<Models.HealthQueue>; + /** + * Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. + * + * @param {number} threshold - Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + * @throws {AppwriteException} + * @returns {Promise<Models.HealthQueue>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getQueueWebhooks(threshold?: number): Promise<Models.HealthQueue>; + getQueueWebhooks( + paramsOrFirst?: { threshold?: number } | number + ): Promise<Models.HealthQueue> { + let params: { threshold?: number }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { threshold?: number }; + } else { + params = { + threshold: paramsOrFirst as number + }; + } + + const threshold = params.threshold; + + + const apiPath = '/health/queue/webhooks'; + const payload: Payload = {}; + if (typeof threshold !== 'undefined') { + payload['threshold'] = threshold; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Check the Appwrite storage device is up and connection is successful. + * + * @throws {AppwriteException} + * @returns {Promise<Models.HealthStatus>} + */ + getStorage(): Promise<Models.HealthStatus> { + + const apiPath = '/health/storage'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Check the Appwrite local storage device is up and connection is successful. + * + * @throws {AppwriteException} + * @returns {Promise<Models.HealthStatus>} + */ + getStorageLocal(): Promise<Models.HealthStatus> { + + const apiPath = '/health/storage/local'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP. + * + * @throws {AppwriteException} + * @returns {Promise<Models.HealthTime>} + */ + getTime(): Promise<Models.HealthTime> { + + const apiPath = '/health/time'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } +} + +const Health = HealthRuntime as unknown as { + new (client: Client<ServerAuth>): Health; +}; + +export { Health }; diff --git a/src/services/locale.ts b/src/services/locale.ts index fe85eeb5..c9a0b95f 100644 --- a/src/services/locale.ts +++ b/src/services/locale.ts @@ -1,12 +1,21 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload } from '../client'; import type { Models } from '../models'; -export class Locale { - client: Client; +type LocaleServerOnlyMethod = never; +type LocaleClientOnlyMethod = never; - constructor(client: Client) { +export type Locale<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<LocaleRuntime<TAuth>, 'client' | LocaleServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<LocaleRuntime<TAuth>, 'client' | LocaleClientOnlyMethod> + : Omit<LocaleRuntime<TAuth>, 'client'>; + +class LocaleRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } @@ -196,3 +205,9 @@ export class Locale { ); } } + +const Locale = LocaleRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): Locale<TAuth>; +}; + +export { Locale }; diff --git a/src/services/messaging.ts b/src/services/messaging.ts index d6c45bcd..117be78a 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -1,15 +1,4153 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload } from '../client'; import type { Models } from '../models'; +import { MessagePriority } from '../enums/message-priority'; +import { SmtpEncryption } from '../enums/smtp-encryption'; -export class Messaging { - client: Client; +type MessagingServerOnlyMethod = 'listMessages' | 'createEmail' | 'updateEmail' | 'createPush' | 'updatePush' | 'createSms' | 'updateSms' | 'getMessage' | 'delete' | 'listMessageLogs' | 'listTargets' | 'listProviders' | 'createApnsProvider' | 'updateApnsProvider' | 'createFcmProvider' | 'updateFcmProvider' | 'createMailgunProvider' | 'updateMailgunProvider' | 'createMsg91Provider' | 'updateMsg91Provider' | 'createResendProvider' | 'updateResendProvider' | 'createSendgridProvider' | 'updateSendgridProvider' | 'createSmtpProvider' | 'updateSmtpProvider' | 'createTelesignProvider' | 'updateTelesignProvider' | 'createTextmagicProvider' | 'updateTextmagicProvider' | 'createTwilioProvider' | 'updateTwilioProvider' | 'createVonageProvider' | 'updateVonageProvider' | 'getProvider' | 'deleteProvider' | 'listProviderLogs' | 'listSubscriberLogs' | 'listTopics' | 'createTopic' | 'getTopic' | 'updateTopic' | 'deleteTopic' | 'listTopicLogs' | 'listSubscribers' | 'getSubscriber'; +type MessagingClientOnlyMethod = never; - constructor(client: Client) { +export type Messaging<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<MessagingRuntime<TAuth>, 'client' | MessagingServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<MessagingRuntime<TAuth>, 'client' | MessagingClientOnlyMethod> + : Omit<MessagingRuntime<TAuth>, 'client'>; + +class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } + /** + * Get a list of all messages from the current Appwrite project. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.MessageList>} + */ + listMessages(this: Messaging<ServerAuth>, params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.MessageList>; + /** + * Get a list of all messages from the current Appwrite project. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.MessageList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listMessages(this: Messaging<ServerAuth>, queries?: string[], search?: string, total?: boolean): Promise<Models.MessageList>; + listMessages( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise<Models.MessageList> { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/messaging/messages'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new email message. + * + * @param {string} params.messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.subject - Email Subject. + * @param {string} params.content - Email Content. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {string[]} params.cc - Array of target IDs to be added as CC. + * @param {string[]} params.bcc - Array of target IDs to be added as BCC. + * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {boolean} params.draft - Is message a draft + * @param {boolean} params.html - Is content of type HTML + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + createEmail(this: Messaging<ServerAuth>, params: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }): Promise<Models.Message>; + /** + * Create a new email message. + * + * @param {string} messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} subject - Email Subject. + * @param {string} content - Email Content. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {string[]} cc - Array of target IDs to be added as CC. + * @param {string[]} bcc - Array of target IDs to be added as BCC. + * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {boolean} draft - Is message a draft + * @param {boolean} html - Is content of type HTML + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEmail(this: Messaging<ServerAuth>, messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string): Promise<Models.Message>; + createEmail( + paramsOrFirst: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (string[])?, (string[])?, (string[])?, (string[])?, (string[])?, (boolean)?, (boolean)?, (string)?] + ): Promise<Models.Message> { + let params: { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string }; + } else { + params = { + messageId: paramsOrFirst as string, + subject: rest[0] as string, + content: rest[1] as string, + topics: rest[2] as string[], + users: rest[3] as string[], + targets: rest[4] as string[], + cc: rest[5] as string[], + bcc: rest[6] as string[], + attachments: rest[7] as string[], + draft: rest[8] as boolean, + html: rest[9] as boolean, + scheduledAt: rest[10] as string + }; + } + + const messageId = params.messageId; + const subject = params.subject; + const content = params.content; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const cc = params.cc; + const bcc = params.bcc; + const attachments = params.attachments; + const draft = params.draft; + const html = params.html; + const scheduledAt = params.scheduledAt; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (typeof subject === 'undefined') { + throw new AppwriteException('Missing required parameter: "subject"'); + } + if (typeof content === 'undefined') { + throw new AppwriteException('Missing required parameter: "content"'); + } + + const apiPath = '/messaging/messages/email'; + const payload: Payload = {}; + if (typeof messageId !== 'undefined') { + payload['messageId'] = messageId; + } + if (typeof subject !== 'undefined') { + payload['subject'] = subject; + } + if (typeof content !== 'undefined') { + payload['content'] = content; + } + if (typeof topics !== 'undefined') { + payload['topics'] = topics; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + if (typeof targets !== 'undefined') { + payload['targets'] = targets; + } + if (typeof cc !== 'undefined') { + payload['cc'] = cc; + } + if (typeof bcc !== 'undefined') { + payload['bcc'] = bcc; + } + if (typeof attachments !== 'undefined') { + payload['attachments'] = attachments; + } + if (typeof draft !== 'undefined') { + payload['draft'] = draft; + } + if (typeof html !== 'undefined') { + payload['html'] = html; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an email message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} params.messageId - Message ID. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {string} params.subject - Email Subject. + * @param {string} params.content - Email Content. + * @param {boolean} params.draft - Is message a draft + * @param {boolean} params.html - Is content of type HTML + * @param {string[]} params.cc - Array of target IDs to be added as CC. + * @param {string[]} params.bcc - Array of target IDs to be added as BCC. + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[]} params.attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + updateEmail(this: Messaging<ServerAuth>, params: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }): Promise<Models.Message>; + /** + * Update an email message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} messageId - Message ID. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {string} subject - Email Subject. + * @param {string} content - Email Content. + * @param {boolean} draft - Is message a draft + * @param {boolean} html - Is content of type HTML + * @param {string[]} cc - Array of target IDs to be added as CC. + * @param {string[]} bcc - Array of target IDs to be added as BCC. + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {string[]} attachments - Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmail(this: Messaging<ServerAuth>, messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[]): Promise<Models.Message>; + updateEmail( + paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] } | string, + ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (string)?, (boolean)?, (boolean)?, (string[])?, (string[])?, (string)?, (string[])?] + ): Promise<Models.Message> { + let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[] }; + } else { + params = { + messageId: paramsOrFirst as string, + topics: rest[0] as string[], + users: rest[1] as string[], + targets: rest[2] as string[], + subject: rest[3] as string, + content: rest[4] as string, + draft: rest[5] as boolean, + html: rest[6] as boolean, + cc: rest[7] as string[], + bcc: rest[8] as string[], + scheduledAt: rest[9] as string, + attachments: rest[10] as string[] + }; + } + + const messageId = params.messageId; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const subject = params.subject; + const content = params.content; + const draft = params.draft; + const html = params.html; + const cc = params.cc; + const bcc = params.bcc; + const scheduledAt = params.scheduledAt; + const attachments = params.attachments; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + + const apiPath = '/messaging/messages/email/{messageId}'.replace('{messageId}', messageId); + const payload: Payload = {}; + if (typeof topics !== 'undefined') { + payload['topics'] = topics; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + if (typeof targets !== 'undefined') { + payload['targets'] = targets; + } + if (typeof subject !== 'undefined') { + payload['subject'] = subject; + } + if (typeof content !== 'undefined') { + payload['content'] = content; + } + if (typeof draft !== 'undefined') { + payload['draft'] = draft; + } + if (typeof html !== 'undefined') { + payload['html'] = html; + } + if (typeof cc !== 'undefined') { + payload['cc'] = cc; + } + if (typeof bcc !== 'undefined') { + payload['bcc'] = bcc; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + if (typeof attachments !== 'undefined') { + payload['attachments'] = attachments; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new push notification. + * + * @param {string} params.messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.title - Title for push notification. + * @param {string} params.body - Body for push notification. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {object} params.data - Additional key-value pair data for push notification. + * @param {string} params.action - Action for push notification. + * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string} params.icon - Icon for push notification. Available only for Android and Web Platform. + * @param {string} params.sound - Sound for push notification. Available only for Android and iOS Platform. + * @param {string} params.color - Color for push notification. Available only for Android Platform. + * @param {string} params.tag - Tag for push notification. Available only for Android Platform. + * @param {number} params.badge - Badge for push notification. Available only for iOS Platform. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + createPush(this: Messaging<ServerAuth>, params: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }): Promise<Models.Message>; + /** + * Create a new push notification. + * + * @param {string} messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} title - Title for push notification. + * @param {string} body - Body for push notification. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {object} data - Additional key-value pair data for push notification. + * @param {string} action - Action for push notification. + * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string} icon - Icon for push notification. Available only for Android and Web Platform. + * @param {string} sound - Sound for push notification. Available only for Android and iOS Platform. + * @param {string} color - Color for push notification. Available only for Android Platform. + * @param {string} tag - Tag for push notification. Available only for Android Platform. + * @param {number} badge - Badge for push notification. Available only for iOS Platform. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPush(this: Messaging<ServerAuth>, messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise<Models.Message>; + createPush( + paramsOrFirst: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority } | string, + ...rest: [(string)?, (string)?, (string[])?, (string[])?, (string[])?, (object)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?, (MessagePriority)?] + ): Promise<Models.Message> { + let params: { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, title?: string, body?: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + } else { + params = { + messageId: paramsOrFirst as string, + title: rest[0] as string, + body: rest[1] as string, + topics: rest[2] as string[], + users: rest[3] as string[], + targets: rest[4] as string[], + data: rest[5] as object, + action: rest[6] as string, + image: rest[7] as string, + icon: rest[8] as string, + sound: rest[9] as string, + color: rest[10] as string, + tag: rest[11] as string, + badge: rest[12] as number, + draft: rest[13] as boolean, + scheduledAt: rest[14] as string, + contentAvailable: rest[15] as boolean, + critical: rest[16] as boolean, + priority: rest[17] as MessagePriority + }; + } + + const messageId = params.messageId; + const title = params.title; + const body = params.body; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const data = params.data; + const action = params.action; + const image = params.image; + const icon = params.icon; + const sound = params.sound; + const color = params.color; + const tag = params.tag; + const badge = params.badge; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + const contentAvailable = params.contentAvailable; + const critical = params.critical; + const priority = params.priority; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + + const apiPath = '/messaging/messages/push'; + const payload: Payload = {}; + if (typeof messageId !== 'undefined') { + payload['messageId'] = messageId; + } + if (typeof title !== 'undefined') { + payload['title'] = title; + } + if (typeof body !== 'undefined') { + payload['body'] = body; + } + if (typeof topics !== 'undefined') { + payload['topics'] = topics; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + if (typeof targets !== 'undefined') { + payload['targets'] = targets; + } + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof action !== 'undefined') { + payload['action'] = action; + } + if (typeof image !== 'undefined') { + payload['image'] = image; + } + if (typeof icon !== 'undefined') { + payload['icon'] = icon; + } + if (typeof sound !== 'undefined') { + payload['sound'] = sound; + } + if (typeof color !== 'undefined') { + payload['color'] = color; + } + if (typeof tag !== 'undefined') { + payload['tag'] = tag; + } + if (typeof badge !== 'undefined') { + payload['badge'] = badge; + } + if (typeof draft !== 'undefined') { + payload['draft'] = draft; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + if (typeof contentAvailable !== 'undefined') { + payload['contentAvailable'] = contentAvailable; + } + if (typeof critical !== 'undefined') { + payload['critical'] = critical; + } + if (typeof priority !== 'undefined') { + payload['priority'] = priority; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a push notification by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} params.messageId - Message ID. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {string} params.title - Title for push notification. + * @param {string} params.body - Body for push notification. + * @param {object} params.data - Additional Data for push notification. + * @param {string} params.action - Action for push notification. + * @param {string} params.image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string} params.icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string} params.sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string} params.color - Color for push notification. Available only for Android platforms. + * @param {string} params.tag - Tag for push notification. Available only for Android platforms. + * @param {number} params.badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean} params.contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean} params.critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority} params.priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + updatePush(this: Messaging<ServerAuth>, params: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }): Promise<Models.Message>; + /** + * Update a push notification by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} messageId - Message ID. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {string} title - Title for push notification. + * @param {string} body - Body for push notification. + * @param {object} data - Additional Data for push notification. + * @param {string} action - Action for push notification. + * @param {string} image - Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. + * @param {string} icon - Icon for push notification. Available only for Android and Web platforms. + * @param {string} sound - Sound for push notification. Available only for Android and iOS platforms. + * @param {string} color - Color for push notification. Available only for Android platforms. + * @param {string} tag - Tag for push notification. Available only for Android platforms. + * @param {number} badge - Badge for push notification. Available only for iOS platforms. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @param {boolean} contentAvailable - If set to true, the notification will be delivered in the background. Available only for iOS Platform. + * @param {boolean} critical - If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + * @param {MessagePriority} priority - Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePush(this: Messaging<ServerAuth>, messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority): Promise<Models.Message>; + updatePush( + paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority } | string, + ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (string)?, (object)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?, (MessagePriority)?] + ): Promise<Models.Message> { + let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string, contentAvailable?: boolean, critical?: boolean, priority?: MessagePriority }; + } else { + params = { + messageId: paramsOrFirst as string, + topics: rest[0] as string[], + users: rest[1] as string[], + targets: rest[2] as string[], + title: rest[3] as string, + body: rest[4] as string, + data: rest[5] as object, + action: rest[6] as string, + image: rest[7] as string, + icon: rest[8] as string, + sound: rest[9] as string, + color: rest[10] as string, + tag: rest[11] as string, + badge: rest[12] as number, + draft: rest[13] as boolean, + scheduledAt: rest[14] as string, + contentAvailable: rest[15] as boolean, + critical: rest[16] as boolean, + priority: rest[17] as MessagePriority + }; + } + + const messageId = params.messageId; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const title = params.title; + const body = params.body; + const data = params.data; + const action = params.action; + const image = params.image; + const icon = params.icon; + const sound = params.sound; + const color = params.color; + const tag = params.tag; + const badge = params.badge; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + const contentAvailable = params.contentAvailable; + const critical = params.critical; + const priority = params.priority; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + + const apiPath = '/messaging/messages/push/{messageId}'.replace('{messageId}', messageId); + const payload: Payload = {}; + if (typeof topics !== 'undefined') { + payload['topics'] = topics; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + if (typeof targets !== 'undefined') { + payload['targets'] = targets; + } + if (typeof title !== 'undefined') { + payload['title'] = title; + } + if (typeof body !== 'undefined') { + payload['body'] = body; + } + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof action !== 'undefined') { + payload['action'] = action; + } + if (typeof image !== 'undefined') { + payload['image'] = image; + } + if (typeof icon !== 'undefined') { + payload['icon'] = icon; + } + if (typeof sound !== 'undefined') { + payload['sound'] = sound; + } + if (typeof color !== 'undefined') { + payload['color'] = color; + } + if (typeof tag !== 'undefined') { + payload['tag'] = tag; + } + if (typeof badge !== 'undefined') { + payload['badge'] = badge; + } + if (typeof draft !== 'undefined') { + payload['draft'] = draft; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + if (typeof contentAvailable !== 'undefined') { + payload['contentAvailable'] = contentAvailable; + } + if (typeof critical !== 'undefined') { + payload['critical'] = critical; + } + if (typeof priority !== 'undefined') { + payload['priority'] = priority; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new SMS message. + * + * @param {string} params.messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.content - SMS Content. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMS` instead. + */ + createSms(this: Messaging<ServerAuth>, params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }): Promise<Models.Message>; + /** + * Create a new SMS message. + * + * @param {string} messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} content - SMS Content. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSms(this: Messaging<ServerAuth>, messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise<Models.Message>; + createSms( + paramsOrFirst: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string } | string, + ...rest: [(string)?, (string[])?, (string[])?, (string[])?, (boolean)?, (string)?] + ): Promise<Models.Message> { + let params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + } else { + params = { + messageId: paramsOrFirst as string, + content: rest[0] as string, + topics: rest[1] as string[], + users: rest[2] as string[], + targets: rest[3] as string[], + draft: rest[4] as boolean, + scheduledAt: rest[5] as string + }; + } + + const messageId = params.messageId; + const content = params.content; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (typeof content === 'undefined') { + throw new AppwriteException('Missing required parameter: "content"'); + } + + const apiPath = '/messaging/messages/sms'; + const payload: Payload = {}; + if (typeof messageId !== 'undefined') { + payload['messageId'] = messageId; + } + if (typeof content !== 'undefined') { + payload['content'] = content; + } + if (typeof topics !== 'undefined') { + payload['topics'] = topics; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + if (typeof targets !== 'undefined') { + payload['targets'] = targets; + } + if (typeof draft !== 'undefined') { + payload['draft'] = draft; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} params.messageId - Message ID. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {string} params.content - Email Content. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMS` instead. + */ + updateSms(this: Messaging<ServerAuth>, params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }): Promise<Models.Message>; + /** + * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} messageId - Message ID. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {string} content - Email Content. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSms(this: Messaging<ServerAuth>, messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise<Models.Message>; + updateSms( + paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string } | string, + ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (boolean)?, (string)?] + ): Promise<Models.Message> { + let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + } else { + params = { + messageId: paramsOrFirst as string, + topics: rest[0] as string[], + users: rest[1] as string[], + targets: rest[2] as string[], + content: rest[3] as string, + draft: rest[4] as boolean, + scheduledAt: rest[5] as string + }; + } + + const messageId = params.messageId; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const content = params.content; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + + const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', messageId); + const payload: Payload = {}; + if (typeof topics !== 'undefined') { + payload['topics'] = topics; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + if (typeof targets !== 'undefined') { + payload['targets'] = targets; + } + if (typeof content !== 'undefined') { + payload['content'] = content; + } + if (typeof draft !== 'undefined') { + payload['draft'] = draft; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a message by its unique ID. + * + * + * @param {string} params.messageId - Message ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + getMessage(this: Messaging<ServerAuth>, params: { messageId: string }): Promise<Models.Message>; + /** + * Get a message by its unique ID. + * + * + * @param {string} messageId - Message ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getMessage(this: Messaging<ServerAuth>, messageId: string): Promise<Models.Message>; + getMessage( + paramsOrFirst: { messageId: string } | string + ): Promise<Models.Message> { + let params: { messageId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string }; + } else { + params = { + messageId: paramsOrFirst as string + }; + } + + const messageId = params.messageId; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + + const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', messageId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a message. If the message is not a draft or scheduled, but has been sent, this will not recall the message. + * + * @param {string} params.messageId - Message ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(this: Messaging<ServerAuth>, params: { messageId: string }): Promise<{}>; + /** + * Delete a message. If the message is not a draft or scheduled, but has been sent, this will not recall the message. + * + * @param {string} messageId - Message ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(this: Messaging<ServerAuth>, messageId: string): Promise<{}>; + delete( + paramsOrFirst: { messageId: string } | string + ): Promise<{}> { + let params: { messageId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string }; + } else { + params = { + messageId: paramsOrFirst as string + }; + } + + const messageId = params.messageId; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + + const apiPath = '/messaging/messages/{messageId}'.replace('{messageId}', messageId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the message activity logs listed by its unique ID. + * + * @param {string} params.messageId - Message ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + */ + listMessageLogs(this: Messaging<ServerAuth>, params: { messageId: string, queries?: string[], total?: boolean }): Promise<Models.LogList>; + /** + * Get the message activity logs listed by its unique ID. + * + * @param {string} messageId - Message ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listMessageLogs(this: Messaging<ServerAuth>, messageId: string, queries?: string[], total?: boolean): Promise<Models.LogList>; + listMessageLogs( + paramsOrFirst: { messageId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.LogList> { + let params: { messageId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, queries?: string[], total?: boolean }; + } else { + params = { + messageId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const messageId = params.messageId; + const queries = params.queries; + const total = params.total; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + + const apiPath = '/messaging/messages/{messageId}/logs'.replace('{messageId}', messageId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of the targets associated with a message. + * + * @param {string} params.messageId - Message ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.TargetList>} + */ + listTargets(this: Messaging<ServerAuth>, params: { messageId: string, queries?: string[], total?: boolean }): Promise<Models.TargetList>; + /** + * Get a list of the targets associated with a message. + * + * @param {string} messageId - Message ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.TargetList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listTargets(this: Messaging<ServerAuth>, messageId: string, queries?: string[], total?: boolean): Promise<Models.TargetList>; + listTargets( + paramsOrFirst: { messageId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.TargetList> { + let params: { messageId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, queries?: string[], total?: boolean }; + } else { + params = { + messageId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const messageId = params.messageId; + const queries = params.queries; + const total = params.total; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + + const apiPath = '/messaging/messages/{messageId}/targets'.replace('{messageId}', messageId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all providers from the current Appwrite project. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, provider, type, enabled + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProviderList>} + */ + listProviders(this: Messaging<ServerAuth>, params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.ProviderList>; + /** + * Get a list of all providers from the current Appwrite project. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, provider, type, enabled + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProviderList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listProviders(this: Messaging<ServerAuth>, queries?: string[], search?: string, total?: boolean): Promise<Models.ProviderList>; + listProviders( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise<Models.ProviderList> { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/messaging/providers'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Apple Push Notification service provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.authKey - APNS authentication key. + * @param {string} params.authKeyId - APNS authentication key ID. + * @param {string} params.teamId - APNS team ID. + * @param {string} params.bundleId - APNS bundle ID. + * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createAPNSProvider` instead. + */ + createApnsProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Apple Push Notification service provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} authKey - APNS authentication key. + * @param {string} authKeyId - APNS authentication key ID. + * @param {string} teamId - APNS team ID. + * @param {string} bundleId - APNS bundle ID. + * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createApnsProvider(this: Messaging<ServerAuth>, providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise<Models.Provider>; + createApnsProvider( + paramsOrFirst: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + authKey: rest[1] as string, + authKeyId: rest[2] as string, + teamId: rest[3] as string, + bundleId: rest[4] as string, + sandbox: rest[5] as boolean, + enabled: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const authKey = params.authKey; + const authKeyId = params.authKeyId; + const teamId = params.teamId; + const bundleId = params.bundleId; + const sandbox = params.sandbox; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/apns'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof authKey !== 'undefined') { + payload['authKey'] = authKey; + } + if (typeof authKeyId !== 'undefined') { + payload['authKeyId'] = authKeyId; + } + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + if (typeof bundleId !== 'undefined') { + payload['bundleId'] = bundleId; + } + if (typeof sandbox !== 'undefined') { + payload['sandbox'] = sandbox; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Apple Push Notification service provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.authKey - APNS authentication key. + * @param {string} params.authKeyId - APNS authentication key ID. + * @param {string} params.teamId - APNS team ID. + * @param {string} params.bundleId - APNS bundle ID. + * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. + */ + updateApnsProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }): Promise<Models.Provider>; + /** + * Update a Apple Push Notification service provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} authKey - APNS authentication key. + * @param {string} authKeyId - APNS authentication key ID. + * @param {string} teamId - APNS team ID. + * @param {string} bundleId - APNS bundle ID. + * @param {boolean} sandbox - Use APNS sandbox environment. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateApnsProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise<Models.Provider>; + updateApnsProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + authKey: rest[2] as string, + authKeyId: rest[3] as string, + teamId: rest[4] as string, + bundleId: rest[5] as string, + sandbox: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const authKey = params.authKey; + const authKeyId = params.authKeyId; + const teamId = params.teamId; + const bundleId = params.bundleId; + const sandbox = params.sandbox; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof authKey !== 'undefined') { + payload['authKey'] = authKey; + } + if (typeof authKeyId !== 'undefined') { + payload['authKeyId'] = authKeyId; + } + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + if (typeof bundleId !== 'undefined') { + payload['bundleId'] = bundleId; + } + if (typeof sandbox !== 'undefined') { + payload['sandbox'] = sandbox; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. + */ + createFcmProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFcmProvider(this: Messaging<ServerAuth>, providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise<Models.Provider>; + createFcmProvider( + paramsOrFirst: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean } | string, + ...rest: [(string)?, (object)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + serviceAccountJSON: rest[1] as object, + enabled: rest[2] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const serviceAccountJSON = params.serviceAccountJSON; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/fcm'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof serviceAccountJSON !== 'undefined') { + payload['serviceAccountJSON'] = serviceAccountJSON; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Firebase Cloud Messaging provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. + */ + updateFcmProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }): Promise<Models.Provider>; + /** + * Update a Firebase Cloud Messaging provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {object} serviceAccountJSON - FCM service account JSON. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateFcmProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise<Models.Provider>; + updateFcmProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object } | string, + ...rest: [(string)?, (boolean)?, (object)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + serviceAccountJSON: rest[2] as object + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const serviceAccountJSON = params.serviceAccountJSON; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/fcm/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof serviceAccountJSON !== 'undefined') { + payload['serviceAccountJSON'] = serviceAccountJSON; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Mailgun provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.apiKey - Mailgun API Key. + * @param {string} params.domain - Mailgun Domain. + * @param {boolean} params.isEuRegion - Set as EU region. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createMailgunProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Mailgun provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} apiKey - Mailgun API Key. + * @param {string} domain - Mailgun Domain. + * @param {boolean} isEuRegion - Set as EU region. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. Reply to name must have reply to email as well. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. Reply to email must have reply to name as well. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMailgunProvider(this: Messaging<ServerAuth>, providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createMailgunProvider( + paramsOrFirst: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + apiKey: rest[1] as string, + domain: rest[2] as string, + isEuRegion: rest[3] as boolean, + fromName: rest[4] as string, + fromEmail: rest[5] as string, + replyToName: rest[6] as string, + replyToEmail: rest[7] as string, + enabled: rest[8] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const apiKey = params.apiKey; + const domain = params.domain; + const isEuRegion = params.isEuRegion; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/mailgun'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof isEuRegion !== 'undefined') { + payload['isEuRegion'] = isEuRegion; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Mailgun provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {string} params.apiKey - Mailgun API Key. + * @param {string} params.domain - Mailgun Domain. + * @param {boolean} params.isEuRegion - Set as EU region. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateMailgunProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise<Models.Provider>; + /** + * Update a Mailgun provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {string} apiKey - Mailgun API Key. + * @param {string} domain - Mailgun Domain. + * @param {boolean} isEuRegion - Set as EU region. + * @param {boolean} enabled - Set as enabled. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMailgunProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider>; + updateMailgunProvider( + paramsOrFirst: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?, (boolean)?, (string)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + apiKey: rest[1] as string, + domain: rest[2] as string, + isEuRegion: rest[3] as boolean, + enabled: rest[4] as boolean, + fromName: rest[5] as string, + fromEmail: rest[6] as string, + replyToName: rest[7] as string, + replyToEmail: rest[8] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const apiKey = params.apiKey; + const domain = params.domain; + const isEuRegion = params.isEuRegion; + const enabled = params.enabled; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/mailgun/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof isEuRegion !== 'undefined') { + payload['isEuRegion'] = isEuRegion; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new MSG91 provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.templateId - Msg91 template ID + * @param {string} params.senderId - Msg91 sender ID. + * @param {string} params.authKey - Msg91 auth key. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createMsg91Provider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new MSG91 provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} templateId - Msg91 template ID + * @param {string} senderId - Msg91 sender ID. + * @param {string} authKey - Msg91 auth key. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMsg91Provider(this: Messaging<ServerAuth>, providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider>; + createMsg91Provider( + paramsOrFirst: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + templateId: rest[1] as string, + senderId: rest[2] as string, + authKey: rest[3] as string, + enabled: rest[4] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const templateId = params.templateId; + const senderId = params.senderId; + const authKey = params.authKey; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/msg91'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof templateId !== 'undefined') { + payload['templateId'] = templateId; + } + if (typeof senderId !== 'undefined') { + payload['senderId'] = senderId; + } + if (typeof authKey !== 'undefined') { + payload['authKey'] = authKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a MSG91 provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.templateId - Msg91 template ID. + * @param {string} params.senderId - Msg91 sender ID. + * @param {string} params.authKey - Msg91 auth key. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateMsg91Provider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }): Promise<Models.Provider>; + /** + * Update a MSG91 provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} templateId - Msg91 template ID. + * @param {string} senderId - Msg91 sender ID. + * @param {string} authKey - Msg91 auth key. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMsg91Provider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise<Models.Provider>; + updateMsg91Provider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + templateId: rest[2] as string, + senderId: rest[3] as string, + authKey: rest[4] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const templateId = params.templateId; + const senderId = params.senderId; + const authKey = params.authKey; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof templateId !== 'undefined') { + payload['templateId'] = templateId; + } + if (typeof senderId !== 'undefined') { + payload['senderId'] = senderId; + } + if (typeof authKey !== 'undefined') { + payload['authKey'] = authKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Resend provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.apiKey - Resend API key. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createResendProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Resend provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} apiKey - Resend API key. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createResendProvider(this: Messaging<ServerAuth>, providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createResendProvider( + paramsOrFirst: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + apiKey: rest[1] as string, + fromName: rest[2] as string, + fromEmail: rest[3] as string, + replyToName: rest[4] as string, + replyToEmail: rest[5] as string, + enabled: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const apiKey = params.apiKey; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/resend'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Resend provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.apiKey - Resend API key. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateResendProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise<Models.Provider>; + /** + * Update a Resend provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} apiKey - Resend API key. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateResendProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider>; + updateResendProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + apiKey: rest[2] as string, + fromName: rest[3] as string, + fromEmail: rest[4] as string, + replyToName: rest[5] as string, + replyToEmail: rest[6] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const apiKey = params.apiKey; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/resend/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Sendgrid provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.apiKey - Sendgrid API key. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createSendgridProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Sendgrid provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} apiKey - Sendgrid API key. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSendgridProvider(this: Messaging<ServerAuth>, providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createSendgridProvider( + paramsOrFirst: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + apiKey: rest[1] as string, + fromName: rest[2] as string, + fromEmail: rest[3] as string, + replyToName: rest[4] as string, + replyToEmail: rest[5] as string, + enabled: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const apiKey = params.apiKey; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/sendgrid'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Sendgrid provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.apiKey - Sendgrid API key. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateSendgridProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise<Models.Provider>; + /** + * Update a Sendgrid provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} apiKey - Sendgrid API key. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSendgridProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider>; + updateSendgridProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + apiKey: rest[2] as string, + fromName: rest[3] as string, + fromEmail: rest[4] as string, + replyToName: rest[5] as string, + replyToEmail: rest[6] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const apiKey = params.apiKey; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new SMTP provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} params.port - The default SMTP server port. + * @param {string} params.username - Authentication username. + * @param {string} params.password - Authentication password. + * @param {SmtpEncryption} params.encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {string} params.mailer - The value to use for the X-Mailer header. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. + */ + createSmtpProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new SMTP provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} port - The default SMTP server port. + * @param {string} username - Authentication username. + * @param {string} password - Authentication password. + * @param {SmtpEncryption} encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {string} mailer - The value to use for the X-Mailer header. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSmtpProvider(this: Messaging<ServerAuth>, providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createSmtpProvider( + paramsOrFirst: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + host: rest[1] as string, + port: rest[2] as number, + username: rest[3] as string, + password: rest[4] as string, + encryption: rest[5] as SmtpEncryption, + autoTLS: rest[6] as boolean, + mailer: rest[7] as string, + fromName: rest[8] as string, + fromEmail: rest[9] as string, + replyToName: rest[10] as string, + replyToEmail: rest[11] as string, + enabled: rest[12] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const host = params.host; + const port = params.port; + const username = params.username; + const password = params.password; + const encryption = params.encryption; + const autoTLS = params.autoTLS; + const mailer = params.mailer; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof host === 'undefined') { + throw new AppwriteException('Missing required parameter: "host"'); + } + + const apiPath = '/messaging/providers/smtp'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof host !== 'undefined') { + payload['host'] = host; + } + if (typeof port !== 'undefined') { + payload['port'] = port; + } + if (typeof username !== 'undefined') { + payload['username'] = username; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof encryption !== 'undefined') { + payload['encryption'] = encryption; + } + if (typeof autoTLS !== 'undefined') { + payload['autoTLS'] = autoTLS; + } + if (typeof mailer !== 'undefined') { + payload['mailer'] = mailer; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a SMTP provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} params.port - SMTP port. + * @param {string} params.username - Authentication username. + * @param {string} params.password - Authentication password. + * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' + * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {string} params.mailer - The value to use for the X-Mailer header. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. + */ + updateSmtpProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Update a SMTP provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} port - SMTP port. + * @param {string} username - Authentication username. + * @param {string} password - Authentication password. + * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' + * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {string} mailer - The value to use for the X-Mailer header. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSmtpProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + updateSmtpProvider( + paramsOrFirst: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + host: rest[1] as string, + port: rest[2] as number, + username: rest[3] as string, + password: rest[4] as string, + encryption: rest[5] as SmtpEncryption, + autoTLS: rest[6] as boolean, + mailer: rest[7] as string, + fromName: rest[8] as string, + fromEmail: rest[9] as string, + replyToName: rest[10] as string, + replyToEmail: rest[11] as string, + enabled: rest[12] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const host = params.host; + const port = params.port; + const username = params.username; + const password = params.password; + const encryption = params.encryption; + const autoTLS = params.autoTLS; + const mailer = params.mailer; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/smtp/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof host !== 'undefined') { + payload['host'] = host; + } + if (typeof port !== 'undefined') { + payload['port'] = port; + } + if (typeof username !== 'undefined') { + payload['username'] = username; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof encryption !== 'undefined') { + payload['encryption'] = encryption; + } + if (typeof autoTLS !== 'undefined') { + payload['autoTLS'] = autoTLS; + } + if (typeof mailer !== 'undefined') { + payload['mailer'] = mailer; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Telesign provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.customerId - Telesign customer ID. + * @param {string} params.apiKey - Telesign API key. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createTelesignProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Telesign provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} customerId - Telesign customer ID. + * @param {string} apiKey - Telesign API key. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTelesignProvider(this: Messaging<ServerAuth>, providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean): Promise<Models.Provider>; + createTelesignProvider( + paramsOrFirst: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + from: rest[1] as string, + customerId: rest[2] as string, + apiKey: rest[3] as string, + enabled: rest[4] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const from = params.from; + const customerId = params.customerId; + const apiKey = params.apiKey; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/telesign'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof from !== 'undefined') { + payload['from'] = from; + } + if (typeof customerId !== 'undefined') { + payload['customerId'] = customerId; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Telesign provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.customerId - Telesign customer ID. + * @param {string} params.apiKey - Telesign API key. + * @param {string} params.from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateTelesignProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }): Promise<Models.Provider>; + /** + * Update a Telesign provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} customerId - Telesign customer ID. + * @param {string} apiKey - Telesign API key. + * @param {string} from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTelesignProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string): Promise<Models.Provider>; + updateTelesignProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + customerId: rest[2] as string, + apiKey: rest[3] as string, + from: rest[4] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const customerId = params.customerId; + const apiKey = params.apiKey; + const from = params.from; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/telesign/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof customerId !== 'undefined') { + payload['customerId'] = customerId; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof from !== 'undefined') { + payload['from'] = from; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Textmagic provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.username - Textmagic username. + * @param {string} params.apiKey - Textmagic apiKey. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createTextmagicProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Textmagic provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} username - Textmagic username. + * @param {string} apiKey - Textmagic apiKey. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTextmagicProvider(this: Messaging<ServerAuth>, providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean): Promise<Models.Provider>; + createTextmagicProvider( + paramsOrFirst: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + from: rest[1] as string, + username: rest[2] as string, + apiKey: rest[3] as string, + enabled: rest[4] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const from = params.from; + const username = params.username; + const apiKey = params.apiKey; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/textmagic'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof from !== 'undefined') { + payload['from'] = from; + } + if (typeof username !== 'undefined') { + payload['username'] = username; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Textmagic provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.username - Textmagic username. + * @param {string} params.apiKey - Textmagic apiKey. + * @param {string} params.from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateTextmagicProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }): Promise<Models.Provider>; + /** + * Update a Textmagic provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} username - Textmagic username. + * @param {string} apiKey - Textmagic apiKey. + * @param {string} from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTextmagicProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string): Promise<Models.Provider>; + updateTextmagicProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + username: rest[2] as string, + apiKey: rest[3] as string, + from: rest[4] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const username = params.username; + const apiKey = params.apiKey; + const from = params.from; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/textmagic/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof username !== 'undefined') { + payload['username'] = username; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof from !== 'undefined') { + payload['from'] = from; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Twilio provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.accountSid - Twilio account secret ID. + * @param {string} params.authToken - Twilio authentication token. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createTwilioProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Twilio provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} accountSid - Twilio account secret ID. + * @param {string} authToken - Twilio authentication token. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTwilioProvider(this: Messaging<ServerAuth>, providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean): Promise<Models.Provider>; + createTwilioProvider( + paramsOrFirst: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + from: rest[1] as string, + accountSid: rest[2] as string, + authToken: rest[3] as string, + enabled: rest[4] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const from = params.from; + const accountSid = params.accountSid; + const authToken = params.authToken; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/twilio'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof from !== 'undefined') { + payload['from'] = from; + } + if (typeof accountSid !== 'undefined') { + payload['accountSid'] = accountSid; + } + if (typeof authToken !== 'undefined') { + payload['authToken'] = authToken; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Twilio provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.accountSid - Twilio account secret ID. + * @param {string} params.authToken - Twilio authentication token. + * @param {string} params.from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateTwilioProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }): Promise<Models.Provider>; + /** + * Update a Twilio provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} accountSid - Twilio account secret ID. + * @param {string} authToken - Twilio authentication token. + * @param {string} from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTwilioProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string): Promise<Models.Provider>; + updateTwilioProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + accountSid: rest[2] as string, + authToken: rest[3] as string, + from: rest[4] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const accountSid = params.accountSid; + const authToken = params.authToken; + const from = params.from; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/twilio/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof accountSid !== 'undefined') { + payload['accountSid'] = accountSid; + } + if (typeof authToken !== 'undefined') { + payload['authToken'] = authToken; + } + if (typeof from !== 'undefined') { + payload['from'] = from; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Vonage provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.apiKey - Vonage API key. + * @param {string} params.apiSecret - Vonage API secret. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createVonageProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Vonage provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} from - Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} apiKey - Vonage API key. + * @param {string} apiSecret - Vonage API secret. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVonageProvider(this: Messaging<ServerAuth>, providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean): Promise<Models.Provider>; + createVonageProvider( + paramsOrFirst: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + from: rest[1] as string, + apiKey: rest[2] as string, + apiSecret: rest[3] as string, + enabled: rest[4] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const from = params.from; + const apiKey = params.apiKey; + const apiSecret = params.apiSecret; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/vonage'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof from !== 'undefined') { + payload['from'] = from; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof apiSecret !== 'undefined') { + payload['apiSecret'] = apiSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Vonage provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.apiKey - Vonage API key. + * @param {string} params.apiSecret - Vonage API secret. + * @param {string} params.from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateVonageProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }): Promise<Models.Provider>; + /** + * Update a Vonage provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} apiKey - Vonage API key. + * @param {string} apiSecret - Vonage API secret. + * @param {string} from - Sender number. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateVonageProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string): Promise<Models.Provider>; + updateVonageProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + apiKey: rest[2] as string, + apiSecret: rest[3] as string, + from: rest[4] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const apiKey = params.apiKey; + const apiSecret = params.apiSecret; + const from = params.from; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/vonage/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof apiSecret !== 'undefined') { + payload['apiSecret'] = apiSecret; + } + if (typeof from !== 'undefined') { + payload['from'] = from; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a provider by its unique ID. + * + * + * @param {string} params.providerId - Provider ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + getProvider(this: Messaging<ServerAuth>, params: { providerId: string }): Promise<Models.Provider>; + /** + * Get a provider by its unique ID. + * + * + * @param {string} providerId - Provider ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getProvider(this: Messaging<ServerAuth>, providerId: string): Promise<Models.Provider>; + getProvider( + paramsOrFirst: { providerId: string } | string + ): Promise<Models.Provider> { + let params: { providerId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string }; + } else { + params = { + providerId: paramsOrFirst as string + }; + } + + const providerId = params.providerId; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteProvider(this: Messaging<ServerAuth>, params: { providerId: string }): Promise<{}>; + /** + * Delete a provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteProvider(this: Messaging<ServerAuth>, providerId: string): Promise<{}>; + deleteProvider( + paramsOrFirst: { providerId: string } | string + ): Promise<{}> { + let params: { providerId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string }; + } else { + params = { + providerId: paramsOrFirst as string + }; + } + + const providerId = params.providerId; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the provider activity logs listed by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + */ + listProviderLogs(this: Messaging<ServerAuth>, params: { providerId: string, queries?: string[], total?: boolean }): Promise<Models.LogList>; + /** + * Get the provider activity logs listed by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listProviderLogs(this: Messaging<ServerAuth>, providerId: string, queries?: string[], total?: boolean): Promise<Models.LogList>; + listProviderLogs( + paramsOrFirst: { providerId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.LogList> { + let params: { providerId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, queries?: string[], total?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const providerId = params.providerId; + const queries = params.queries; + const total = params.total; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/{providerId}/logs'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the subscriber activity logs listed by its unique ID. + * + * @param {string} params.subscriberId - Subscriber ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + */ + listSubscriberLogs(this: Messaging<ServerAuth>, params: { subscriberId: string, queries?: string[], total?: boolean }): Promise<Models.LogList>; + /** + * Get the subscriber activity logs listed by its unique ID. + * + * @param {string} subscriberId - Subscriber ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listSubscriberLogs(this: Messaging<ServerAuth>, subscriberId: string, queries?: string[], total?: boolean): Promise<Models.LogList>; + listSubscriberLogs( + paramsOrFirst: { subscriberId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.LogList> { + let params: { subscriberId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { subscriberId: string, queries?: string[], total?: boolean }; + } else { + params = { + subscriberId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const subscriberId = params.subscriberId; + const queries = params.queries; + const total = params.total; + + if (typeof subscriberId === 'undefined') { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + + const apiPath = '/messaging/subscribers/{subscriberId}/logs'.replace('{subscriberId}', subscriberId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all topics from the current Appwrite project. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, description, emailTotal, smsTotal, pushTotal + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.TopicList>} + */ + listTopics(this: Messaging<ServerAuth>, params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.TopicList>; + /** + * Get a list of all topics from the current Appwrite project. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, description, emailTotal, smsTotal, pushTotal + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.TopicList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listTopics(this: Messaging<ServerAuth>, queries?: string[], search?: string, total?: boolean): Promise<Models.TopicList>; + listTopics( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise<Models.TopicList> { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/messaging/topics'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new topic. + * + * @param {string} params.topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. + * @param {string} params.name - Topic Name. + * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.Topic>} + */ + createTopic(this: Messaging<ServerAuth>, params: { topicId: string, name: string, subscribe?: string[] }): Promise<Models.Topic>; + /** + * Create a new topic. + * + * @param {string} topicId - Topic ID. Choose a custom Topic ID or a new Topic ID. + * @param {string} name - Topic Name. + * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.Topic>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTopic(this: Messaging<ServerAuth>, topicId: string, name: string, subscribe?: string[]): Promise<Models.Topic>; + createTopic( + paramsOrFirst: { topicId: string, name: string, subscribe?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.Topic> { + let params: { topicId: string, name: string, subscribe?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, name: string, subscribe?: string[] }; + } else { + params = { + topicId: paramsOrFirst as string, + name: rest[0] as string, + subscribe: rest[1] as string[] + }; + } + + const topicId = params.topicId; + const name = params.name; + const subscribe = params.subscribe; + + if (typeof topicId === 'undefined') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/topics'; + const payload: Payload = {}; + if (typeof topicId !== 'undefined') { + payload['topicId'] = topicId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof subscribe !== 'undefined') { + payload['subscribe'] = subscribe; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a topic by its unique ID. + * + * + * @param {string} params.topicId - Topic ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Topic>} + */ + getTopic(this: Messaging<ServerAuth>, params: { topicId: string }): Promise<Models.Topic>; + /** + * Get a topic by its unique ID. + * + * + * @param {string} topicId - Topic ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Topic>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getTopic(this: Messaging<ServerAuth>, topicId: string): Promise<Models.Topic>; + getTopic( + paramsOrFirst: { topicId: string } | string + ): Promise<Models.Topic> { + let params: { topicId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string }; + } else { + params = { + topicId: paramsOrFirst as string + }; + } + + const topicId = params.topicId; + + if (typeof topicId === 'undefined') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a topic by its unique ID. + * + * + * @param {string} params.topicId - Topic ID. + * @param {string} params.name - Topic Name. + * @param {string[]} params.subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.Topic>} + */ + updateTopic(this: Messaging<ServerAuth>, params: { topicId: string, name?: string, subscribe?: string[] }): Promise<Models.Topic>; + /** + * Update a topic by its unique ID. + * + * + * @param {string} topicId - Topic ID. + * @param {string} name - Topic Name. + * @param {string[]} subscribe - An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.Topic>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTopic(this: Messaging<ServerAuth>, topicId: string, name?: string, subscribe?: string[]): Promise<Models.Topic>; + updateTopic( + paramsOrFirst: { topicId: string, name?: string, subscribe?: string[] } | string, + ...rest: [(string)?, (string[])?] + ): Promise<Models.Topic> { + let params: { topicId: string, name?: string, subscribe?: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, name?: string, subscribe?: string[] }; + } else { + params = { + topicId: paramsOrFirst as string, + name: rest[0] as string, + subscribe: rest[1] as string[] + }; + } + + const topicId = params.topicId; + const name = params.name; + const subscribe = params.subscribe; + + if (typeof topicId === 'undefined') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof subscribe !== 'undefined') { + payload['subscribe'] = subscribe; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a topic by its unique ID. + * + * @param {string} params.topicId - Topic ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTopic(this: Messaging<ServerAuth>, params: { topicId: string }): Promise<{}>; + /** + * Delete a topic by its unique ID. + * + * @param {string} topicId - Topic ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteTopic(this: Messaging<ServerAuth>, topicId: string): Promise<{}>; + deleteTopic( + paramsOrFirst: { topicId: string } | string + ): Promise<{}> { + let params: { topicId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string }; + } else { + params = { + topicId: paramsOrFirst as string + }; + } + + const topicId = params.topicId; + + if (typeof topicId === 'undefined') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + const apiPath = '/messaging/topics/{topicId}'.replace('{topicId}', topicId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the topic activity logs listed by its unique ID. + * + * @param {string} params.topicId - Topic ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + */ + listTopicLogs(this: Messaging<ServerAuth>, params: { topicId: string, queries?: string[], total?: boolean }): Promise<Models.LogList>; + /** + * Get the topic activity logs listed by its unique ID. + * + * @param {string} topicId - Topic ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listTopicLogs(this: Messaging<ServerAuth>, topicId: string, queries?: string[], total?: boolean): Promise<Models.LogList>; + listTopicLogs( + paramsOrFirst: { topicId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.LogList> { + let params: { topicId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, queries?: string[], total?: boolean }; + } else { + params = { + topicId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const topicId = params.topicId; + const queries = params.queries; + const total = params.total; + + if (typeof topicId === 'undefined') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + const apiPath = '/messaging/topics/{topicId}/logs'.replace('{topicId}', topicId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all subscribers from the current Appwrite project. + * + * @param {string} params.topicId - Topic ID. The topic ID subscribed to. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: targetId, topicId, userId, providerType + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.SubscriberList>} + */ + listSubscribers(this: Messaging<ServerAuth>, params: { topicId: string, queries?: string[], search?: string, total?: boolean }): Promise<Models.SubscriberList>; + /** + * Get a list of all subscribers from the current Appwrite project. + * + * @param {string} topicId - Topic ID. The topic ID subscribed to. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: targetId, topicId, userId, providerType + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.SubscriberList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listSubscribers(this: Messaging<ServerAuth>, topicId: string, queries?: string[], search?: string, total?: boolean): Promise<Models.SubscriberList>; + listSubscribers( + paramsOrFirst: { topicId: string, queries?: string[], search?: string, total?: boolean } | string, + ...rest: [(string[])?, (string)?, (boolean)?] + ): Promise<Models.SubscriberList> { + let params: { topicId: string, queries?: string[], search?: string, total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, queries?: string[], search?: string, total?: boolean }; + } else { + params = { + topicId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string, + total: rest[2] as boolean + }; + } + + const topicId = params.topicId; + const queries = params.queries; + const search = params.search; + const total = params.total; + + if (typeof topicId === 'undefined') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', topicId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + /** * Create a new subscriber. * @@ -83,6 +4221,67 @@ export class Messaging { ); } + /** + * Get a subscriber by its unique ID. + * + * + * @param {string} params.topicId - Topic ID. The topic ID subscribed to. + * @param {string} params.subscriberId - Subscriber ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Subscriber>} + */ + getSubscriber(this: Messaging<ServerAuth>, params: { topicId: string, subscriberId: string }): Promise<Models.Subscriber>; + /** + * Get a subscriber by its unique ID. + * + * + * @param {string} topicId - Topic ID. The topic ID subscribed to. + * @param {string} subscriberId - Subscriber ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Subscriber>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getSubscriber(this: Messaging<ServerAuth>, topicId: string, subscriberId: string): Promise<Models.Subscriber>; + getSubscriber( + paramsOrFirst: { topicId: string, subscriberId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Subscriber> { + let params: { topicId: string, subscriberId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { topicId: string, subscriberId: string }; + } else { + params = { + topicId: paramsOrFirst as string, + subscriberId: rest[0] as string + }; + } + + const topicId = params.topicId; + const subscriberId = params.subscriberId; + + if (typeof topicId === 'undefined') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + if (typeof subscriberId === 'undefined') { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + + const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', topicId).replace('{subscriberId}', subscriberId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + /** * Delete a subscriber by its unique ID. * @@ -143,3 +4342,9 @@ export class Messaging { ); } } + +const Messaging = MessagingRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): Messaging<TAuth>; +}; + +export { Messaging }; diff --git a/src/services/presences.ts b/src/services/presences.ts index f9df9e18..fe696fc1 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -1,12 +1,21 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload } from '../client'; import type { Models } from '../models'; -export class Presences { - client: Client; +type PresencesServerOnlyMethod = never; +type PresencesClientOnlyMethod = 'upsert' | 'update'; - constructor(client: Client) { +export type Presences<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<PresencesRuntime<TAuth>, 'client' | PresencesServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<PresencesRuntime<TAuth>, 'client' | PresencesClientOnlyMethod> + : Omit<PresencesRuntime<TAuth>, 'client'>; + +class PresencesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } @@ -137,19 +146,21 @@ export class Presences { * * @param {string} params.presenceId - Presence unique ID. * @param {string} params.status - Presence status. + * @param {string} params.userId - User ID. * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {string} params.expiresAt - Presence expiry datetime. * @param {object} params.metadata - Presence metadata object. * @throws {AppwriteException} * @returns {Promise<Presence>} */ - upsert<Presence extends Models.Presence = Models.DefaultPresence>(params: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise<Presence>; + upsert<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, params: { presenceId: string, status: string, userId?: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise<Presence>; /** * Create or update a presence log by its user ID. * * * @param {string} presenceId - Presence unique ID. * @param {string} status - Presence status. + * @param {string} userId - User ID. * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {string} expiresAt - Presence expiry datetime. * @param {object} metadata - Presence metadata object. @@ -157,27 +168,29 @@ export class Presences { * @returns {Promise<Presence>} * @deprecated Use the object parameter style method for a better developer experience. */ - upsert<Presence extends Models.Presence = Models.DefaultPresence>(presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise<Presence>; + upsert<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, presenceId: string, status: string, userId?: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise<Presence>; upsert<Presence extends Models.Presence = Models.DefaultPresence>( - paramsOrFirst: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object } | string, - ...rest: [(string)?, (string[])?, (string)?, (object)?] + paramsOrFirst: { presenceId: string, status: string, userId?: string, permissions?: string[], expiresAt?: string, metadata?: object } | string, + ...rest: [(string)?, (string)?, (string[])?, (string)?, (object)?] ): Promise<Presence> { - let params: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; + let params: { presenceId: string, status: string, userId?: string, permissions?: string[], expiresAt?: string, metadata?: object }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; + params = (paramsOrFirst || {}) as { presenceId: string, status: string, userId?: string, permissions?: string[], expiresAt?: string, metadata?: object }; } else { params = { presenceId: paramsOrFirst as string, status: rest[0] as string, - permissions: rest[1] as string[], - expiresAt: rest[2] as string, - metadata: rest[3] as object + userId: rest[1] as string, + permissions: rest[2] as string[], + expiresAt: rest[3] as string, + metadata: rest[4] as object }; } const presenceId = params.presenceId; const status = params.status; + const userId = params.userId; const permissions = params.permissions; const expiresAt = params.expiresAt; const metadata = params.metadata; @@ -191,6 +204,9 @@ export class Presences { const apiPath = '/presences/{presenceId}'.replace('{presenceId}', presenceId); const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } if (typeof status !== 'undefined') { payload['status'] = status; } @@ -222,6 +238,7 @@ export class Presences { * * * @param {string} params.presenceId - Presence unique ID. + * @param {string} params.userId - User ID. * @param {string} params.status - Presence status. * @param {string} params.expiresAt - Presence expiry datetime. * @param {object} params.metadata - Presence metadata object. @@ -230,12 +247,13 @@ export class Presences { * @throws {AppwriteException} * @returns {Promise<Presence>} */ - update<Presence extends Models.Presence = Models.DefaultPresence>(params: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise<Presence>; + update<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, params: { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise<Presence>; /** * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. * * * @param {string} presenceId - Presence unique ID. + * @param {string} userId - User ID. * @param {string} status - Presence status. * @param {string} expiresAt - Presence expiry datetime. * @param {object} metadata - Presence metadata object. @@ -245,27 +263,29 @@ export class Presences { * @returns {Promise<Presence>} * @deprecated Use the object parameter style method for a better developer experience. */ - update<Presence extends Models.Presence = Models.DefaultPresence>(presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise<Presence>; + update<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise<Presence>; update<Presence extends Models.Presence = Models.DefaultPresence>( - paramsOrFirst: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean } | string, - ...rest: [(string)?, (string)?, (object)?, (string[])?, (boolean)?] + paramsOrFirst: { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (object)?, (string[])?, (boolean)?] ): Promise<Presence> { - let params: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; + let params: { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; + params = (paramsOrFirst || {}) as { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; } else { params = { presenceId: paramsOrFirst as string, - status: rest[0] as string, - expiresAt: rest[1] as string, - metadata: rest[2] as object, - permissions: rest[3] as string[], - purge: rest[4] as boolean + userId: rest[0] as string, + status: rest[1] as string, + expiresAt: rest[2] as string, + metadata: rest[3] as object, + permissions: rest[4] as string[], + purge: rest[5] as boolean }; } const presenceId = params.presenceId; + const userId = params.userId; const status = params.status; const expiresAt = params.expiresAt; const metadata = params.metadata; @@ -278,6 +298,9 @@ export class Presences { const apiPath = '/presences/{presenceId}'.replace('{presenceId}', presenceId); const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } if (typeof status !== 'undefined') { payload['status'] = status; } @@ -361,3 +384,9 @@ export class Presences { ); } } + +const Presences = PresencesRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): Presences<TAuth>; +}; + +export { Presences }; diff --git a/src/services/project.ts b/src/services/project.ts new file mode 100644 index 00000000..3f8bdd0e --- /dev/null +++ b/src/services/project.ts @@ -0,0 +1,6466 @@ +import { AppwriteException, Client, type ServerAuth, type Payload } from '../client'; +import type { Models } from '../models'; + +import { ProjectAuthMethodId } from '../enums/project-auth-method-id'; +import { ProjectKeyScopes } from '../enums/project-key-scopes'; +import { ProjectOAuth2GooglePrompt } from '../enums/project-o-auth-2-google-prompt'; +import { ProjectOAuthProviderId } from '../enums/project-o-auth-provider-id'; +import { ProjectPolicyId } from '../enums/project-policy-id'; +import { ProjectProtocolId } from '../enums/project-protocol-id'; +import { ProjectServiceId } from '../enums/project-service-id'; +import { ProjectSMTPSecure } from '../enums/project-smtp-secure'; +import { ProjectEmailTemplateId } from '../enums/project-email-template-id'; +import { ProjectEmailTemplateLocale } from '../enums/project-email-template-locale'; + +export type Project = Omit<ProjectRuntime, 'client'>; + +class ProjectRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * Get a project. + * + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + get(): Promise<Models.Project> { + + const apiPath = '/project'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a project. + * + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(): Promise<{}> { + + const apiPath = '/project'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. + * + * @param {ProjectAuthMethodId} params.methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + * @param {boolean} params.enabled - Auth method status. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateAuthMethod(params: { methodId: ProjectAuthMethodId, enabled: boolean }): Promise<Models.Project>; + /** + * Update properties of a specific auth method. Use this endpoint to enable or disable a method in your project. + * + * @param {ProjectAuthMethodId} methodId - Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone + * @param {boolean} enabled - Auth method status. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateAuthMethod(methodId: ProjectAuthMethodId, enabled: boolean): Promise<Models.Project>; + updateAuthMethod( + paramsOrFirst: { methodId: ProjectAuthMethodId, enabled: boolean } | ProjectAuthMethodId, + ...rest: [(boolean)?] + ): Promise<Models.Project> { + let params: { methodId: ProjectAuthMethodId, enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('methodId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { methodId: ProjectAuthMethodId, enabled: boolean }; + } else { + params = { + methodId: paramsOrFirst as ProjectAuthMethodId, + enabled: rest[0] as boolean + }; + } + + const methodId = params.methodId; + const enabled = params.enabled; + + if (typeof methodId === 'undefined') { + throw new AppwriteException('Missing required parameter: "methodId"'); + } + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/auth-methods/{methodId}'.replace('{methodId}', methodId); + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all API keys from the current project. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.KeyList>} + */ + listKeys(params?: { queries?: string[], total?: boolean }): Promise<Models.KeyList>; + /** + * Get a list of all API keys from the current project. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.KeyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listKeys(queries?: string[], total?: boolean): Promise<Models.KeyList>; + listKeys( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.KeyList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/project/keys'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create an ephemeral API key if you need a short-lived key instead. + * + * @param {string} params.keyId - Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Key name. Max length: 128 chars. + * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise<Models.Key>} + */ + createKey(params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }): Promise<Models.Key>; + /** + * Create a new API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create an ephemeral API key if you need a short-lived key instead. + * + * @param {string} keyId - Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Key name. Max length: 128 chars. + * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise<Models.Key>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createKey(keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string): Promise<Models.Key>; + createKey( + paramsOrFirst: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string } | string, + ...rest: [(string)?, (ProjectKeyScopes[])?, (string)?] + ): Promise<Models.Key> { + let params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; + } else { + params = { + keyId: paramsOrFirst as string, + name: rest[0] as string, + scopes: rest[1] as ProjectKeyScopes[], + expire: rest[2] as string + }; + } + + const keyId = params.keyId; + const name = params.name; + const scopes = params.scopes; + const expire = params.expire; + + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + + const apiPath = '/project/keys'; + const payload: Payload = {}; + if (typeof keyId !== 'undefined') { + payload['keyId'] = keyId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create a standard API key if you need a longer-lived key instead. + * + * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {number} params.duration - Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.EphemeralKey>} + */ + createEphemeralKey(params: { scopes: ProjectKeyScopes[], duration: number }): Promise<Models.EphemeralKey>; + /** + * Create a new ephemeral API key. It's recommended to have multiple API keys with strict scopes for separate functions within your project. + * + * You can also create a standard API key if you need a longer-lived key instead. + * + * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {number} duration - Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.EphemeralKey>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEphemeralKey(scopes: ProjectKeyScopes[], duration: number): Promise<Models.EphemeralKey>; + createEphemeralKey( + paramsOrFirst: { scopes: ProjectKeyScopes[], duration: number } | ProjectKeyScopes[], + ...rest: [(number)?] + ): Promise<Models.EphemeralKey> { + let params: { scopes: ProjectKeyScopes[], duration: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('scopes' in paramsOrFirst || 'duration' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { scopes: ProjectKeyScopes[], duration: number }; + } else { + params = { + scopes: paramsOrFirst as ProjectKeyScopes[], + duration: rest[0] as number + }; + } + + const scopes = params.scopes; + const duration = params.duration; + + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + if (typeof duration === 'undefined') { + throw new AppwriteException('Missing required parameter: "duration"'); + } + + const apiPath = '/project/keys/ephemeral'; + const payload: Payload = {}; + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof duration !== 'undefined') { + payload['duration'] = duration; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a key by its unique ID. + * + * @param {string} params.keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Key>} + */ + getKey(params: { keyId: string }): Promise<Models.Key>; + /** + * Get a key by its unique ID. + * + * @param {string} keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Key>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getKey(keyId: string): Promise<Models.Key>; + getKey( + paramsOrFirst: { keyId: string } | string + ): Promise<Models.Key> { + let params: { keyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string }; + } else { + params = { + keyId: paramsOrFirst as string + }; + } + + const keyId = params.keyId; + + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + + const apiPath = '/project/keys/{keyId}'.replace('{keyId}', keyId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + * + * @param {string} params.keyId - Key ID. + * @param {string} params.name - Key name. Max length: 128 chars. + * @param {ProjectKeyScopes[]} params.scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} params.expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise<Models.Key>} + */ + updateKey(params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }): Promise<Models.Key>; + /** + * Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. + * + * @param {string} keyId - Key ID. + * @param {string} name - Key name. Max length: 128 chars. + * @param {ProjectKeyScopes[]} scopes - Key scopes list. Maximum of 100 scopes are allowed. + * @param {string} expire - Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + * @throws {AppwriteException} + * @returns {Promise<Models.Key>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateKey(keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string): Promise<Models.Key>; + updateKey( + paramsOrFirst: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string } | string, + ...rest: [(string)?, (ProjectKeyScopes[])?, (string)?] + ): Promise<Models.Key> { + let params: { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string, name: string, scopes: ProjectKeyScopes[], expire?: string }; + } else { + params = { + keyId: paramsOrFirst as string, + name: rest[0] as string, + scopes: rest[1] as ProjectKeyScopes[], + expire: rest[2] as string + }; + } + + const keyId = params.keyId; + const name = params.name; + const scopes = params.scopes; + const expire = params.expire; + + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof scopes === 'undefined') { + throw new AppwriteException('Missing required parameter: "scopes"'); + } + + const apiPath = '/project/keys/{keyId}'.replace('{keyId}', keyId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof scopes !== 'undefined') { + payload['scopes'] = scopes; + } + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. + * + * @param {string} params.keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteKey(params: { keyId: string }): Promise<{}>; + /** + * Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. + * + * @param {string} keyId - Key ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteKey(keyId: string): Promise<{}>; + deleteKey( + paramsOrFirst: { keyId: string } | string + ): Promise<{}> { + let params: { keyId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyId: string }; + } else { + params = { + keyId: paramsOrFirst as string + }; + } + + const keyId = params.keyId; + + if (typeof keyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + + const apiPath = '/project/keys/{keyId}'.replace('{keyId}', keyId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project labels. Labels can be used to easily filter projects in an organization. + * + * @param {string[]} params.labels - Array of project labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateLabels(params: { labels: string[] }): Promise<Models.Project>; + /** + * Update the project labels. Labels can be used to easily filter projects in an organization. + * + * @param {string[]} labels - Array of project labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateLabels(labels: string[]): Promise<Models.Project>; + updateLabels( + paramsOrFirst: { labels: string[] } | string[] + ): Promise<Models.Project> { + let params: { labels: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { labels: string[] }; + } else { + params = { + labels: paramsOrFirst as string[] + }; + } + + const labels = params.labels; + + if (typeof labels === 'undefined') { + throw new AppwriteException('Missing required parameter: "labels"'); + } + + const apiPath = '/project/labels'; + const payload: Payload = {}; + if (typeof labels !== 'undefined') { + payload['labels'] = labels; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all mock phones in the project. This endpoint returns an array of all mock phones and their OTPs. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.MockNumberList>} + */ + listMockPhones(params?: { queries?: string[], total?: boolean }): Promise<Models.MockNumberList>; + /** + * Get a list of all mock phones in the project. This endpoint returns an array of all mock phones and their OTPs. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.MockNumberList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listMockPhones(queries?: string[], total?: boolean): Promise<Models.MockNumberList>; + listMockPhones( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.MockNumberList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/project/mock-phones'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new mock phone for your project. Use this endpoint to register a mock phone number and its sign-in OTP for your testers. + * + * @param {string} params.number - Phone number to associate with the mock phone. Must be a valid E.164 formatted phone number. + * @param {string} params.otp - One-time password (OTP) to associate with the mock phone. Must be a 6-digit numeric code. + * @throws {AppwriteException} + * @returns {Promise<Models.MockNumber>} + */ + createMockPhone(params: { number: string, otp: string }): Promise<Models.MockNumber>; + /** + * Create a new mock phone for your project. Use this endpoint to register a mock phone number and its sign-in OTP for your testers. + * + * @param {string} number - Phone number to associate with the mock phone. Must be a valid E.164 formatted phone number. + * @param {string} otp - One-time password (OTP) to associate with the mock phone. Must be a 6-digit numeric code. + * @throws {AppwriteException} + * @returns {Promise<Models.MockNumber>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMockPhone(number: string, otp: string): Promise<Models.MockNumber>; + createMockPhone( + paramsOrFirst: { number: string, otp: string } | string, + ...rest: [(string)?] + ): Promise<Models.MockNumber> { + let params: { number: string, otp: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { number: string, otp: string }; + } else { + params = { + number: paramsOrFirst as string, + otp: rest[0] as string + }; + } + + const number = params.number; + const otp = params.otp; + + if (typeof number === 'undefined') { + throw new AppwriteException('Missing required parameter: "number"'); + } + if (typeof otp === 'undefined') { + throw new AppwriteException('Missing required parameter: "otp"'); + } + + const apiPath = '/project/mock-phones'; + const payload: Payload = {}; + if (typeof number !== 'undefined') { + payload['number'] = number; + } + if (typeof otp !== 'undefined') { + payload['otp'] = otp; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a mock phone by its unique number. This endpoint returns the mock phone's OTP. + * + * @param {string} params.number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. + * @throws {AppwriteException} + * @returns {Promise<Models.MockNumber>} + */ + getMockPhone(params: { number: string }): Promise<Models.MockNumber>; + /** + * Get a mock phone by its unique number. This endpoint returns the mock phone's OTP. + * + * @param {string} number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. + * @throws {AppwriteException} + * @returns {Promise<Models.MockNumber>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getMockPhone(number: string): Promise<Models.MockNumber>; + getMockPhone( + paramsOrFirst: { number: string } | string + ): Promise<Models.MockNumber> { + let params: { number: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { number: string }; + } else { + params = { + number: paramsOrFirst as string + }; + } + + const number = params.number; + + if (typeof number === 'undefined') { + throw new AppwriteException('Missing required parameter: "number"'); + } + + const apiPath = '/project/mock-phones/{number}'.replace('{number}', number); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a mock phone by its unique number. Use this endpoint to update the mock phone's OTP. + * + * @param {string} params.number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. + * @param {string} params.otp - One-time password (OTP) to associate with the mock phone. Must be a 6-digit numeric code. + * @throws {AppwriteException} + * @returns {Promise<Models.MockNumber>} + */ + updateMockPhone(params: { number: string, otp: string }): Promise<Models.MockNumber>; + /** + * Update a mock phone by its unique number. Use this endpoint to update the mock phone's OTP. + * + * @param {string} number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. + * @param {string} otp - One-time password (OTP) to associate with the mock phone. Must be a 6-digit numeric code. + * @throws {AppwriteException} + * @returns {Promise<Models.MockNumber>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMockPhone(number: string, otp: string): Promise<Models.MockNumber>; + updateMockPhone( + paramsOrFirst: { number: string, otp: string } | string, + ...rest: [(string)?] + ): Promise<Models.MockNumber> { + let params: { number: string, otp: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { number: string, otp: string }; + } else { + params = { + number: paramsOrFirst as string, + otp: rest[0] as string + }; + } + + const number = params.number; + const otp = params.otp; + + if (typeof number === 'undefined') { + throw new AppwriteException('Missing required parameter: "number"'); + } + if (typeof otp === 'undefined') { + throw new AppwriteException('Missing required parameter: "otp"'); + } + + const apiPath = '/project/mock-phones/{number}'.replace('{number}', number); + const payload: Payload = {}; + if (typeof otp !== 'undefined') { + payload['otp'] = otp; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a mock phone by its unique number. This endpoint removes the mock phone and its OTP configuration from the project. + * + * @param {string} params.number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteMockPhone(params: { number: string }): Promise<{}>; + /** + * Delete a mock phone by its unique number. This endpoint removes the mock phone and its OTP configuration from the project. + * + * @param {string} number - Phone number associated with the mock phone. Must be a valid E.164 formatted phone number. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteMockPhone(number: string): Promise<{}>; + deleteMockPhone( + paramsOrFirst: { number: string } | string + ): Promise<{}> { + let params: { number: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { number: string }; + } else { + params = { + number: paramsOrFirst as string + }; + } + + const number = params.number; + + if (typeof number === 'undefined') { + throw new AppwriteException('Missing required parameter: "number"'); + } + + const apiPath = '/project/mock-phones/{number}'.replace('{number}', number); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all OAuth2 providers supported by the server, along with the project's configuration for each. Credential fields are write-only and always returned empty. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2ProviderList>} + */ + listOAuth2Providers(params?: { queries?: string[], total?: boolean }): Promise<Models.OAuth2ProviderList>; + /** + * Get a list of all OAuth2 providers supported by the server, along with the project's configuration for each. Credential fields are write-only and always returned empty. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2ProviderList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listOAuth2Providers(queries?: string[], total?: boolean): Promise<Models.OAuth2ProviderList>; + listOAuth2Providers( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.OAuth2ProviderList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/project/oauth2'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Amazon configuration. + * + * @param {string} params.clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string} params.clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Amazon>} + */ + updateOAuth2Amazon(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Amazon>; + /** + * Update the project OAuth2 Amazon configuration. + * + * @param {string} clientId - 'Client ID' of Amazon OAuth2 app. For example: amzn1.application-oa2-client.87400c00000000000000000000063d5b2 + * @param {string} clientSecret - 'Client Secret' of Amazon OAuth2 app. For example: 79ffe4000000000000000000000000000000000000000000000000000002de55 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Amazon>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Amazon(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Amazon>; + updateOAuth2Amazon( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Amazon> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/amazon'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Apple configuration. + * + * @param {string} params.serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string} params.keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string} params.teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string} params.p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Apple>} + */ + updateOAuth2Apple(params?: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }): Promise<Models.OAuth2Apple>; + /** + * Update the project OAuth2 Apple configuration. + * + * @param {string} serviceId - 'Service ID' of Apple OAuth2 app. For example: ip.appwrite.app.web + * @param {string} keyId - 'Key ID' of Apple OAuth2 app. For example: P4000000N8 + * @param {string} teamId - 'Team ID' of Apple OAuth2 app. For example: D4000000R6 + * @param {string} p8File - Contents of the Apple OAuth2 app .p8 private key file. The secret key wrapped by the PEM markers is 200 characters long. For example: -----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY----- + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Apple>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Apple(serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean): Promise<Models.OAuth2Apple>; + updateOAuth2Apple( + paramsOrFirst?: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.OAuth2Apple> { + let params: { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { serviceId?: string, keyId?: string, teamId?: string, p8File?: string, enabled?: boolean }; + } else { + params = { + serviceId: paramsOrFirst as string, + keyId: rest[0] as string, + teamId: rest[1] as string, + p8File: rest[2] as string, + enabled: rest[3] as boolean + }; + } + + const serviceId = params.serviceId; + const keyId = params.keyId; + const teamId = params.teamId; + const p8File = params.p8File; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/apple'; + const payload: Payload = {}; + if (typeof serviceId !== 'undefined') { + payload['serviceId'] = serviceId; + } + if (typeof keyId !== 'undefined') { + payload['keyId'] = keyId; + } + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + if (typeof p8File !== 'undefined') { + payload['p8File'] = p8File; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Auth0 configuration. + * + * @param {string} params.clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string} params.clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string} params.endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Auth0>} + */ + updateOAuth2Auth0(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise<Models.OAuth2Auth0>; + /** + * Update the project OAuth2 Auth0 configuration. + * + * @param {string} clientId - 'Client ID' of Auth0 OAuth2 app. For example: OaOkIA000000000000000000005KLSYq + * @param {string} clientSecret - 'Client Secret' of Auth0 OAuth2 app. For example: zXz0000-00000000000000000000000000000-00000000000000000000PJafnF + * @param {string} endpoint - Domain of Auth0 instance. For example: example.us.auth0.com + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Auth0>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Auth0(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise<Models.OAuth2Auth0>; + updateOAuth2Auth0( + paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise<Models.OAuth2Auth0> { + let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + endpoint: rest[1] as string, + enabled: rest[2] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const endpoint = params.endpoint; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/auth0'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof endpoint !== 'undefined') { + payload['endpoint'] = endpoint; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Authentik configuration. + * + * @param {string} params.clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string} params.clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string} params.endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Authentik>} + */ + updateOAuth2Authentik(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise<Models.OAuth2Authentik>; + /** + * Update the project OAuth2 Authentik configuration. + * + * @param {string} clientId - 'Client ID' of Authentik OAuth2 app. For example: dTKOPa0000000000000000000000000000e7G8hv + * @param {string} clientSecret - 'Client Secret' of Authentik OAuth2 app. For example: ntQadq000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Hp5WK + * @param {string} endpoint - Domain of Authentik instance. For example: example.authentik.com + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Authentik>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Authentik(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise<Models.OAuth2Authentik>; + updateOAuth2Authentik( + paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise<Models.OAuth2Authentik> { + let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + endpoint: rest[1] as string, + enabled: rest[2] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const endpoint = params.endpoint; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/authentik'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof endpoint !== 'undefined') { + payload['endpoint'] = endpoint; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Autodesk configuration. + * + * @param {string} params.clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string} params.clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Autodesk>} + */ + updateOAuth2Autodesk(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Autodesk>; + /** + * Update the project OAuth2 Autodesk configuration. + * + * @param {string} clientId - 'Client ID' of Autodesk OAuth2 app. For example: 5zw90v00000000000000000000kVYXN7 + * @param {string} clientSecret - 'Client Secret' of Autodesk OAuth2 app. For example: 7I000000000000MW + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Autodesk>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Autodesk(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Autodesk>; + updateOAuth2Autodesk( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Autodesk> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/autodesk'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Bitbucket configuration. + * + * @param {string} params.key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string} params.secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Bitbucket>} + */ + updateOAuth2Bitbucket(params?: { key?: string, secret?: string, enabled?: boolean }): Promise<Models.OAuth2Bitbucket>; + /** + * Update the project OAuth2 Bitbucket configuration. + * + * @param {string} key - 'Key' of Bitbucket OAuth2 app. For example: Knt70000000000ByRc + * @param {string} secret - 'Secret' of Bitbucket OAuth2 app. For example: NMfLZJ00000000000000000000TLQdDx + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Bitbucket>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Bitbucket(key?: string, secret?: string, enabled?: boolean): Promise<Models.OAuth2Bitbucket>; + updateOAuth2Bitbucket( + paramsOrFirst?: { key?: string, secret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Bitbucket> { + let params: { key?: string, secret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { key?: string, secret?: string, enabled?: boolean }; + } else { + params = { + key: paramsOrFirst as string, + secret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const key = params.key; + const secret = params.secret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/bitbucket'; + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Bitly configuration. + * + * @param {string} params.clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string} params.clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Bitly>} + */ + updateOAuth2Bitly(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Bitly>; + /** + * Update the project OAuth2 Bitly configuration. + * + * @param {string} clientId - 'Client ID' of Bitly OAuth2 app. For example: d95151000000000000000000000000000067af9b + * @param {string} clientSecret - 'Client Secret' of Bitly OAuth2 app. For example: a13e250000000000000000000000000000d73095 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Bitly>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Bitly(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Bitly>; + updateOAuth2Bitly( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Bitly> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/bitly'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Box configuration. + * + * @param {string} params.clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string} params.clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Box>} + */ + updateOAuth2Box(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Box>; + /** + * Update the project OAuth2 Box configuration. + * + * @param {string} clientId - 'Client ID' of Box OAuth2 app. For example: deglcs00000000000000000000x2og6y + * @param {string} clientSecret - 'Client Secret' of Box OAuth2 app. For example: OKM1f100000000000000000000eshEif + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Box>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Box(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Box>; + updateOAuth2Box( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Box> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/box'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Dailymotion configuration. + * + * @param {string} params.apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string} params.apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Dailymotion>} + */ + updateOAuth2Dailymotion(params?: { apiKey?: string, apiSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Dailymotion>; + /** + * Update the project OAuth2 Dailymotion configuration. + * + * @param {string} apiKey - 'API Key' of Dailymotion OAuth2 app. For example: 07a9000000000000067f + * @param {string} apiSecret - 'API Secret' of Dailymotion OAuth2 app. For example: a399a90000000000000000000000000000d90639 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Dailymotion>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Dailymotion(apiKey?: string, apiSecret?: string, enabled?: boolean): Promise<Models.OAuth2Dailymotion>; + updateOAuth2Dailymotion( + paramsOrFirst?: { apiKey?: string, apiSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Dailymotion> { + let params: { apiKey?: string, apiSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { apiKey?: string, apiSecret?: string, enabled?: boolean }; + } else { + params = { + apiKey: paramsOrFirst as string, + apiSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const apiKey = params.apiKey; + const apiSecret = params.apiSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/dailymotion'; + const payload: Payload = {}; + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof apiSecret !== 'undefined') { + payload['apiSecret'] = apiSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Discord configuration. + * + * @param {string} params.clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string} params.clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Discord>} + */ + updateOAuth2Discord(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Discord>; + /** + * Update the project OAuth2 Discord configuration. + * + * @param {string} clientId - 'Client ID' of Discord OAuth2 app. For example: 950722000000343754 + * @param {string} clientSecret - 'Client Secret' of Discord OAuth2 app. For example: YmPXnM000000000000000000002zFg5D + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Discord>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Discord(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Discord>; + updateOAuth2Discord( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Discord> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/discord'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Disqus configuration. + * + * @param {string} params.publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string} params.secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Disqus>} + */ + updateOAuth2Disqus(params?: { publicKey?: string, secretKey?: string, enabled?: boolean }): Promise<Models.OAuth2Disqus>; + /** + * Update the project OAuth2 Disqus configuration. + * + * @param {string} publicKey - 'Public Key, also known as API Key' of Disqus OAuth2 app. For example: cgegH70000000000000000000000000000000000000000000000000000Hr1nYX + * @param {string} secretKey - 'Secret Key, also known as API Secret' of Disqus OAuth2 app. For example: W7Bykj00000000000000000000000000000000000000000000000000003o43w9 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Disqus>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Disqus(publicKey?: string, secretKey?: string, enabled?: boolean): Promise<Models.OAuth2Disqus>; + updateOAuth2Disqus( + paramsOrFirst?: { publicKey?: string, secretKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Disqus> { + let params: { publicKey?: string, secretKey?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { publicKey?: string, secretKey?: string, enabled?: boolean }; + } else { + params = { + publicKey: paramsOrFirst as string, + secretKey: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const publicKey = params.publicKey; + const secretKey = params.secretKey; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/disqus'; + const payload: Payload = {}; + if (typeof publicKey !== 'undefined') { + payload['publicKey'] = publicKey; + } + if (typeof secretKey !== 'undefined') { + payload['secretKey'] = secretKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Dropbox configuration. + * + * @param {string} params.appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string} params.appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Dropbox>} + */ + updateOAuth2Dropbox(params?: { appKey?: string, appSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Dropbox>; + /** + * Update the project OAuth2 Dropbox configuration. + * + * @param {string} appKey - 'App Key' of Dropbox OAuth2 app. For example: jl000000000009t + * @param {string} appSecret - 'App Secret' of Dropbox OAuth2 app. For example: g200000000000vw + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Dropbox>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Dropbox(appKey?: string, appSecret?: string, enabled?: boolean): Promise<Models.OAuth2Dropbox>; + updateOAuth2Dropbox( + paramsOrFirst?: { appKey?: string, appSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Dropbox> { + let params: { appKey?: string, appSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appKey?: string, appSecret?: string, enabled?: boolean }; + } else { + params = { + appKey: paramsOrFirst as string, + appSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const appKey = params.appKey; + const appSecret = params.appSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/dropbox'; + const payload: Payload = {}; + if (typeof appKey !== 'undefined') { + payload['appKey'] = appKey; + } + if (typeof appSecret !== 'undefined') { + payload['appSecret'] = appSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Etsy configuration. + * + * @param {string} params.keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string} params.sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Etsy>} + */ + updateOAuth2Etsy(params?: { keyString?: string, sharedSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Etsy>; + /** + * Update the project OAuth2 Etsy configuration. + * + * @param {string} keyString - 'Keystring' of Etsy OAuth2 app. For example: nsgzxh0000000000008j85a2 + * @param {string} sharedSecret - 'Shared Secret' of Etsy OAuth2 app. For example: tp000000ru + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Etsy>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Etsy(keyString?: string, sharedSecret?: string, enabled?: boolean): Promise<Models.OAuth2Etsy>; + updateOAuth2Etsy( + paramsOrFirst?: { keyString?: string, sharedSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Etsy> { + let params: { keyString?: string, sharedSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { keyString?: string, sharedSecret?: string, enabled?: boolean }; + } else { + params = { + keyString: paramsOrFirst as string, + sharedSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const keyString = params.keyString; + const sharedSecret = params.sharedSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/etsy'; + const payload: Payload = {}; + if (typeof keyString !== 'undefined') { + payload['keyString'] = keyString; + } + if (typeof sharedSecret !== 'undefined') { + payload['sharedSecret'] = sharedSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Facebook configuration. + * + * @param {string} params.appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string} params.appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Facebook>} + */ + updateOAuth2Facebook(params?: { appId?: string, appSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Facebook>; + /** + * Update the project OAuth2 Facebook configuration. + * + * @param {string} appId - 'App ID' of Facebook OAuth2 app. For example: 260600000007694 + * @param {string} appSecret - 'App Secret' of Facebook OAuth2 app. For example: 2d0b2800000000000000000000d38af4 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Facebook>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Facebook(appId?: string, appSecret?: string, enabled?: boolean): Promise<Models.OAuth2Facebook>; + updateOAuth2Facebook( + paramsOrFirst?: { appId?: string, appSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Facebook> { + let params: { appId?: string, appSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { appId?: string, appSecret?: string, enabled?: boolean }; + } else { + params = { + appId: paramsOrFirst as string, + appSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const appId = params.appId; + const appSecret = params.appSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/facebook'; + const payload: Payload = {}; + if (typeof appId !== 'undefined') { + payload['appId'] = appId; + } + if (typeof appSecret !== 'undefined') { + payload['appSecret'] = appSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Figma configuration. + * + * @param {string} params.clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string} params.clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Figma>} + */ + updateOAuth2Figma(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Figma>; + /** + * Update the project OAuth2 Figma configuration. + * + * @param {string} clientId - 'Client ID' of Figma OAuth2 app. For example: byay5H0000000000VtiI40 + * @param {string} clientSecret - 'Client Secret' of Figma OAuth2 app. For example: yEpOYn0000000000000000004iIsU5 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Figma>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Figma(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Figma>; + updateOAuth2Figma( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Figma> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/figma'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 FusionAuth configuration. + * + * @param {string} params.clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string} params.clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string} params.endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2FusionAuth>} + */ + updateOAuth2FusionAuth(params?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }): Promise<Models.OAuth2FusionAuth>; + /** + * Update the project OAuth2 FusionAuth configuration. + * + * @param {string} clientId - 'Client ID' of FusionAuth OAuth2 app. For example: b2222c00-0000-0000-0000-000000862097 + * @param {string} clientSecret - 'Client Secret' of FusionAuth OAuth2 app. For example: Jx4s0C0000000000000000000000000000000wGqLsc + * @param {string} endpoint - Domain of FusionAuth instance. For example: example.fusionauth.io + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2FusionAuth>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2FusionAuth(clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean): Promise<Models.OAuth2FusionAuth>; + updateOAuth2FusionAuth( + paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise<Models.OAuth2FusionAuth> { + let params: { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + endpoint: rest[1] as string, + enabled: rest[2] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const endpoint = params.endpoint; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/fusionauth'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof endpoint !== 'undefined') { + payload['endpoint'] = endpoint; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 GitHub configuration. + * + * @param {string} params.clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string} params.clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Github>} + */ + updateOAuth2GitHub(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Github>; + /** + * Update the project OAuth2 GitHub configuration. + * + * @param {string} clientId - 'OAuth2 app Client ID, or App ID' of GitHub OAuth2 app. For example: e4d87900000000540733. Example of wrong value: 370006 + * @param {string} clientSecret - 'Client Secret' of GitHub OAuth2 app. For example: 5e07c00000000000000000000000000000198bcc + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Github>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2GitHub(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Github>; + updateOAuth2GitHub( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Github> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/github'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Gitlab configuration. + * + * @param {string} params.applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string} params.secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string} params.endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Gitlab>} + */ + updateOAuth2Gitlab(params?: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }): Promise<Models.OAuth2Gitlab>; + /** + * Update the project OAuth2 Gitlab configuration. + * + * @param {string} applicationId - 'Application ID' of Gitlab OAuth2 app. For example: d41ffe0000000000000000000000000000000000000000000000000000d5e252 + * @param {string} secret - 'Secret' of Gitlab OAuth2 app. For example: gloas-838cfa0000000000000000000000000000000000000000000000000000ecbb38 + * @param {string} endpoint - Endpoint URL of self-hosted GitLab instance. For example: https://gitlab.com + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Gitlab>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Gitlab(applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean): Promise<Models.OAuth2Gitlab>; + updateOAuth2Gitlab( + paramsOrFirst?: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise<Models.OAuth2Gitlab> { + let params: { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { applicationId?: string, secret?: string, endpoint?: string, enabled?: boolean }; + } else { + params = { + applicationId: paramsOrFirst as string, + secret: rest[0] as string, + endpoint: rest[1] as string, + enabled: rest[2] as boolean + }; + } + + const applicationId = params.applicationId; + const secret = params.secret; + const endpoint = params.endpoint; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/gitlab'; + const payload: Payload = {}; + if (typeof applicationId !== 'undefined') { + payload['applicationId'] = applicationId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + if (typeof endpoint !== 'undefined') { + payload['endpoint'] = endpoint; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Google configuration. + * + * @param {string} params.clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string} params.clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[]} params.prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Google>} + */ + updateOAuth2Google(params?: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }): Promise<Models.OAuth2Google>; + /** + * Update the project OAuth2 Google configuration. + * + * @param {string} clientId - 'Client ID' of Google OAuth2 app. For example: 120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com + * @param {string} clientSecret - 'Client Secret' of Google OAuth2 app. For example: GOCSPX-2k8gsR0000000000000000VNahJj + * @param {ProjectOAuth2GooglePrompt[]} prompt - Array of Google OAuth2 prompt values. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. Must not be specified with other values. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Google>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Google(clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean): Promise<Models.OAuth2Google>; + updateOAuth2Google( + paramsOrFirst?: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean } | string, + ...rest: [(string)?, (ProjectOAuth2GooglePrompt[])?, (boolean)?] + ): Promise<Models.OAuth2Google> { + let params: { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, prompt?: ProjectOAuth2GooglePrompt[], enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + prompt: rest[1] as ProjectOAuth2GooglePrompt[], + enabled: rest[2] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const prompt = params.prompt; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/google'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof prompt !== 'undefined') { + payload['prompt'] = prompt; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Keycloak configuration. + * + * @param {string} params.clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string} params.clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string} params.endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string} params.realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Keycloak>} + */ + updateOAuth2Keycloak(params?: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }): Promise<Models.OAuth2Keycloak>; + /** + * Update the project OAuth2 Keycloak configuration. + * + * @param {string} clientId - 'Client ID' of Keycloak OAuth2 app. For example: appwrite-o0000000st-app + * @param {string} clientSecret - 'Client Secret' of Keycloak OAuth2 app. For example: jdjrJd00000000000000000000HUsaZO + * @param {string} endpoint - Domain of Keycloak instance. For example: keycloak.example.com + * @param {string} realmName - Keycloak realm name. For example: appwrite-realm + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Keycloak>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Keycloak(clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean): Promise<Models.OAuth2Keycloak>; + updateOAuth2Keycloak( + paramsOrFirst?: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.OAuth2Keycloak> { + let params: { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, endpoint?: string, realmName?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + endpoint: rest[1] as string, + realmName: rest[2] as string, + enabled: rest[3] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const endpoint = params.endpoint; + const realmName = params.realmName; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/keycloak'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof endpoint !== 'undefined') { + payload['endpoint'] = endpoint; + } + if (typeof realmName !== 'undefined') { + payload['realmName'] = realmName; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Kick configuration. + * + * @param {string} params.clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string} params.clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Kick>} + */ + updateOAuth2Kick(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Kick>; + /** + * Update the project OAuth2 Kick configuration. + * + * @param {string} clientId - 'Client ID' of Kick OAuth2 app. For example: 01KQ7C00000000000001MFHS32 + * @param {string} clientSecret - 'Client Secret' of Kick OAuth2 app. For example: 34ac5600000000000000000000000000000000000000000000000000e830c8b + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Kick>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Kick(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Kick>; + updateOAuth2Kick( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Kick> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/kick'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Linkedin configuration. + * + * @param {string} params.clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string} params.primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Linkedin>} + */ + updateOAuth2Linkedin(params?: { clientId?: string, primaryClientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Linkedin>; + /** + * Update the project OAuth2 Linkedin configuration. + * + * @param {string} clientId - 'Client ID' of Linkedin OAuth2 app. For example: 770000000000dv + * @param {string} primaryClientSecret - 'Primary Client Secret or Secondary Client Secret' of Linkedin OAuth2 app. For example: WPL_AP1.2Bf0000000000000./HtlYw== + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Linkedin>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Linkedin(clientId?: string, primaryClientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Linkedin>; + updateOAuth2Linkedin( + paramsOrFirst?: { clientId?: string, primaryClientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Linkedin> { + let params: { clientId?: string, primaryClientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, primaryClientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + primaryClientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const primaryClientSecret = params.primaryClientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/linkedin'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof primaryClientSecret !== 'undefined') { + payload['primaryClientSecret'] = primaryClientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Microsoft configuration. + * + * @param {string} params.applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string} params.applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string} params.tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Microsoft>} + */ + updateOAuth2Microsoft(params?: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }): Promise<Models.OAuth2Microsoft>; + /** + * Update the project OAuth2 Microsoft configuration. + * + * @param {string} applicationId - 'Entra ID Application ID, also known as Client ID' of Microsoft OAuth2 app. For example: 00001111-aaaa-2222-bbbb-3333cccc4444 + * @param {string} applicationSecret - 'Entra ID Application Secret, also known as Client Secret' of Microsoft OAuth2 app. For example: A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u + * @param {string} tenant - Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. For example: common + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Microsoft>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Microsoft(applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean): Promise<Models.OAuth2Microsoft>; + updateOAuth2Microsoft( + paramsOrFirst?: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise<Models.OAuth2Microsoft> { + let params: { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { applicationId?: string, applicationSecret?: string, tenant?: string, enabled?: boolean }; + } else { + params = { + applicationId: paramsOrFirst as string, + applicationSecret: rest[0] as string, + tenant: rest[1] as string, + enabled: rest[2] as boolean + }; + } + + const applicationId = params.applicationId; + const applicationSecret = params.applicationSecret; + const tenant = params.tenant; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/microsoft'; + const payload: Payload = {}; + if (typeof applicationId !== 'undefined') { + payload['applicationId'] = applicationId; + } + if (typeof applicationSecret !== 'undefined') { + payload['applicationSecret'] = applicationSecret; + } + if (typeof tenant !== 'undefined') { + payload['tenant'] = tenant; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Notion configuration. + * + * @param {string} params.oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string} params.oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Notion>} + */ + updateOAuth2Notion(params?: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Notion>; + /** + * Update the project OAuth2 Notion configuration. + * + * @param {string} oauthClientId - 'OAuth Client ID' of Notion OAuth2 app. For example: 341d8700-0000-0000-0000-000000446ee3 + * @param {string} oauthClientSecret - 'OAuth Client Secret' of Notion OAuth2 app. For example: secret_dLUr4b000000000000000000000000000000lFHAa9 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Notion>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Notion(oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Notion>; + updateOAuth2Notion( + paramsOrFirst?: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Notion> { + let params: { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { oauthClientId?: string, oauthClientSecret?: string, enabled?: boolean }; + } else { + params = { + oauthClientId: paramsOrFirst as string, + oauthClientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const oauthClientId = params.oauthClientId; + const oauthClientSecret = params.oauthClientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/notion'; + const payload: Payload = {}; + if (typeof oauthClientId !== 'undefined') { + payload['oauthClientId'] = oauthClientId; + } + if (typeof oauthClientSecret !== 'undefined') { + payload['oauthClientSecret'] = oauthClientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Oidc configuration. + * + * @param {string} params.clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string} params.clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string} params.wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string} params.authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string} params.tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string} params.userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Oidc>} + */ + updateOAuth2Oidc(params?: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, enabled?: boolean }): Promise<Models.OAuth2Oidc>; + /** + * Update the project OAuth2 Oidc configuration. + * + * @param {string} clientId - 'Client ID' of Oidc OAuth2 app. For example: qibI2x0000000000000000000000000006L2YFoG + * @param {string} clientSecret - 'Client Secret' of Oidc OAuth2 app. For example: Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV + * @param {string} wellKnownURL - OpenID Connect well-known configuration URL. When provided, authorization, token, and user info endpoints can be discovered automatically. For example: https://myoauth.com/.well-known/openid-configuration + * @param {string} authorizationURL - OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize + * @param {string} tokenURL - OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token + * @param {string} userInfoURL - OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Oidc>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Oidc(clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, enabled?: boolean): Promise<Models.OAuth2Oidc>; + updateOAuth2Oidc( + paramsOrFirst?: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.OAuth2Oidc> { + let params: { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, wellKnownURL?: string, authorizationURL?: string, tokenURL?: string, userInfoURL?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + wellKnownURL: rest[1] as string, + authorizationURL: rest[2] as string, + tokenURL: rest[3] as string, + userInfoURL: rest[4] as string, + enabled: rest[5] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const wellKnownURL = params.wellKnownURL; + const authorizationURL = params.authorizationURL; + const tokenURL = params.tokenURL; + const userInfoURL = params.userInfoURL; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/oidc'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof wellKnownURL !== 'undefined') { + payload['wellKnownURL'] = wellKnownURL; + } + if (typeof authorizationURL !== 'undefined') { + payload['authorizationURL'] = authorizationURL; + } + if (typeof tokenURL !== 'undefined') { + payload['tokenURL'] = tokenURL; + } + if (typeof userInfoURL !== 'undefined') { + payload['userInfoURL'] = userInfoURL; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Okta configuration. + * + * @param {string} params.clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string} params.clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string} params.domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string} params.authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Okta>} + */ + updateOAuth2Okta(params?: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }): Promise<Models.OAuth2Okta>; + /** + * Update the project OAuth2 Okta configuration. + * + * @param {string} clientId - 'Client ID' of Okta OAuth2 app. For example: 0oa00000000000000698 + * @param {string} clientSecret - 'Client Secret' of Okta OAuth2 app. For example: Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV + * @param {string} domain - Okta company domain. Required when enabling the provider. For example: trial-6400025.okta.com. Example of wrong value: trial-6400025-admin.okta.com, or https://trial-6400025.okta.com/ + * @param {string} authorizationServerId - Custom Authorization Servers. Optional, can be left empty or unconfigured. For example: aus000000000000000h7z + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Okta>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Okta(clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean): Promise<Models.OAuth2Okta>; + updateOAuth2Okta( + paramsOrFirst?: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.OAuth2Okta> { + let params: { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, domain?: string, authorizationServerId?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + domain: rest[1] as string, + authorizationServerId: rest[2] as string, + enabled: rest[3] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const domain = params.domain; + const authorizationServerId = params.authorizationServerId; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/okta'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof authorizationServerId !== 'undefined') { + payload['authorizationServerId'] = authorizationServerId; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Paypal configuration. + * + * @param {string} params.clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Paypal>} + */ + updateOAuth2Paypal(params?: { clientId?: string, secretKey?: string, enabled?: boolean }): Promise<Models.OAuth2Paypal>; + /** + * Update the project OAuth2 Paypal configuration. + * + * @param {string} clientId - 'Client ID' of Paypal OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of Paypal OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Paypal>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Paypal(clientId?: string, secretKey?: string, enabled?: boolean): Promise<Models.OAuth2Paypal>; + updateOAuth2Paypal( + paramsOrFirst?: { clientId?: string, secretKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Paypal> { + let params: { clientId?: string, secretKey?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, secretKey?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + secretKey: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const secretKey = params.secretKey; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/paypal'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof secretKey !== 'undefined') { + payload['secretKey'] = secretKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 PaypalSandbox configuration. + * + * @param {string} params.clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string} params.secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Paypal>} + */ + updateOAuth2PaypalSandbox(params?: { clientId?: string, secretKey?: string, enabled?: boolean }): Promise<Models.OAuth2Paypal>; + /** + * Update the project OAuth2 PaypalSandbox configuration. + * + * @param {string} clientId - 'Client ID' of PaypalSandbox OAuth2 app. For example: AdhIEG7-000000000000-0000000000000000000000000000000-0000000000000000000000-2pyB + * @param {string} secretKey - 'Secret Key 1 or Secret Key 2' of PaypalSandbox OAuth2 app. For example: EH8KCXtew--000000000000000000000000000000000000000_C-1_5UP_000000000000000CB7KDp + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Paypal>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2PaypalSandbox(clientId?: string, secretKey?: string, enabled?: boolean): Promise<Models.OAuth2Paypal>; + updateOAuth2PaypalSandbox( + paramsOrFirst?: { clientId?: string, secretKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Paypal> { + let params: { clientId?: string, secretKey?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, secretKey?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + secretKey: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const secretKey = params.secretKey; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/paypalSandbox'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof secretKey !== 'undefined') { + payload['secretKey'] = secretKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Podio configuration. + * + * @param {string} params.clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string} params.clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Podio>} + */ + updateOAuth2Podio(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Podio>; + /** + * Update the project OAuth2 Podio configuration. + * + * @param {string} clientId - 'Client ID' of Podio OAuth2 app. For example: appwrite-o0000000st-app + * @param {string} clientSecret - 'Client Secret' of Podio OAuth2 app. For example: Rn247T0000000000000000000000000000000000000000000000000000W2zWTN + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Podio>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Podio(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Podio>; + updateOAuth2Podio( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Podio> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/podio'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Salesforce configuration. + * + * @param {string} params.customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string} params.customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Salesforce>} + */ + updateOAuth2Salesforce(params?: { customerKey?: string, customerSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Salesforce>; + /** + * Update the project OAuth2 Salesforce configuration. + * + * @param {string} customerKey - 'Consumer Key' of Salesforce OAuth2 app. For example: 3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq + * @param {string} customerSecret - 'Consumer Secret' of Salesforce OAuth2 app. For example: 3w000000000000e2 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Salesforce>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Salesforce(customerKey?: string, customerSecret?: string, enabled?: boolean): Promise<Models.OAuth2Salesforce>; + updateOAuth2Salesforce( + paramsOrFirst?: { customerKey?: string, customerSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Salesforce> { + let params: { customerKey?: string, customerSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { customerKey?: string, customerSecret?: string, enabled?: boolean }; + } else { + params = { + customerKey: paramsOrFirst as string, + customerSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const customerKey = params.customerKey; + const customerSecret = params.customerSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/salesforce'; + const payload: Payload = {}; + if (typeof customerKey !== 'undefined') { + payload['customerKey'] = customerKey; + } + if (typeof customerSecret !== 'undefined') { + payload['customerSecret'] = customerSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Slack configuration. + * + * @param {string} params.clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string} params.clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Slack>} + */ + updateOAuth2Slack(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Slack>; + /** + * Update the project OAuth2 Slack configuration. + * + * @param {string} clientId - 'Client ID' of Slack OAuth2 app. For example: 23000000089.15000000000023 + * @param {string} clientSecret - 'Client Secret' of Slack OAuth2 app. For example: 81656000000000000000000000f3d2fd + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Slack>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Slack(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Slack>; + updateOAuth2Slack( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Slack> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/slack'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Spotify configuration. + * + * @param {string} params.clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string} params.clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Spotify>} + */ + updateOAuth2Spotify(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Spotify>; + /** + * Update the project OAuth2 Spotify configuration. + * + * @param {string} clientId - 'Client ID' of Spotify OAuth2 app. For example: 6ec271000000000000000000009beace + * @param {string} clientSecret - 'Client Secret' of Spotify OAuth2 app. For example: db068a000000000000000000008b5b9f + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Spotify>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Spotify(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Spotify>; + updateOAuth2Spotify( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Spotify> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/spotify'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Stripe configuration. + * + * @param {string} params.clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string} params.apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Stripe>} + */ + updateOAuth2Stripe(params?: { clientId?: string, apiSecretKey?: string, enabled?: boolean }): Promise<Models.OAuth2Stripe>; + /** + * Update the project OAuth2 Stripe configuration. + * + * @param {string} clientId - 'Client ID' of Stripe OAuth2 app. For example: ca_UKibXX0000000000000000000006byvR + * @param {string} apiSecretKey - 'API Secret Key' of Stripe OAuth2 app. For example: sk_51SfOd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000QGWYfp + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Stripe>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Stripe(clientId?: string, apiSecretKey?: string, enabled?: boolean): Promise<Models.OAuth2Stripe>; + updateOAuth2Stripe( + paramsOrFirst?: { clientId?: string, apiSecretKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Stripe> { + let params: { clientId?: string, apiSecretKey?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, apiSecretKey?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + apiSecretKey: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const apiSecretKey = params.apiSecretKey; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/stripe'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof apiSecretKey !== 'undefined') { + payload['apiSecretKey'] = apiSecretKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Tradeshift configuration. + * + * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Tradeshift>} + */ + updateOAuth2Tradeshift(params?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Tradeshift>; + /** + * Update the project OAuth2 Tradeshift configuration. + * + * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Tradeshift>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Tradeshift(oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Tradeshift>; + updateOAuth2Tradeshift( + paramsOrFirst?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Tradeshift> { + let params: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + } else { + params = { + oauth2ClientId: paramsOrFirst as string, + oauth2ClientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const oauth2ClientId = params.oauth2ClientId; + const oauth2ClientSecret = params.oauth2ClientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/tradeshift'; + const payload: Payload = {}; + if (typeof oauth2ClientId !== 'undefined') { + payload['oauth2ClientId'] = oauth2ClientId; + } + if (typeof oauth2ClientSecret !== 'undefined') { + payload['oauth2ClientSecret'] = oauth2ClientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Tradeshift Sandbox configuration. + * + * @param {string} params.oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string} params.oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Tradeshift>} + */ + updateOAuth2TradeshiftSandbox(params?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Tradeshift>; + /** + * Update the project OAuth2 Tradeshift Sandbox configuration. + * + * @param {string} oauth2ClientId - 'OAuth2 Client ID' of Tradeshift Sandbox OAuth2 app. For example: appwrite-tes00000.0000000000est-app + * @param {string} oauth2ClientSecret - 'OAuth2 Client Secret' of Tradeshift Sandbox OAuth2 app. For example: 7cb52700-0000-0000-0000-000000ca5b83 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Tradeshift>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2TradeshiftSandbox(oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Tradeshift>; + updateOAuth2TradeshiftSandbox( + paramsOrFirst?: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Tradeshift> { + let params: { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { oauth2ClientId?: string, oauth2ClientSecret?: string, enabled?: boolean }; + } else { + params = { + oauth2ClientId: paramsOrFirst as string, + oauth2ClientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const oauth2ClientId = params.oauth2ClientId; + const oauth2ClientSecret = params.oauth2ClientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/tradeshiftBox'; + const payload: Payload = {}; + if (typeof oauth2ClientId !== 'undefined') { + payload['oauth2ClientId'] = oauth2ClientId; + } + if (typeof oauth2ClientSecret !== 'undefined') { + payload['oauth2ClientSecret'] = oauth2ClientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Twitch configuration. + * + * @param {string} params.clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string} params.clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Twitch>} + */ + updateOAuth2Twitch(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Twitch>; + /** + * Update the project OAuth2 Twitch configuration. + * + * @param {string} clientId - 'Client ID' of Twitch OAuth2 app. For example: vvi0in000000000000000000ikmt9p + * @param {string} clientSecret - 'Client Secret' of Twitch OAuth2 app. For example: pmapue000000000000000000zylw3v + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Twitch>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Twitch(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Twitch>; + updateOAuth2Twitch( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Twitch> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/twitch'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 WordPress configuration. + * + * @param {string} params.clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string} params.clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2WordPress>} + */ + updateOAuth2WordPress(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2WordPress>; + /** + * Update the project OAuth2 WordPress configuration. + * + * @param {string} clientId - 'Client ID' of WordPress OAuth2 app. For example: 130005 + * @param {string} clientSecret - 'Client Secret' of WordPress OAuth2 app. For example: PlBfJS0000000000000000000000000000000000000000000000000000EdUZJk + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2WordPress>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2WordPress(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2WordPress>; + updateOAuth2WordPress( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2WordPress> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/wordpress'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 X configuration. + * + * @param {string} params.customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string} params.secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2X>} + */ + updateOAuth2X(params?: { customerKey?: string, secretKey?: string, enabled?: boolean }): Promise<Models.OAuth2X>; + /** + * Update the project OAuth2 X configuration. + * + * @param {string} customerKey - 'Customer Key' of X OAuth2 app. For example: slzZV0000000000000NFLaWT + * @param {string} secretKey - 'Secret Key' of X OAuth2 app. For example: tkEPkp00000000000000000000000000000000000000FTxbI9 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2X>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2X(customerKey?: string, secretKey?: string, enabled?: boolean): Promise<Models.OAuth2X>; + updateOAuth2X( + paramsOrFirst?: { customerKey?: string, secretKey?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2X> { + let params: { customerKey?: string, secretKey?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { customerKey?: string, secretKey?: string, enabled?: boolean }; + } else { + params = { + customerKey: paramsOrFirst as string, + secretKey: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const customerKey = params.customerKey; + const secretKey = params.secretKey; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/x'; + const payload: Payload = {}; + if (typeof customerKey !== 'undefined') { + payload['customerKey'] = customerKey; + } + if (typeof secretKey !== 'undefined') { + payload['secretKey'] = secretKey; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Yahoo configuration. + * + * @param {string} params.clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string} params.clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Yahoo>} + */ + updateOAuth2Yahoo(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Yahoo>; + /** + * Update the project OAuth2 Yahoo configuration. + * + * @param {string} clientId - 'Client ID, also known as Customer Key' of Yahoo OAuth2 app. For example: dj0yJm000000000000000000000000000000000000000000000000000000000000000000000000000000000000Z4PWRm + * @param {string} clientSecret - 'Client Secret, also known as Customer Secret' of Yahoo OAuth2 app. For example: cf978f0000000000000000000000000000c5e2e9 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Yahoo>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Yahoo(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Yahoo>; + updateOAuth2Yahoo( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Yahoo> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/yahoo'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Yandex configuration. + * + * @param {string} params.clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string} params.clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Yandex>} + */ + updateOAuth2Yandex(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Yandex>; + /** + * Update the project OAuth2 Yandex configuration. + * + * @param {string} clientId - 'Client ID' of Yandex OAuth2 app. For example: 6a8a6a0000000000000000000091483c + * @param {string} clientSecret - 'Client Secret' of Yandex OAuth2 app. For example: bbf98500000000000000000000c75a63 + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Yandex>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Yandex(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Yandex>; + updateOAuth2Yandex( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Yandex> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/yandex'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Zoho configuration. + * + * @param {string} params.clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string} params.clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Zoho>} + */ + updateOAuth2Zoho(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Zoho>; + /** + * Update the project OAuth2 Zoho configuration. + * + * @param {string} clientId - 'Client ID' of Zoho OAuth2 app. For example: 1000.83C178000000000000000000RPNX0B + * @param {string} clientSecret - 'Client Secret' of Zoho OAuth2 app. For example: fb5cac000000000000000000000000000000a68f6e + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Zoho>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Zoho(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Zoho>; + updateOAuth2Zoho( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Zoho> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/zoho'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the project OAuth2 Zoom configuration. + * + * @param {string} params.clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string} params.clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean} params.enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Zoom>} + */ + updateOAuth2Zoom(params?: { clientId?: string, clientSecret?: string, enabled?: boolean }): Promise<Models.OAuth2Zoom>; + /** + * Update the project OAuth2 Zoom configuration. + * + * @param {string} clientId - 'Client ID' of Zoom OAuth2 app. For example: QMAC00000000000000w0AQ + * @param {string} clientSecret - 'Client Secret' of Zoom OAuth2 app. For example: GAWsG4000000000000000000007U01ON + * @param {boolean} enabled - OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Zoom>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateOAuth2Zoom(clientId?: string, clientSecret?: string, enabled?: boolean): Promise<Models.OAuth2Zoom>; + updateOAuth2Zoom( + paramsOrFirst?: { clientId?: string, clientSecret?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.OAuth2Zoom> { + let params: { clientId?: string, clientSecret?: string, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { clientId?: string, clientSecret?: string, enabled?: boolean }; + } else { + params = { + clientId: paramsOrFirst as string, + clientSecret: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const clientId = params.clientId; + const clientSecret = params.clientSecret; + const enabled = params.enabled; + + + const apiPath = '/project/oauth2/zoom'; + const payload: Payload = {}; + if (typeof clientId !== 'undefined') { + payload['clientId'] = clientId; + } + if (typeof clientSecret !== 'undefined') { + payload['clientSecret'] = clientSecret; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. + * + * @param {ProjectOAuthProviderId} params.providerId - OAuth2 provider key. For example: github, google, apple. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Github | Models.OAuth2Discord | Models.OAuth2Figma | Models.OAuth2Dropbox | Models.OAuth2Dailymotion | Models.OAuth2Bitbucket | Models.OAuth2Bitly | Models.OAuth2Box | Models.OAuth2Autodesk | Models.OAuth2Google | Models.OAuth2Zoom | Models.OAuth2Zoho | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify | Models.OAuth2Slack | Models.OAuth2Podio | Models.OAuth2Notion | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon | Models.OAuth2Etsy | Models.OAuth2Facebook | Models.OAuth2Tradeshift | Models.OAuth2Paypal | Models.OAuth2Gitlab | Models.OAuth2Authentik | Models.OAuth2Auth0 | Models.OAuth2FusionAuth | Models.OAuth2Keycloak | Models.OAuth2Oidc | Models.OAuth2Apple | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft>} + */ + getOAuth2Provider(params: { providerId: ProjectOAuthProviderId }): Promise<Models.OAuth2Github | Models.OAuth2Discord | Models.OAuth2Figma | Models.OAuth2Dropbox | Models.OAuth2Dailymotion | Models.OAuth2Bitbucket | Models.OAuth2Bitly | Models.OAuth2Box | Models.OAuth2Autodesk | Models.OAuth2Google | Models.OAuth2Zoom | Models.OAuth2Zoho | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify | Models.OAuth2Slack | Models.OAuth2Podio | Models.OAuth2Notion | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon | Models.OAuth2Etsy | Models.OAuth2Facebook | Models.OAuth2Tradeshift | Models.OAuth2Paypal | Models.OAuth2Gitlab | Models.OAuth2Authentik | Models.OAuth2Auth0 | Models.OAuth2FusionAuth | Models.OAuth2Keycloak | Models.OAuth2Oidc | Models.OAuth2Apple | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft>; + /** + * Get a single OAuth2 provider configuration. Credential fields (client secret, p8 file, key/team IDs) are write-only and always returned empty. + * + * @param {ProjectOAuthProviderId} providerId - OAuth2 provider key. For example: github, google, apple. + * @throws {AppwriteException} + * @returns {Promise<Models.OAuth2Github | Models.OAuth2Discord | Models.OAuth2Figma | Models.OAuth2Dropbox | Models.OAuth2Dailymotion | Models.OAuth2Bitbucket | Models.OAuth2Bitly | Models.OAuth2Box | Models.OAuth2Autodesk | Models.OAuth2Google | Models.OAuth2Zoom | Models.OAuth2Zoho | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify | Models.OAuth2Slack | Models.OAuth2Podio | Models.OAuth2Notion | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon | Models.OAuth2Etsy | Models.OAuth2Facebook | Models.OAuth2Tradeshift | Models.OAuth2Paypal | Models.OAuth2Gitlab | Models.OAuth2Authentik | Models.OAuth2Auth0 | Models.OAuth2FusionAuth | Models.OAuth2Keycloak | Models.OAuth2Oidc | Models.OAuth2Apple | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getOAuth2Provider(providerId: ProjectOAuthProviderId): Promise<Models.OAuth2Github | Models.OAuth2Discord | Models.OAuth2Figma | Models.OAuth2Dropbox | Models.OAuth2Dailymotion | Models.OAuth2Bitbucket | Models.OAuth2Bitly | Models.OAuth2Box | Models.OAuth2Autodesk | Models.OAuth2Google | Models.OAuth2Zoom | Models.OAuth2Zoho | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify | Models.OAuth2Slack | Models.OAuth2Podio | Models.OAuth2Notion | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon | Models.OAuth2Etsy | Models.OAuth2Facebook | Models.OAuth2Tradeshift | Models.OAuth2Paypal | Models.OAuth2Gitlab | Models.OAuth2Authentik | Models.OAuth2Auth0 | Models.OAuth2FusionAuth | Models.OAuth2Keycloak | Models.OAuth2Oidc | Models.OAuth2Apple | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft>; + getOAuth2Provider( + paramsOrFirst: { providerId: ProjectOAuthProviderId } | ProjectOAuthProviderId + ): Promise<Models.OAuth2Github | Models.OAuth2Discord | Models.OAuth2Figma | Models.OAuth2Dropbox | Models.OAuth2Dailymotion | Models.OAuth2Bitbucket | Models.OAuth2Bitly | Models.OAuth2Box | Models.OAuth2Autodesk | Models.OAuth2Google | Models.OAuth2Zoom | Models.OAuth2Zoho | Models.OAuth2Yandex | Models.OAuth2X | Models.OAuth2WordPress | Models.OAuth2Twitch | Models.OAuth2Stripe | Models.OAuth2Spotify | Models.OAuth2Slack | Models.OAuth2Podio | Models.OAuth2Notion | Models.OAuth2Salesforce | Models.OAuth2Yahoo | Models.OAuth2Linkedin | Models.OAuth2Disqus | Models.OAuth2Amazon | Models.OAuth2Etsy | Models.OAuth2Facebook | Models.OAuth2Tradeshift | Models.OAuth2Paypal | Models.OAuth2Gitlab | Models.OAuth2Authentik | Models.OAuth2Auth0 | Models.OAuth2FusionAuth | Models.OAuth2Keycloak | Models.OAuth2Oidc | Models.OAuth2Apple | Models.OAuth2Okta | Models.OAuth2Kick | Models.OAuth2Microsoft> { + let params: { providerId: ProjectOAuthProviderId }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('providerId' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: ProjectOAuthProviderId }; + } else { + params = { + providerId: paramsOrFirst as ProjectOAuthProviderId + }; + } + + const providerId = params.providerId; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/project/oauth2/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, name, hostname, bundleIdentifier, applicationId, packageIdentifierName, packageName + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformList>} + */ + listPlatforms(params?: { queries?: string[], total?: boolean }): Promise<Models.PlatformList>; + /** + * Get a list of all platforms in the project. This endpoint returns an array of all platforms and their configurations. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, name, hostname, bundleIdentifier, applicationId, packageIdentifierName, packageName + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPlatforms(queries?: string[], total?: boolean): Promise<Models.PlatformList>; + listPlatforms( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.PlatformList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/project/platforms'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformAndroid>} + */ + createAndroidPlatform(params: { platformId: string, name: string, applicationId: string }): Promise<Models.PlatformAndroid>; + /** + * Create a new Android platform for your project. Use this endpoint to register a new Android platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformAndroid>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createAndroidPlatform(platformId: string, name: string, applicationId: string): Promise<Models.PlatformAndroid>; + createAndroidPlatform( + paramsOrFirst: { platformId: string, name: string, applicationId: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.PlatformAndroid> { + let params: { platformId: string, name: string, applicationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, applicationId: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + applicationId: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const applicationId = params.applicationId; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof applicationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "applicationId"'); + } + + const apiPath = '/project/platforms/android'; + const payload: Payload = {}; + if (typeof platformId !== 'undefined') { + payload['platformId'] = platformId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof applicationId !== 'undefined') { + payload['applicationId'] = applicationId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * + * @param {string} params.platformId - Platform ID. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.applicationId - Android application ID. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformAndroid>} + */ + updateAndroidPlatform(params: { platformId: string, name: string, applicationId: string }): Promise<Models.PlatformAndroid>; + /** + * Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. + * + * @param {string} platformId - Platform ID. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} applicationId - Android application ID. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformAndroid>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateAndroidPlatform(platformId: string, name: string, applicationId: string): Promise<Models.PlatformAndroid>; + updateAndroidPlatform( + paramsOrFirst: { platformId: string, name: string, applicationId: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.PlatformAndroid> { + let params: { platformId: string, name: string, applicationId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, applicationId: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + applicationId: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const applicationId = params.applicationId; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof applicationId === 'undefined') { + throw new AppwriteException('Missing required parameter: "applicationId"'); + } + + const apiPath = '/project/platforms/android/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof applicationId !== 'undefined') { + payload['applicationId'] = applicationId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformApple>} + */ + createApplePlatform(params: { platformId: string, name: string, bundleIdentifier: string }): Promise<Models.PlatformApple>; + /** + * Create a new Apple platform for your project. Use this endpoint to register a new Apple platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformApple>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createApplePlatform(platformId: string, name: string, bundleIdentifier: string): Promise<Models.PlatformApple>; + createApplePlatform( + paramsOrFirst: { platformId: string, name: string, bundleIdentifier: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.PlatformApple> { + let params: { platformId: string, name: string, bundleIdentifier: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, bundleIdentifier: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + bundleIdentifier: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const bundleIdentifier = params.bundleIdentifier; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof bundleIdentifier === 'undefined') { + throw new AppwriteException('Missing required parameter: "bundleIdentifier"'); + } + + const apiPath = '/project/platforms/apple'; + const payload: Payload = {}; + if (typeof platformId !== 'undefined') { + payload['platformId'] = platformId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof bundleIdentifier !== 'undefined') { + payload['bundleIdentifier'] = bundleIdentifier; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. + * + * @param {string} params.platformId - Platform ID. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformApple>} + */ + updateApplePlatform(params: { platformId: string, name: string, bundleIdentifier: string }): Promise<Models.PlatformApple>; + /** + * Update an Apple platform by its unique ID. Use this endpoint to update the platform's name or bundle identifier. + * + * @param {string} platformId - Platform ID. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} bundleIdentifier - Apple bundle identifier. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformApple>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateApplePlatform(platformId: string, name: string, bundleIdentifier: string): Promise<Models.PlatformApple>; + updateApplePlatform( + paramsOrFirst: { platformId: string, name: string, bundleIdentifier: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.PlatformApple> { + let params: { platformId: string, name: string, bundleIdentifier: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, bundleIdentifier: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + bundleIdentifier: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const bundleIdentifier = params.bundleIdentifier; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof bundleIdentifier === 'undefined') { + throw new AppwriteException('Missing required parameter: "bundleIdentifier"'); + } + + const apiPath = '/project/platforms/apple/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof bundleIdentifier !== 'undefined') { + payload['bundleIdentifier'] = bundleIdentifier; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.packageName - Linux package name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformLinux>} + */ + createLinuxPlatform(params: { platformId: string, name: string, packageName: string }): Promise<Models.PlatformLinux>; + /** + * Create a new Linux platform for your project. Use this endpoint to register a new Linux platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} packageName - Linux package name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformLinux>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createLinuxPlatform(platformId: string, name: string, packageName: string): Promise<Models.PlatformLinux>; + createLinuxPlatform( + paramsOrFirst: { platformId: string, name: string, packageName: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.PlatformLinux> { + let params: { platformId: string, name: string, packageName: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, packageName: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + packageName: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const packageName = params.packageName; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof packageName === 'undefined') { + throw new AppwriteException('Missing required parameter: "packageName"'); + } + + const apiPath = '/project/platforms/linux'; + const payload: Payload = {}; + if (typeof platformId !== 'undefined') { + payload['platformId'] = platformId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof packageName !== 'undefined') { + payload['packageName'] = packageName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. + * + * @param {string} params.platformId - Platform ID. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.packageName - Linux package name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformLinux>} + */ + updateLinuxPlatform(params: { platformId: string, name: string, packageName: string }): Promise<Models.PlatformLinux>; + /** + * Update a Linux platform by its unique ID. Use this endpoint to update the platform's name or package name. + * + * @param {string} platformId - Platform ID. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} packageName - Linux package name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformLinux>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateLinuxPlatform(platformId: string, name: string, packageName: string): Promise<Models.PlatformLinux>; + updateLinuxPlatform( + paramsOrFirst: { platformId: string, name: string, packageName: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.PlatformLinux> { + let params: { platformId: string, name: string, packageName: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, packageName: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + packageName: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const packageName = params.packageName; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof packageName === 'undefined') { + throw new AppwriteException('Missing required parameter: "packageName"'); + } + + const apiPath = '/project/platforms/linux/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof packageName !== 'undefined') { + payload['packageName'] = packageName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.hostname - Platform web hostname. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformWeb>} + */ + createWebPlatform(params: { platformId: string, name: string, hostname: string }): Promise<Models.PlatformWeb>; + /** + * Create a new web platform for your project. Use this endpoint to register a new platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} hostname - Platform web hostname. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformWeb>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createWebPlatform(platformId: string, name: string, hostname: string): Promise<Models.PlatformWeb>; + createWebPlatform( + paramsOrFirst: { platformId: string, name: string, hostname: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.PlatformWeb> { + let params: { platformId: string, name: string, hostname: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, hostname: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + hostname: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const hostname = params.hostname; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof hostname === 'undefined') { + throw new AppwriteException('Missing required parameter: "hostname"'); + } + + const apiPath = '/project/platforms/web'; + const payload: Payload = {}; + if (typeof platformId !== 'undefined') { + payload['platformId'] = platformId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof hostname !== 'undefined') { + payload['hostname'] = hostname; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. + * + * @param {string} params.platformId - Platform ID. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.hostname - Platform web hostname. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformWeb>} + */ + updateWebPlatform(params: { platformId: string, name: string, hostname: string }): Promise<Models.PlatformWeb>; + /** + * Update a web platform by its unique ID. Use this endpoint to update the platform's name or hostname. + * + * @param {string} platformId - Platform ID. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} hostname - Platform web hostname. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformWeb>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateWebPlatform(platformId: string, name: string, hostname: string): Promise<Models.PlatformWeb>; + updateWebPlatform( + paramsOrFirst: { platformId: string, name: string, hostname: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.PlatformWeb> { + let params: { platformId: string, name: string, hostname: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, hostname: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + hostname: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const hostname = params.hostname; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof hostname === 'undefined') { + throw new AppwriteException('Missing required parameter: "hostname"'); + } + + const apiPath = '/project/platforms/web/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof hostname !== 'undefined') { + payload['hostname'] = hostname; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} params.platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformWindows>} + */ + createWindowsPlatform(params: { platformId: string, name: string, packageIdentifierName: string }): Promise<Models.PlatformWindows>; + /** + * Create a new Windows platform for your project. Use this endpoint to register a new Windows platform where your users will run your application which will interact with the Appwrite API. + * + * @param {string} platformId - Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformWindows>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createWindowsPlatform(platformId: string, name: string, packageIdentifierName: string): Promise<Models.PlatformWindows>; + createWindowsPlatform( + paramsOrFirst: { platformId: string, name: string, packageIdentifierName: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.PlatformWindows> { + let params: { platformId: string, name: string, packageIdentifierName: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, packageIdentifierName: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + packageIdentifierName: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const packageIdentifierName = params.packageIdentifierName; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof packageIdentifierName === 'undefined') { + throw new AppwriteException('Missing required parameter: "packageIdentifierName"'); + } + + const apiPath = '/project/platforms/windows'; + const payload: Payload = {}; + if (typeof platformId !== 'undefined') { + payload['platformId'] = platformId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof packageIdentifierName !== 'undefined') { + payload['packageIdentifierName'] = packageIdentifierName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. + * + * @param {string} params.platformId - Platform ID. + * @param {string} params.name - Platform name. Max length: 128 chars. + * @param {string} params.packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformWindows>} + */ + updateWindowsPlatform(params: { platformId: string, name: string, packageIdentifierName: string }): Promise<Models.PlatformWindows>; + /** + * Update a Windows platform by its unique ID. Use this endpoint to update the platform's name or package identifier name. + * + * @param {string} platformId - Platform ID. + * @param {string} name - Platform name. Max length: 128 chars. + * @param {string} packageIdentifierName - Windows package identifier name. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformWindows>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateWindowsPlatform(platformId: string, name: string, packageIdentifierName: string): Promise<Models.PlatformWindows>; + updateWindowsPlatform( + paramsOrFirst: { platformId: string, name: string, packageIdentifierName: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.PlatformWindows> { + let params: { platformId: string, name: string, packageIdentifierName: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string, name: string, packageIdentifierName: string }; + } else { + params = { + platformId: paramsOrFirst as string, + name: rest[0] as string, + packageIdentifierName: rest[1] as string + }; + } + + const platformId = params.platformId; + const name = params.name; + const packageIdentifierName = params.packageIdentifierName; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof packageIdentifierName === 'undefined') { + throw new AppwriteException('Missing required parameter: "packageIdentifierName"'); + } + + const apiPath = '/project/platforms/windows/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof packageIdentifierName !== 'undefined') { + payload['packageIdentifierName'] = packageIdentifierName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. + * + * @param {string} params.platformId - Platform ID. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformWeb | Models.PlatformApple | Models.PlatformAndroid | Models.PlatformWindows | Models.PlatformLinux>} + */ + getPlatform(params: { platformId: string }): Promise<Models.PlatformWeb | Models.PlatformApple | Models.PlatformAndroid | Models.PlatformWindows | Models.PlatformLinux>; + /** + * Get a platform by its unique ID. This endpoint returns the platform's details, including its name, type, and key configurations. + * + * @param {string} platformId - Platform ID. + * @throws {AppwriteException} + * @returns {Promise<Models.PlatformWeb | Models.PlatformApple | Models.PlatformAndroid | Models.PlatformWindows | Models.PlatformLinux>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPlatform(platformId: string): Promise<Models.PlatformWeb | Models.PlatformApple | Models.PlatformAndroid | Models.PlatformWindows | Models.PlatformLinux>; + getPlatform( + paramsOrFirst: { platformId: string } | string + ): Promise<Models.PlatformWeb | Models.PlatformApple | Models.PlatformAndroid | Models.PlatformWindows | Models.PlatformLinux> { + let params: { platformId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string }; + } else { + params = { + platformId: paramsOrFirst as string + }; + } + + const platformId = params.platformId; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + + const apiPath = '/project/platforms/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a platform by its unique ID. This endpoint removes the platform and all its configurations from the project. + * + * @param {string} params.platformId - Platform ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deletePlatform(params: { platformId: string }): Promise<{}>; + /** + * Delete a platform by its unique ID. This endpoint removes the platform and all its configurations from the project. + * + * @param {string} platformId - Platform ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deletePlatform(platformId: string): Promise<{}>; + deletePlatform( + paramsOrFirst: { platformId: string } | string + ): Promise<{}> { + let params: { platformId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { platformId: string }; + } else { + params = { + platformId: paramsOrFirst as string + }; + } + + const platformId = params.platformId; + + if (typeof platformId === 'undefined') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + + const apiPath = '/project/platforms/{platformId}'.replace('{platformId}', platformId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all project policies and their current configuration. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PolicyList>} + */ + listPolicies(params?: { queries?: string[], total?: boolean }): Promise<Models.PolicyList>; + /** + * Get a list of all project policies and their current configuration. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.PolicyList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listPolicies(queries?: string[], total?: boolean): Promise<Models.PolicyList>; + listPolicies( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.PolicyList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/project/policies'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Configures if aliased emails such as subaddresses and emails with suffixes are denied during new users sign-ups and email updates. + * + * @param {boolean} params.enabled - Set whether or not to block aliased emails during signup and email updates. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateDenyAliasedEmailPolicy(params: { enabled: boolean }): Promise<Models.Project>; + /** + * Configures if aliased emails such as subaddresses and emails with suffixes are denied during new users sign-ups and email updates. + * + * @param {boolean} enabled - Set whether or not to block aliased emails during signup and email updates. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDenyAliasedEmailPolicy(enabled: boolean): Promise<Models.Project>; + updateDenyAliasedEmailPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise<Models.Project> { + let params: { enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { enabled: boolean }; + } else { + params = { + enabled: paramsOrFirst as boolean + }; + } + + const enabled = params.enabled; + + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/policies/deny-aliased-email'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Configures if disposable emails from known temporary domains are denied during new users sign-ups and email updates. + * + * @param {boolean} params.enabled - Set whether or not to block disposable email addresses during signup and email updates. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateDenyDisposableEmailPolicy(params: { enabled: boolean }): Promise<Models.Project>; + /** + * Configures if disposable emails from known temporary domains are denied during new users sign-ups and email updates. + * + * @param {boolean} enabled - Set whether or not to block disposable email addresses during signup and email updates. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDenyDisposableEmailPolicy(enabled: boolean): Promise<Models.Project>; + updateDenyDisposableEmailPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise<Models.Project> { + let params: { enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { enabled: boolean }; + } else { + params = { + enabled: paramsOrFirst as boolean + }; + } + + const enabled = params.enabled; + + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/policies/deny-disposable-email'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Configures if emails from free providers such as Gmail or Yahoo are denied during new users sign-ups and email updates. + * + * @param {boolean} params.enabled - Set whether or not to block free email addresses during signup and email updates. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateDenyFreeEmailPolicy(params: { enabled: boolean }): Promise<Models.Project>; + /** + * Configures if emails from free providers such as Gmail or Yahoo are denied during new users sign-ups and email updates. + * + * @param {boolean} enabled - Set whether or not to block free email addresses during signup and email updates. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDenyFreeEmailPolicy(enabled: boolean): Promise<Models.Project>; + updateDenyFreeEmailPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise<Models.Project> { + let params: { enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { enabled: boolean }; + } else { + params = { + enabled: paramsOrFirst as boolean + }; + } + + const enabled = params.enabled; + + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/policies/deny-free-email'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. + * + * @param {boolean} params.userId - Set to true if you want make user ID visible to all team members, or false to hide it. + * @param {boolean} params.userEmail - Set to true if you want make user email visible to all team members, or false to hide it. + * @param {boolean} params.userPhone - Set to true if you want make user phone number visible to all team members, or false to hide it. + * @param {boolean} params.userName - Set to true if you want make user name visible to all team members, or false to hide it. + * @param {boolean} params.userMFA - Set to true if you want make user MFA status visible to all team members, or false to hide it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateMembershipPrivacyPolicy(params?: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean }): Promise<Models.Project>; + /** + * Updating this policy allows you to control if team members can see other members information. When enabled, all team members can see ID, name, email, phone number, and MFA status of other members.. + * + * @param {boolean} userId - Set to true if you want make user ID visible to all team members, or false to hide it. + * @param {boolean} userEmail - Set to true if you want make user email visible to all team members, or false to hide it. + * @param {boolean} userPhone - Set to true if you want make user phone number visible to all team members, or false to hide it. + * @param {boolean} userName - Set to true if you want make user name visible to all team members, or false to hide it. + * @param {boolean} userMFA - Set to true if you want make user MFA status visible to all team members, or false to hide it. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMembershipPrivacyPolicy(userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean): Promise<Models.Project>; + updateMembershipPrivacyPolicy( + paramsOrFirst?: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean } | boolean, + ...rest: [(boolean)?, (boolean)?, (boolean)?, (boolean)?] + ): Promise<Models.Project> { + let params: { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId?: boolean, userEmail?: boolean, userPhone?: boolean, userName?: boolean, userMFA?: boolean }; + } else { + params = { + userId: paramsOrFirst as boolean, + userEmail: rest[0] as boolean, + userPhone: rest[1] as boolean, + userName: rest[2] as boolean, + userMFA: rest[3] as boolean + }; + } + + const userId = params.userId; + const userEmail = params.userEmail; + const userPhone = params.userPhone; + const userName = params.userName; + const userMFA = params.userMFA; + + + const apiPath = '/project/policies/membership-privacy'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof userEmail !== 'undefined') { + payload['userEmail'] = userEmail; + } + if (typeof userPhone !== 'undefined') { + payload['userPhone'] = userPhone; + } + if (typeof userName !== 'undefined') { + payload['userName'] = userName; + } + if (typeof userMFA !== 'undefined') { + payload['userMFA'] = userMFA; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Updating this policy allows you to control if new passwords are checked against most common passwords dictionary. When enabled, and user changes their password, password must not be contained in the dictionary. + * + * @param {boolean} params.enabled - Toggle password dictionary policy. Set to true if you want password change to block passwords in the dictionary, or false to allow them. When changing this policy, existing passwords remain valid. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasswordDictionaryPolicy(params: { enabled: boolean }): Promise<Models.Project>; + /** + * Updating this policy allows you to control if new passwords are checked against most common passwords dictionary. When enabled, and user changes their password, password must not be contained in the dictionary. + * + * @param {boolean} enabled - Toggle password dictionary policy. Set to true if you want password change to block passwords in the dictionary, or false to allow them. When changing this policy, existing passwords remain valid. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordDictionaryPolicy(enabled: boolean): Promise<Models.Project>; + updatePasswordDictionaryPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise<Models.Project> { + let params: { enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { enabled: boolean }; + } else { + params = { + enabled: paramsOrFirst as boolean + }; + } + + const enabled = params.enabled; + + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/policies/password-dictionary'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. + * + * Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. + * + * @param {number} params.total - Set the password history length per user. Value can be between 1 and 5000, or null to disable the limit. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasswordHistoryPolicy(params: { total?: number }): Promise<Models.Project>; + /** + * Updates one of password strength policies. Based on total length configured, previous password hashes are stored, and users cannot choose a new password that is already stored in the passwird history list, when updating an user password, or setting new one through password recovery. + * + * Keep in mind, while password history policy is disabled, the history is not being stored. Enabling the policy will not have any history on existing users, and it will only start to collect and enforce the policy on password changes since the policy is enabled. + * + * @param {number} total - Set the password history length per user. Value can be between 1 and 5000, or null to disable the limit. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordHistoryPolicy(total?: number): Promise<Models.Project>; + updatePasswordHistoryPolicy( + paramsOrFirst?: { total?: number } | number + ): Promise<Models.Project> { + let params: { total?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { total?: number }; + } else { + params = { + total: paramsOrFirst as number + }; + } + + const total = params.total; + + if (typeof total === 'undefined') { + throw new AppwriteException('Missing required parameter: "total"'); + } + + const apiPath = '/project/policies/password-history'; + const payload: Payload = {}; + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. + * + * @param {boolean} params.enabled - Toggle password personal data policy. Set to true if you want to block passwords including user's personal data, or false to allow it. When changing this policy, existing passwords remain valid. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updatePasswordPersonalDataPolicy(params: { enabled: boolean }): Promise<Models.Project>; + /** + * Updating this policy allows you to control if password strength is checked against personal data. When enabled, and user sets or changes their password, the password must not contain user ID, name, email or phone number. + * + * @param {boolean} enabled - Toggle password personal data policy. Set to true if you want to block passwords including user's personal data, or false to allow it. When changing this policy, existing passwords remain valid. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePasswordPersonalDataPolicy(enabled: boolean): Promise<Models.Project>; + updatePasswordPersonalDataPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise<Models.Project> { + let params: { enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { enabled: boolean }; + } else { + params = { + enabled: paramsOrFirst as boolean + }; + } + + const enabled = params.enabled; + + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/policies/password-personal-data'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. + * + * @param {boolean} params.enabled - Toggle session alert policy. Set to true if you want users to receive email notifications when a sessions are created for their users, or false to not send email alerts. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateSessionAlertPolicy(params: { enabled: boolean }): Promise<Models.Project>; + /** + * Updating this policy allows you to control if email alert is sent upon session creation. When enabled, and user signs into their account, they will be sent an email notification. There is an exception, the first session after a new sign up does not trigger an alert, even if the policy is enabled. + * + * @param {boolean} enabled - Toggle session alert policy. Set to true if you want users to receive email notifications when a sessions are created for their users, or false to not send email alerts. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSessionAlertPolicy(enabled: boolean): Promise<Models.Project>; + updateSessionAlertPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise<Models.Project> { + let params: { enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { enabled: boolean }; + } else { + params = { + enabled: paramsOrFirst as boolean + }; + } + + const enabled = params.enabled; + + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/policies/session-alert'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update maximum duration how long sessions created within a project should stay active for. + * + * @param {number} params.duration - Maximum session length in seconds. Minium allowed value is 5 second, and maximum is 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateSessionDurationPolicy(params: { duration: number }): Promise<Models.Project>; + /** + * Update maximum duration how long sessions created within a project should stay active for. + * + * @param {number} duration - Maximum session length in seconds. Minium allowed value is 5 second, and maximum is 1 year, which is 31536000 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSessionDurationPolicy(duration: number): Promise<Models.Project>; + updateSessionDurationPolicy( + paramsOrFirst: { duration: number } | number + ): Promise<Models.Project> { + let params: { duration: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { duration: number }; + } else { + params = { + duration: paramsOrFirst as number + }; + } + + const duration = params.duration; + + if (typeof duration === 'undefined') { + throw new AppwriteException('Missing required parameter: "duration"'); + } + + const apiPath = '/project/policies/session-duration'; + const payload: Payload = {}; + if (typeof duration !== 'undefined') { + payload['duration'] = duration; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Updating this policy allows you to control if existing sessions should be invalidated when a password of a user is changed. When enabled, and user changes their password, they will be logged out of all their devices. + * + * @param {boolean} params.enabled - Toggle session invalidation policy. Set to true if you want password change to invalidate all sessions of an user, or false to keep sessions active. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateSessionInvalidationPolicy(params: { enabled: boolean }): Promise<Models.Project>; + /** + * Updating this policy allows you to control if existing sessions should be invalidated when a password of a user is changed. When enabled, and user changes their password, they will be logged out of all their devices. + * + * @param {boolean} enabled - Toggle session invalidation policy. Set to true if you want password change to invalidate all sessions of an user, or false to keep sessions active. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSessionInvalidationPolicy(enabled: boolean): Promise<Models.Project>; + updateSessionInvalidationPolicy( + paramsOrFirst: { enabled: boolean } | boolean + ): Promise<Models.Project> { + let params: { enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { enabled: boolean }; + } else { + params = { + enabled: paramsOrFirst as boolean + }; + } + + const enabled = params.enabled; + + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/policies/session-invalidation'; + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the maximum number of sessions allowed per user. When the limit is hit, the oldest session will be deleted to make room for new one. + * + * @param {number} params.total - Set the maximum number of sessions allowed per user. Value can be between 1 and 5000, or null to disable the limit. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateSessionLimitPolicy(params: { total?: number }): Promise<Models.Project>; + /** + * Update the maximum number of sessions allowed per user. When the limit is hit, the oldest session will be deleted to make room for new one. + * + * @param {number} total - Set the maximum number of sessions allowed per user. Value can be between 1 and 5000, or null to disable the limit. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSessionLimitPolicy(total?: number): Promise<Models.Project>; + updateSessionLimitPolicy( + paramsOrFirst?: { total?: number } | number + ): Promise<Models.Project> { + let params: { total?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { total?: number }; + } else { + params = { + total: paramsOrFirst as number + }; + } + + const total = params.total; + + if (typeof total === 'undefined') { + throw new AppwriteException('Missing required parameter: "total"'); + } + + const apiPath = '/project/policies/session-limit'; + const payload: Payload = {}; + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. + * + * @param {number} params.total - Set the maximum number of users allowed in the project. Value can be between 1 and 5000, or null to disable the limit. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateUserLimitPolicy(params: { total?: number }): Promise<Models.Project>; + /** + * Update the maximum number of users in the project. When the limit is hit or amount of existing users already exceeded the limit, all users remain active, but new user sign up will be prohibited. + * + * @param {number} total - Set the maximum number of users allowed in the project. Value can be between 1 and 5000, or null to disable the limit. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateUserLimitPolicy(total?: number): Promise<Models.Project>; + updateUserLimitPolicy( + paramsOrFirst?: { total?: number } | number + ): Promise<Models.Project> { + let params: { total?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { total?: number }; + } else { + params = { + total: paramsOrFirst as number + }; + } + + const total = params.total; + + if (typeof total === 'undefined') { + throw new AppwriteException('Missing required parameter: "total"'); + } + + const apiPath = '/project/policies/user-limit'; + const payload: Payload = {}; + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. + * + * @param {ProjectPolicyId} params.policyId - Policy ID. Can be one of: password-dictionary, password-history, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy. + * @throws {AppwriteException} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordPersonalData | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy>} + */ + getPolicy(params: { policyId: ProjectPolicyId }): Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordPersonalData | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy>; + /** + * Get a policy by its unique ID. This endpoint returns the current configuration for the requested project policy. + * + * @param {ProjectPolicyId} policyId - Policy ID. Can be one of: password-dictionary, password-history, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy. + * @throws {AppwriteException} + * @returns {Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordPersonalData | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPolicy(policyId: ProjectPolicyId): Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordPersonalData | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy>; + getPolicy( + paramsOrFirst: { policyId: ProjectPolicyId } | ProjectPolicyId + ): Promise<Models.PolicyPasswordDictionary | Models.PolicyPasswordHistory | Models.PolicyPasswordPersonalData | Models.PolicySessionAlert | Models.PolicySessionDuration | Models.PolicySessionInvalidation | Models.PolicySessionLimit | Models.PolicyUserLimit | Models.PolicyMembershipPrivacy> { + let params: { policyId: ProjectPolicyId }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('policyId' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { policyId: ProjectPolicyId }; + } else { + params = { + policyId: paramsOrFirst as ProjectPolicyId + }; + } + + const policyId = params.policyId; + + if (typeof policyId === 'undefined') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + + const apiPath = '/project/policies/{policyId}'.replace('{policyId}', policyId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + * + * @param {ProjectProtocolId} params.protocolId - Protocol name. Can be one of: rest, graphql, websocket + * @param {boolean} params.enabled - Protocol status. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateProtocol(params: { protocolId: ProjectProtocolId, enabled: boolean }): Promise<Models.Project>; + /** + * Update properties of a specific protocol. Use this endpoint to enable or disable a protocol in your project. + * + * @param {ProjectProtocolId} protocolId - Protocol name. Can be one of: rest, graphql, websocket + * @param {boolean} enabled - Protocol status. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateProtocol(protocolId: ProjectProtocolId, enabled: boolean): Promise<Models.Project>; + updateProtocol( + paramsOrFirst: { protocolId: ProjectProtocolId, enabled: boolean } | ProjectProtocolId, + ...rest: [(boolean)?] + ): Promise<Models.Project> { + let params: { protocolId: ProjectProtocolId, enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('protocolId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { protocolId: ProjectProtocolId, enabled: boolean }; + } else { + params = { + protocolId: paramsOrFirst as ProjectProtocolId, + enabled: rest[0] as boolean + }; + } + + const protocolId = params.protocolId; + const enabled = params.enabled; + + if (typeof protocolId === 'undefined') { + throw new AppwriteException('Missing required parameter: "protocolId"'); + } + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/protocols/{protocolId}'.replace('{protocolId}', protocolId); + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. + * + * @param {ProjectServiceId} params.serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging, advisor + * @param {boolean} params.enabled - Service status. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateService(params: { serviceId: ProjectServiceId, enabled: boolean }): Promise<Models.Project>; + /** + * Update properties of a specific service. Use this endpoint to enable or disable a service in your project. + * + * @param {ProjectServiceId} serviceId - Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging, advisor + * @param {boolean} enabled - Service status. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateService(serviceId: ProjectServiceId, enabled: boolean): Promise<Models.Project>; + updateService( + paramsOrFirst: { serviceId: ProjectServiceId, enabled: boolean } | ProjectServiceId, + ...rest: [(boolean)?] + ): Promise<Models.Project> { + let params: { serviceId: ProjectServiceId, enabled: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('serviceId' in paramsOrFirst || 'enabled' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { serviceId: ProjectServiceId, enabled: boolean }; + } else { + params = { + serviceId: paramsOrFirst as ProjectServiceId, + enabled: rest[0] as boolean + }; + } + + const serviceId = params.serviceId; + const enabled = params.enabled; + + if (typeof serviceId === 'undefined') { + throw new AppwriteException('Missing required parameter: "serviceId"'); + } + if (typeof enabled === 'undefined') { + throw new AppwriteException('Missing required parameter: "enabled"'); + } + + const apiPath = '/project/services/{serviceId}'.replace('{serviceId}', serviceId); + const payload: Payload = {}; + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the SMTP configuration for your project. Use this endpoint to configure your project's SMTP provider with your custom settings for sending transactional emails. + * + * @param {string} params.host - SMTP server hostname (domain) + * @param {number} params.port - SMTP server port + * @param {string} params.username - SMTP server username. Leave empty for no authorization. + * @param {string} params.password - SMTP server password. Leave empty for no authorization. This property is stored securely and cannot be read in future (write-only). + * @param {string} params.senderEmail - Email address shown in inbox as the sender of the email. + * @param {string} params.senderName - Name shown in inbox as the sender of the email. + * @param {string} params.replyToEmail - Email used when user replies to the email. + * @param {string} params.replyToName - Name used when user replies to the email. + * @param {ProjectSMTPSecure} params.secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean} params.enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + */ + updateSMTP(params?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }): Promise<Models.Project>; + /** + * Update the SMTP configuration for your project. Use this endpoint to configure your project's SMTP provider with your custom settings for sending transactional emails. + * + * @param {string} host - SMTP server hostname (domain) + * @param {number} port - SMTP server port + * @param {string} username - SMTP server username. Leave empty for no authorization. + * @param {string} password - SMTP server password. Leave empty for no authorization. This property is stored securely and cannot be read in future (write-only). + * @param {string} senderEmail - Email address shown in inbox as the sender of the email. + * @param {string} senderName - Name shown in inbox as the sender of the email. + * @param {string} replyToEmail - Email used when user replies to the email. + * @param {string} replyToName - Name used when user replies to the email. + * @param {ProjectSMTPSecure} secure - Configures if communication with SMTP server is encrypted. Allowed values are: tls, ssl. Leave empty for no encryption. + * @param {boolean} enabled - Enable or disable custom SMTP. Custom SMTP is useful for branding purposes, but also allows use of custom email templates. + * @throws {AppwriteException} + * @returns {Promise<Models.Project>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSMTP(host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean): Promise<Models.Project>; + updateSMTP( + paramsOrFirst?: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean } | string, + ...rest: [(number)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (ProjectSMTPSecure)?, (boolean)?] + ): Promise<Models.Project> { + let params: { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { host?: string, port?: number, username?: string, password?: string, senderEmail?: string, senderName?: string, replyToEmail?: string, replyToName?: string, secure?: ProjectSMTPSecure, enabled?: boolean }; + } else { + params = { + host: paramsOrFirst as string, + port: rest[0] as number, + username: rest[1] as string, + password: rest[2] as string, + senderEmail: rest[3] as string, + senderName: rest[4] as string, + replyToEmail: rest[5] as string, + replyToName: rest[6] as string, + secure: rest[7] as ProjectSMTPSecure, + enabled: rest[8] as boolean + }; + } + + const host = params.host; + const port = params.port; + const username = params.username; + const password = params.password; + const senderEmail = params.senderEmail; + const senderName = params.senderName; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; + const secure = params.secure; + const enabled = params.enabled; + + + const apiPath = '/project/smtp'; + const payload: Payload = {}; + if (typeof host !== 'undefined') { + payload['host'] = host; + } + if (typeof port !== 'undefined') { + payload['port'] = port; + } + if (typeof username !== 'undefined') { + payload['username'] = username; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof senderEmail !== 'undefined') { + payload['senderEmail'] = senderEmail; + } + if (typeof senderName !== 'undefined') { + payload['senderName'] = senderName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof secure !== 'undefined') { + payload['secure'] = secure; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Send a test email to verify SMTP configuration. + * + * @param {string[]} params.emails - Array of emails to send test email to. Maximum of 10 emails are allowed. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + createSMTPTest(params: { emails: string[] }): Promise<{}>; + /** + * Send a test email to verify SMTP configuration. + * + * @param {string[]} emails - Array of emails to send test email to. Maximum of 10 emails are allowed. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSMTPTest(emails: string[]): Promise<{}>; + createSMTPTest( + paramsOrFirst: { emails: string[] } | string[] + ): Promise<{}> { + let params: { emails: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { emails: string[] }; + } else { + params = { + emails: paramsOrFirst as string[] + }; + } + + const emails = params.emails; + + if (typeof emails === 'undefined') { + throw new AppwriteException('Missing required parameter: "emails"'); + } + + const apiPath = '/project/smtp/tests'; + const payload: Payload = {}; + if (typeof emails !== 'undefined') { + payload['emails'] = emails; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all custom email templates configured for the project. This endpoint returns an array of all configured email templates and their locales. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.EmailTemplateList>} + */ + listEmailTemplates(params?: { queries?: string[], total?: boolean }): Promise<Models.EmailTemplateList>; + /** + * Get a list of all custom email templates configured for the project. This endpoint returns an array of all configured email templates and their locales. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.EmailTemplateList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listEmailTemplates(queries?: string[], total?: boolean): Promise<Models.EmailTemplateList>; + listEmailTemplates( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.EmailTemplateList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/project/templates/email'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. + * + * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. + * @param {string} params.subject - Subject of the email template. Can be up to 255 characters. + * @param {string} params.message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string} params.senderName - Name of the email sender. + * @param {string} params.senderEmail - Email of the sender. + * @param {string} params.replyToEmail - Reply to email. + * @param {string} params.replyToName - Reply to name. + * @throws {AppwriteException} + * @returns {Promise<Models.EmailTemplate>} + */ + updateEmailTemplate(params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }): Promise<Models.EmailTemplate>; + /** + * Update a custom email template for the specified locale and type. Use this endpoint to modify the content of your email templates. + * + * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. + * @param {string} subject - Subject of the email template. Can be up to 255 characters. + * @param {string} message - Plain or HTML body of the email template message. Can be up to 10MB of content. + * @param {string} senderName - Name of the email sender. + * @param {string} senderEmail - Email of the sender. + * @param {string} replyToEmail - Reply to email. + * @param {string} replyToName - Reply to name. + * @throws {AppwriteException} + * @returns {Promise<Models.EmailTemplate>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmailTemplate(templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string): Promise<Models.EmailTemplate>; + updateEmailTemplate( + paramsOrFirst: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string } | ProjectEmailTemplateId, + ...rest: [(ProjectEmailTemplateLocale)?, (string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise<Models.EmailTemplate> { + let params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst || 'subject' in paramsOrFirst || 'message' in paramsOrFirst || 'senderName' in paramsOrFirst || 'senderEmail' in paramsOrFirst || 'replyToEmail' in paramsOrFirst || 'replyToName' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale, subject?: string, message?: string, senderName?: string, senderEmail?: string, replyToEmail?: string, replyToName?: string }; + } else { + params = { + templateId: paramsOrFirst as ProjectEmailTemplateId, + locale: rest[0] as ProjectEmailTemplateLocale, + subject: rest[1] as string, + message: rest[2] as string, + senderName: rest[3] as string, + senderEmail: rest[4] as string, + replyToEmail: rest[5] as string, + replyToName: rest[6] as string + }; + } + + const templateId = params.templateId; + const locale = params.locale; + const subject = params.subject; + const message = params.message; + const senderName = params.senderName; + const senderEmail = params.senderEmail; + const replyToEmail = params.replyToEmail; + const replyToName = params.replyToName; + + if (typeof templateId === 'undefined') { + throw new AppwriteException('Missing required parameter: "templateId"'); + } + + const apiPath = '/project/templates/email'; + const payload: Payload = {}; + if (typeof templateId !== 'undefined') { + payload['templateId'] = templateId; + } + if (typeof locale !== 'undefined') { + payload['locale'] = locale; + } + if (typeof subject !== 'undefined') { + payload['subject'] = subject; + } + if (typeof message !== 'undefined') { + payload['message'] = message; + } + if (typeof senderName !== 'undefined') { + payload['senderName'] = senderName; + } + if (typeof senderEmail !== 'undefined') { + payload['senderEmail'] = senderEmail; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. + * + * @param {ProjectEmailTemplateId} params.templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateLocale} params.locale - Custom email template locale. If left empty, the fallback locale (en) will be used. + * @throws {AppwriteException} + * @returns {Promise<Models.EmailTemplate>} + */ + getEmailTemplate(params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }): Promise<Models.EmailTemplate>; + /** + * Get a custom email template for the specified locale and type. This endpoint returns the template content, subject, and other configuration details. + * + * @param {ProjectEmailTemplateId} templateId - Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession + * @param {ProjectEmailTemplateLocale} locale - Custom email template locale. If left empty, the fallback locale (en) will be used. + * @throws {AppwriteException} + * @returns {Promise<Models.EmailTemplate>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getEmailTemplate(templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale): Promise<Models.EmailTemplate>; + getEmailTemplate( + paramsOrFirst: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale } | ProjectEmailTemplateId, + ...rest: [(ProjectEmailTemplateLocale)?] + ): Promise<Models.EmailTemplate> { + let params: { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('templateId' in paramsOrFirst || 'locale' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { templateId: ProjectEmailTemplateId, locale?: ProjectEmailTemplateLocale }; + } else { + params = { + templateId: paramsOrFirst as ProjectEmailTemplateId, + locale: rest[0] as ProjectEmailTemplateLocale + }; + } + + const templateId = params.templateId; + const locale = params.locale; + + if (typeof templateId === 'undefined') { + throw new AppwriteException('Missing required parameter: "templateId"'); + } + + const apiPath = '/project/templates/email/{templateId}'.replace('{templateId}', templateId); + const payload: Payload = {}; + if (typeof locale !== 'undefined') { + payload['locale'] = locale; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all project environment variables. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.VariableList>} + */ + listVariables(params?: { queries?: string[], total?: boolean }): Promise<Models.VariableList>; + /** + * Get a list of all project environment variables. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.VariableList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listVariables(queries?: string[], total?: boolean): Promise<Models.VariableList>; + listVariables( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.VariableList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/project/variables'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. + * + * @param {string} params.variableId - Variable unique ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + */ + createVariable(params: { variableId: string, key: string, value: string, secret?: boolean }): Promise<Models.Variable>; + /** + * Create a new project environment variable. These variables can be accessed by all functions and sites in the project. + * + * @param {string} variableId - Variable unique ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVariable(variableId: string, key: string, value: string, secret?: boolean): Promise<Models.Variable>; + createVariable( + paramsOrFirst: { variableId: string, key: string, value: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise<Models.Variable> { + let params: { variableId: string, key: string, value: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { variableId: string, key: string, value: string, secret?: boolean }; + } else { + params = { + variableId: paramsOrFirst as string, + key: rest[0] as string, + value: rest[1] as string, + secret: rest[2] as boolean + }; + } + + const variableId = params.variableId; + const key = params.key; + const value = params.value; + const secret = params.secret; + + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + + const apiPath = '/project/variables'; + const payload: Payload = {}; + if (typeof variableId !== 'undefined') { + payload['variableId'] = variableId; + } + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a variable by its unique ID. + * + * @param {string} params.variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + */ + getVariable(params: { variableId: string }): Promise<Models.Variable>; + /** + * Get a variable by its unique ID. + * + * @param {string} variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getVariable(variableId: string): Promise<Models.Variable>; + getVariable( + paramsOrFirst: { variableId: string } | string + ): Promise<Models.Variable> { + let params: { variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { variableId: string }; + } else { + params = { + variableId: paramsOrFirst as string + }; + } + + const variableId = params.variableId; + + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update variable by its unique ID. + * + * @param {string} params.variableId - Variable unique ID. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + */ + updateVariable(params: { variableId: string, key?: string, value?: string, secret?: boolean }): Promise<Models.Variable>; + /** + * Update variable by its unique ID. + * + * @param {string} variableId - Variable unique ID. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only projects can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateVariable(variableId: string, key?: string, value?: string, secret?: boolean): Promise<Models.Variable>; + updateVariable( + paramsOrFirst: { variableId: string, key?: string, value?: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?] + ): Promise<Models.Variable> { + let params: { variableId: string, key?: string, value?: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { variableId: string, key?: string, value?: string, secret?: boolean }; + } else { + params = { + variableId: paramsOrFirst as string, + key: rest[0] as string, + value: rest[1] as string, + secret: rest[2] as boolean + }; + } + + const variableId = params.variableId; + const key = params.key; + const value = params.value; + const secret = params.secret; + + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a variable by its unique ID. + * + * @param {string} params.variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteVariable(params: { variableId: string }): Promise<{}>; + /** + * Delete a variable by its unique ID. + * + * @param {string} variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteVariable(variableId: string): Promise<{}>; + deleteVariable( + paramsOrFirst: { variableId: string } | string + ): Promise<{}> { + let params: { variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { variableId: string }; + } else { + params = { + variableId: paramsOrFirst as string + }; + } + + const variableId = params.variableId; + + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } +} + +const Project = ProjectRuntime as unknown as { + new (client: Client<ServerAuth>): Project; +}; + +export { Project }; diff --git a/src/services/proxy.ts b/src/services/proxy.ts new file mode 100644 index 00000000..6e8e0919 --- /dev/null +++ b/src/services/proxy.ts @@ -0,0 +1,548 @@ +import { AppwriteException, Client, type ServerAuth, type Payload } from '../client'; +import type { Models } from '../models'; + +import { StatusCode } from '../enums/status-code'; +import { ProxyResourceType } from '../enums/proxy-resource-type'; + +export type Proxy = Omit<ProxyRuntime, 'client'>; + +class ProxyRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * Get a list of all the proxy rules. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRuleList>} + */ + listRules(params?: { queries?: string[], total?: boolean }): Promise<Models.ProxyRuleList>; + /** + * Get a list of all the proxy rules. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRuleList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listRules(queries?: string[], total?: boolean): Promise<Models.ProxyRuleList>; + listRules( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.ProxyRuleList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/proxy/rules'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new proxy rule for serving Appwrite's API on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} params.domain - Domain name. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + */ + createAPIRule(params: { domain: string }): Promise<Models.ProxyRule>; + /** + * Create a new proxy rule for serving Appwrite's API on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} domain - Domain name. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createAPIRule(domain: string): Promise<Models.ProxyRule>; + createAPIRule( + paramsOrFirst: { domain: string } | string + ): Promise<Models.ProxyRule> { + let params: { domain: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain: string }; + } else { + params = { + domain: paramsOrFirst as string + }; + } + + const domain = params.domain; + + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + + const apiPath = '/proxy/rules/api'; + const payload: Payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new proxy rule for executing Appwrite Function on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} params.domain - Domain name. + * @param {string} params.functionId - ID of function to be executed. + * @param {string} params.branch - Name of VCS branch to deploy changes automatically + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + */ + createFunctionRule(params: { domain: string, functionId: string, branch?: string }): Promise<Models.ProxyRule>; + /** + * Create a new proxy rule for executing Appwrite Function on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} domain - Domain name. + * @param {string} functionId - ID of function to be executed. + * @param {string} branch - Name of VCS branch to deploy changes automatically + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFunctionRule(domain: string, functionId: string, branch?: string): Promise<Models.ProxyRule>; + createFunctionRule( + paramsOrFirst: { domain: string, functionId: string, branch?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.ProxyRule> { + let params: { domain: string, functionId: string, branch?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain: string, functionId: string, branch?: string }; + } else { + params = { + domain: paramsOrFirst as string, + functionId: rest[0] as string, + branch: rest[1] as string + }; + } + + const domain = params.domain; + const functionId = params.functionId; + const branch = params.branch; + + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + if (typeof functionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + const apiPath = '/proxy/rules/function'; + const payload: Payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof functionId !== 'undefined') { + payload['functionId'] = functionId; + } + if (typeof branch !== 'undefined') { + payload['branch'] = branch; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new proxy rule for to redirect from custom domain to another domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} params.domain - Domain name. + * @param {string} params.url - Target URL of redirection + * @param {StatusCode} params.statusCode - Status code of redirection + * @param {string} params.resourceId - ID of parent resource. + * @param {ProxyResourceType} params.resourceType - Type of parent resource. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + */ + createRedirectRule(params: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }): Promise<Models.ProxyRule>; + /** + * Create a new proxy rule for to redirect from custom domain to another domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} domain - Domain name. + * @param {string} url - Target URL of redirection + * @param {StatusCode} statusCode - Status code of redirection + * @param {string} resourceId - ID of parent resource. + * @param {ProxyResourceType} resourceType - Type of parent resource. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRedirectRule(domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType): Promise<Models.ProxyRule>; + createRedirectRule( + paramsOrFirst: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType } | string, + ...rest: [(string)?, (StatusCode)?, (string)?, (ProxyResourceType)?] + ): Promise<Models.ProxyRule> { + let params: { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain: string, url: string, statusCode: StatusCode, resourceId: string, resourceType: ProxyResourceType }; + } else { + params = { + domain: paramsOrFirst as string, + url: rest[0] as string, + statusCode: rest[1] as StatusCode, + resourceId: rest[2] as string, + resourceType: rest[3] as ProxyResourceType + }; + } + + const domain = params.domain; + const url = params.url; + const statusCode = params.statusCode; + const resourceId = params.resourceId; + const resourceType = params.resourceType; + + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + if (typeof url === 'undefined') { + throw new AppwriteException('Missing required parameter: "url"'); + } + if (typeof statusCode === 'undefined') { + throw new AppwriteException('Missing required parameter: "statusCode"'); + } + if (typeof resourceId === 'undefined') { + throw new AppwriteException('Missing required parameter: "resourceId"'); + } + if (typeof resourceType === 'undefined') { + throw new AppwriteException('Missing required parameter: "resourceType"'); + } + + const apiPath = '/proxy/rules/redirect'; + const payload: Payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + if (typeof statusCode !== 'undefined') { + payload['statusCode'] = statusCode; + } + if (typeof resourceId !== 'undefined') { + payload['resourceId'] = resourceId; + } + if (typeof resourceType !== 'undefined') { + payload['resourceType'] = resourceType; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new proxy rule for serving Appwrite Site on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} params.domain - Domain name. + * @param {string} params.siteId - ID of site to be executed. + * @param {string} params.branch - Name of VCS branch to deploy changes automatically + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + */ + createSiteRule(params: { domain: string, siteId: string, branch?: string }): Promise<Models.ProxyRule>; + /** + * Create a new proxy rule for serving Appwrite Site on custom domain. + * + * Rule ID is automatically generated as MD5 hash of a rule domain for performance purposes. + * + * @param {string} domain - Domain name. + * @param {string} siteId - ID of site to be executed. + * @param {string} branch - Name of VCS branch to deploy changes automatically + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSiteRule(domain: string, siteId: string, branch?: string): Promise<Models.ProxyRule>; + createSiteRule( + paramsOrFirst: { domain: string, siteId: string, branch?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.ProxyRule> { + let params: { domain: string, siteId: string, branch?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { domain: string, siteId: string, branch?: string }; + } else { + params = { + domain: paramsOrFirst as string, + siteId: rest[0] as string, + branch: rest[1] as string + }; + } + + const domain = params.domain; + const siteId = params.siteId; + const branch = params.branch; + + if (typeof domain === 'undefined') { + throw new AppwriteException('Missing required parameter: "domain"'); + } + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + const apiPath = '/proxy/rules/site'; + const payload: Payload = {}; + if (typeof domain !== 'undefined') { + payload['domain'] = domain; + } + if (typeof siteId !== 'undefined') { + payload['siteId'] = siteId; + } + if (typeof branch !== 'undefined') { + payload['branch'] = branch; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a proxy rule by its unique ID. + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + */ + getRule(params: { ruleId: string }): Promise<Models.ProxyRule>; + /** + * Get a proxy rule by its unique ID. + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getRule(ruleId: string): Promise<Models.ProxyRule>; + getRule( + paramsOrFirst: { ruleId: string } | string + ): Promise<Models.ProxyRule> { + let params: { ruleId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string + }; + } + + const ruleId = params.ruleId; + + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + + const apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', ruleId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a proxy rule by its unique ID. + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteRule(params: { ruleId: string }): Promise<{}>; + /** + * Delete a proxy rule by its unique ID. + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRule(ruleId: string): Promise<{}>; + deleteRule( + paramsOrFirst: { ruleId: string } | string + ): Promise<{}> { + let params: { ruleId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string + }; + } + + const ruleId = params.ruleId; + + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + + const apiPath = '/proxy/rules/{ruleId}'.replace('{ruleId}', ruleId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * If not succeeded yet, retry verification process of a proxy rule domain. This endpoint triggers domain verification by checking DNS records. If verification is successful, a TLS certificate will be automatically provisioned for the domain asynchronously in the background. + * + * @param {string} params.ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + */ + updateRuleStatus(params: { ruleId: string }): Promise<Models.ProxyRule>; + /** + * If not succeeded yet, retry verification process of a proxy rule domain. This endpoint triggers domain verification by checking DNS records. If verification is successful, a TLS certificate will be automatically provisioned for the domain asynchronously in the background. + * + * @param {string} ruleId - Rule ID. + * @throws {AppwriteException} + * @returns {Promise<Models.ProxyRule>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRuleStatus(ruleId: string): Promise<Models.ProxyRule>; + updateRuleStatus( + paramsOrFirst: { ruleId: string } | string + ): Promise<Models.ProxyRule> { + let params: { ruleId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { ruleId: string }; + } else { + params = { + ruleId: paramsOrFirst as string + }; + } + + const ruleId = params.ruleId; + + if (typeof ruleId === 'undefined') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + + const apiPath = '/proxy/rules/{ruleId}/status'.replace('{ruleId}', ruleId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } +} + +const Proxy = ProxyRuntime as unknown as { + new (client: Client<ServerAuth>): Proxy; +}; + +export { Proxy }; diff --git a/src/services/realtime.ts b/src/services/realtime.ts index 7aebdaa6..a5eb07ef 100644 --- a/src/services/realtime.ts +++ b/src/services/realtime.ts @@ -1,4 +1,4 @@ -import { AppwriteException, Client, JSONbig } from '../client'; +import { AppwriteException, Client, JSONbig, type ClientAuth } from '../client'; import { Channel, ActionableChannel, ResolvedChannel } from '../channel'; import { Query } from '../query'; import { ID } from '../id'; @@ -96,7 +96,7 @@ export class Realtime { private readonly DEBOUNCE_MS = 1; private readonly HEARTBEAT_INTERVAL = 20000; // 20 seconds in milliseconds - private client: Client; + private client: Client<ClientAuth>; private socket?: WebSocket; private activeSubscriptions = new Map<string, RealtimeCallback<any>>(); private pendingSubscribes = new Map<string, RealtimeRequestSubscribeRow>(); @@ -117,7 +117,7 @@ export class Realtime { private onCloseCallbacks: Array<() => void> = []; private onOpenCallbacks: Array<() => void> = []; - constructor(client: Client) { + constructor(client: Client<ClientAuth>) { this.client = client; } @@ -153,16 +153,26 @@ export class Realtime { private startHeartbeat(): void { this.stopHeartbeat(); - this.heartbeatTimer = window?.setInterval(() => { - if (this.socket && this.socket.readyState === WebSocket.OPEN) { - this.socket.send(JSONbig.stringify({ type: 'ping' })); - } - }, this.HEARTBEAT_INTERVAL); + this.heartbeatTimer = typeof window !== 'undefined' + ? window.setInterval(() => { + if (this.socket && this.socket.readyState === WebSocket.OPEN) { + this.socket.send(JSONbig.stringify({ type: 'ping' })); + } + }, this.HEARTBEAT_INTERVAL) + : setInterval(() => { + if (this.socket && this.socket.readyState === WebSocket.OPEN) { + this.socket.send(JSONbig.stringify({ type: 'ping' })); + } + }, this.HEARTBEAT_INTERVAL) as unknown as number; } private stopHeartbeat(): void { if (this.heartbeatTimer) { - window?.clearInterval(this.heartbeatTimer); + if (typeof window !== 'undefined') { + window.clearInterval(this.heartbeatTimer); + } else { + clearInterval(this.heartbeatTimer as any); + } this.heartbeatTimer = undefined; } } @@ -707,8 +717,10 @@ export class Realtime { let session = this.client.config.session; if (!session) { try { - const cookie = JSONbig.parse(window.localStorage.getItem('cookieFallback') ?? '{}'); - session = cookie?.[`a_session_${this.client.config.project}`]; + if (typeof window !== 'undefined' && window.localStorage) { + const cookie = JSONbig.parse(window.localStorage.getItem('cookieFallback') ?? '{}'); + session = cookie?.[`a_session_${this.client.config.project}`]; + } } catch (error) { console.error('Failed to parse cookie fallback:', error); } diff --git a/src/services/sites.ts b/src/services/sites.ts new file mode 100644 index 00000000..1c2869e3 --- /dev/null +++ b/src/services/sites.ts @@ -0,0 +1,1924 @@ +import { Service } from '../service'; +import { AppwriteException, Client, type ServerAuth, type Payload, UploadProgress } from '../client'; +import type { Models } from '../models'; + +import { Framework } from '../enums/framework'; +import { BuildRuntime } from '../enums/build-runtime'; +import { Adapter } from '../enums/adapter'; +import { TemplateReferenceType } from '../enums/template-reference-type'; +import { VCSReferenceType } from '../enums/vcs-reference-type'; +import { DeploymentDownloadType } from '../enums/deployment-download-type'; + +export type Sites = Omit<SitesRuntime, 'client'>; + +class SitesRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * Get a list of all the project's sites. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, framework, deploymentId, buildCommand, installCommand, outputDirectory, installationId + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.SiteList>} + */ + list(params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.SiteList>; + /** + * Get a list of all the project's sites. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, framework, deploymentId, buildCommand, installCommand, outputDirectory, installationId + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.SiteList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[], search?: string, total?: boolean): Promise<Models.SiteList>; + list( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise<Models.SiteList> { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/sites'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new site. + * + * @param {string} params.siteId - Site ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Site name. Max length: 128 chars. + * @param {Framework} params.framework - Sites framework. + * @param {BuildRuntime} params.buildRuntime - Runtime to use during build step. + * @param {boolean} params.enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. + * @param {boolean} params.logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * @param {number} params.timeout - Maximum request time in seconds. + * @param {string} params.installCommand - Install Command. + * @param {string} params.buildCommand - Build Command. + * @param {string} params.startCommand - Custom start command. Leave empty to use default. + * @param {string} params.outputDirectory - Output Directory for site. + * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} params.fallbackFile - Fallback file for single page application sites. + * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string} params.providerBranch - Production branch for the repo linked to the site. + * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + * @param {string} params.providerRootDirectory - Path to site code in the linked repo. + * @param {string} params.buildSpecification - Build specification for the site deployments. + * @param {string} params.runtimeSpecification - Runtime specification for the SSR executions. + * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + */ + create(params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise<Models.Site>; + /** + * Create a new site. + * + * @param {string} siteId - Site ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Site name. Max length: 128 chars. + * @param {Framework} framework - Sites framework. + * @param {BuildRuntime} buildRuntime - Runtime to use during build step. + * @param {boolean} enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. + * @param {boolean} logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * @param {number} timeout - Maximum request time in seconds. + * @param {string} installCommand - Install Command. + * @param {string} buildCommand - Build Command. + * @param {string} startCommand - Custom start command. Leave empty to use default. + * @param {string} outputDirectory - Output Directory for site. + * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} fallbackFile - Fallback file for single page application sites. + * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string} providerBranch - Production branch for the repo linked to the site. + * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + * @param {string} providerRootDirectory - Path to site code in the linked repo. + * @param {string} buildSpecification - Build specification for the site deployments. + * @param {string} runtimeSpecification - Runtime specification for the SSR executions. + * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise<Models.Site>; + create( + paramsOrFirst: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (Framework)?, (BuildRuntime)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] + ): Promise<Models.Site> { + let params: { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, buildRuntime: BuildRuntime, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, adapter?: Adapter, installationId?: string, fallbackFile?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + } else { + params = { + siteId: paramsOrFirst as string, + name: rest[0] as string, + framework: rest[1] as Framework, + buildRuntime: rest[2] as BuildRuntime, + enabled: rest[3] as boolean, + logging: rest[4] as boolean, + timeout: rest[5] as number, + installCommand: rest[6] as string, + buildCommand: rest[7] as string, + startCommand: rest[8] as string, + outputDirectory: rest[9] as string, + adapter: rest[10] as Adapter, + installationId: rest[11] as string, + fallbackFile: rest[12] as string, + providerRepositoryId: rest[13] as string, + providerBranch: rest[14] as string, + providerSilentMode: rest[15] as boolean, + providerRootDirectory: rest[16] as string, + buildSpecification: rest[17] as string, + runtimeSpecification: rest[18] as string, + deploymentRetention: rest[19] as number + }; + } + + const siteId = params.siteId; + const name = params.name; + const framework = params.framework; + const buildRuntime = params.buildRuntime; + const enabled = params.enabled; + const logging = params.logging; + const timeout = params.timeout; + const installCommand = params.installCommand; + const buildCommand = params.buildCommand; + const startCommand = params.startCommand; + const outputDirectory = params.outputDirectory; + const adapter = params.adapter; + const installationId = params.installationId; + const fallbackFile = params.fallbackFile; + const providerRepositoryId = params.providerRepositoryId; + const providerBranch = params.providerBranch; + const providerSilentMode = params.providerSilentMode; + const providerRootDirectory = params.providerRootDirectory; + const buildSpecification = params.buildSpecification; + const runtimeSpecification = params.runtimeSpecification; + const deploymentRetention = params.deploymentRetention; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof framework === 'undefined') { + throw new AppwriteException('Missing required parameter: "framework"'); + } + if (typeof buildRuntime === 'undefined') { + throw new AppwriteException('Missing required parameter: "buildRuntime"'); + } + + const apiPath = '/sites'; + const payload: Payload = {}; + if (typeof siteId !== 'undefined') { + payload['siteId'] = siteId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof framework !== 'undefined') { + payload['framework'] = framework; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof logging !== 'undefined') { + payload['logging'] = logging; + } + if (typeof timeout !== 'undefined') { + payload['timeout'] = timeout; + } + if (typeof installCommand !== 'undefined') { + payload['installCommand'] = installCommand; + } + if (typeof buildCommand !== 'undefined') { + payload['buildCommand'] = buildCommand; + } + if (typeof startCommand !== 'undefined') { + payload['startCommand'] = startCommand; + } + if (typeof outputDirectory !== 'undefined') { + payload['outputDirectory'] = outputDirectory; + } + if (typeof buildRuntime !== 'undefined') { + payload['buildRuntime'] = buildRuntime; + } + if (typeof adapter !== 'undefined') { + payload['adapter'] = adapter; + } + if (typeof installationId !== 'undefined') { + payload['installationId'] = installationId; + } + if (typeof fallbackFile !== 'undefined') { + payload['fallbackFile'] = fallbackFile; + } + if (typeof providerRepositoryId !== 'undefined') { + payload['providerRepositoryId'] = providerRepositoryId; + } + if (typeof providerBranch !== 'undefined') { + payload['providerBranch'] = providerBranch; + } + if (typeof providerSilentMode !== 'undefined') { + payload['providerSilentMode'] = providerSilentMode; + } + if (typeof providerRootDirectory !== 'undefined') { + payload['providerRootDirectory'] = providerRootDirectory; + } + if (typeof buildSpecification !== 'undefined') { + payload['buildSpecification'] = buildSpecification; + } + if (typeof runtimeSpecification !== 'undefined') { + payload['runtimeSpecification'] = runtimeSpecification; + } + if (typeof deploymentRetention !== 'undefined') { + payload['deploymentRetention'] = deploymentRetention; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all frameworks that are currently available on the server instance. + * + * @throws {AppwriteException} + * @returns {Promise<Models.FrameworkList>} + */ + listFrameworks(): Promise<Models.FrameworkList> { + + const apiPath = '/sites/frameworks'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * List allowed site specifications for this instance. + * + * @throws {AppwriteException} + * @returns {Promise<Models.SpecificationList>} + */ + listSpecifications(): Promise<Models.SpecificationList> { + + const apiPath = '/sites/specifications'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a site by its unique ID. + * + * @param {string} params.siteId - Site ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + */ + get(params: { siteId: string }): Promise<Models.Site>; + /** + * Get a site by its unique ID. + * + * @param {string} siteId - Site ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(siteId: string): Promise<Models.Site>; + get( + paramsOrFirst: { siteId: string } | string + ): Promise<Models.Site> { + let params: { siteId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string }; + } else { + params = { + siteId: paramsOrFirst as string + }; + } + + const siteId = params.siteId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + const apiPath = '/sites/{siteId}'.replace('{siteId}', siteId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update site by its unique ID. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.name - Site name. Max length: 128 chars. + * @param {Framework} params.framework - Sites framework. + * @param {boolean} params.enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. + * @param {boolean} params.logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * @param {number} params.timeout - Maximum request time in seconds. + * @param {string} params.installCommand - Install Command. + * @param {string} params.buildCommand - Build Command. + * @param {string} params.startCommand - Custom start command. Leave empty to use default. + * @param {string} params.outputDirectory - Output Directory for site. + * @param {BuildRuntime} params.buildRuntime - Runtime to use during build step. + * @param {Adapter} params.adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {string} params.fallbackFile - Fallback file for single page application sites. + * @param {string} params.installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} params.providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string} params.providerBranch - Production branch for the repo linked to the site. + * @param {boolean} params.providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + * @param {string} params.providerRootDirectory - Path to site code in the linked repo. + * @param {string} params.buildSpecification - Build specification for the site deployments. + * @param {string} params.runtimeSpecification - Runtime specification for the SSR executions. + * @param {number} params.deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + */ + update(params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }): Promise<Models.Site>; + /** + * Update site by its unique ID. + * + * @param {string} siteId - Site ID. + * @param {string} name - Site name. Max length: 128 chars. + * @param {Framework} framework - Sites framework. + * @param {boolean} enabled - Is site enabled? When set to 'disabled', users cannot access the site but Server SDKs with and API key can still access the site. No data is lost when this is toggled. + * @param {boolean} logging - When disabled, request logs will exclude logs and errors, and site responses will be slightly faster. + * @param {number} timeout - Maximum request time in seconds. + * @param {string} installCommand - Install Command. + * @param {string} buildCommand - Build Command. + * @param {string} startCommand - Custom start command. Leave empty to use default. + * @param {string} outputDirectory - Output Directory for site. + * @param {BuildRuntime} buildRuntime - Runtime to use during build step. + * @param {Adapter} adapter - Framework adapter defining rendering strategy. Allowed values are: static, ssr + * @param {string} fallbackFile - Fallback file for single page application sites. + * @param {string} installationId - Appwrite Installation ID for VCS (Version Control System) deployment. + * @param {string} providerRepositoryId - Repository ID of the repo linked to the site. + * @param {string} providerBranch - Production branch for the repo linked to the site. + * @param {boolean} providerSilentMode - Is the VCS (Version Control System) connection in silent mode for the repo linked to the site? In silent mode, comments will not be made on commits and pull requests. + * @param {string} providerRootDirectory - Path to site code in the linked repo. + * @param {string} buildSpecification - Build specification for the site deployments. + * @param {string} runtimeSpecification - Runtime specification for the SSR executions. + * @param {number} deploymentRetention - Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number): Promise<Models.Site>; + update( + paramsOrFirst: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number } | string, + ...rest: [(string)?, (Framework)?, (boolean)?, (boolean)?, (number)?, (string)?, (string)?, (string)?, (string)?, (BuildRuntime)?, (Adapter)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (string)?, (string)?, (string)?, (number)?] + ): Promise<Models.Site> { + let params: { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, name: string, framework: Framework, enabled?: boolean, logging?: boolean, timeout?: number, installCommand?: string, buildCommand?: string, startCommand?: string, outputDirectory?: string, buildRuntime?: BuildRuntime, adapter?: Adapter, fallbackFile?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, buildSpecification?: string, runtimeSpecification?: string, deploymentRetention?: number }; + } else { + params = { + siteId: paramsOrFirst as string, + name: rest[0] as string, + framework: rest[1] as Framework, + enabled: rest[2] as boolean, + logging: rest[3] as boolean, + timeout: rest[4] as number, + installCommand: rest[5] as string, + buildCommand: rest[6] as string, + startCommand: rest[7] as string, + outputDirectory: rest[8] as string, + buildRuntime: rest[9] as BuildRuntime, + adapter: rest[10] as Adapter, + fallbackFile: rest[11] as string, + installationId: rest[12] as string, + providerRepositoryId: rest[13] as string, + providerBranch: rest[14] as string, + providerSilentMode: rest[15] as boolean, + providerRootDirectory: rest[16] as string, + buildSpecification: rest[17] as string, + runtimeSpecification: rest[18] as string, + deploymentRetention: rest[19] as number + }; + } + + const siteId = params.siteId; + const name = params.name; + const framework = params.framework; + const enabled = params.enabled; + const logging = params.logging; + const timeout = params.timeout; + const installCommand = params.installCommand; + const buildCommand = params.buildCommand; + const startCommand = params.startCommand; + const outputDirectory = params.outputDirectory; + const buildRuntime = params.buildRuntime; + const adapter = params.adapter; + const fallbackFile = params.fallbackFile; + const installationId = params.installationId; + const providerRepositoryId = params.providerRepositoryId; + const providerBranch = params.providerBranch; + const providerSilentMode = params.providerSilentMode; + const providerRootDirectory = params.providerRootDirectory; + const buildSpecification = params.buildSpecification; + const runtimeSpecification = params.runtimeSpecification; + const deploymentRetention = params.deploymentRetention; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof framework === 'undefined') { + throw new AppwriteException('Missing required parameter: "framework"'); + } + + const apiPath = '/sites/{siteId}'.replace('{siteId}', siteId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof framework !== 'undefined') { + payload['framework'] = framework; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof logging !== 'undefined') { + payload['logging'] = logging; + } + if (typeof timeout !== 'undefined') { + payload['timeout'] = timeout; + } + if (typeof installCommand !== 'undefined') { + payload['installCommand'] = installCommand; + } + if (typeof buildCommand !== 'undefined') { + payload['buildCommand'] = buildCommand; + } + if (typeof startCommand !== 'undefined') { + payload['startCommand'] = startCommand; + } + if (typeof outputDirectory !== 'undefined') { + payload['outputDirectory'] = outputDirectory; + } + if (typeof buildRuntime !== 'undefined') { + payload['buildRuntime'] = buildRuntime; + } + if (typeof adapter !== 'undefined') { + payload['adapter'] = adapter; + } + if (typeof fallbackFile !== 'undefined') { + payload['fallbackFile'] = fallbackFile; + } + if (typeof installationId !== 'undefined') { + payload['installationId'] = installationId; + } + if (typeof providerRepositoryId !== 'undefined') { + payload['providerRepositoryId'] = providerRepositoryId; + } + if (typeof providerBranch !== 'undefined') { + payload['providerBranch'] = providerBranch; + } + if (typeof providerSilentMode !== 'undefined') { + payload['providerSilentMode'] = providerSilentMode; + } + if (typeof providerRootDirectory !== 'undefined') { + payload['providerRootDirectory'] = providerRootDirectory; + } + if (typeof buildSpecification !== 'undefined') { + payload['buildSpecification'] = buildSpecification; + } + if (typeof runtimeSpecification !== 'undefined') { + payload['runtimeSpecification'] = runtimeSpecification; + } + if (typeof deploymentRetention !== 'undefined') { + payload['deploymentRetention'] = deploymentRetention; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a site by its unique ID. + * + * @param {string} params.siteId - Site ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { siteId: string }): Promise<{}>; + /** + * Delete a site by its unique ID. + * + * @param {string} siteId - Site ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(siteId: string): Promise<{}>; + delete( + paramsOrFirst: { siteId: string } | string + ): Promise<{}> { + let params: { siteId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string }; + } else { + params = { + siteId: paramsOrFirst as string + }; + } + + const siteId = params.siteId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + const apiPath = '/sites/{siteId}'.replace('{siteId}', siteId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + */ + updateSiteDeployment(params: { siteId: string, deploymentId: string }): Promise<Models.Site>; + /** + * Update the site active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your site. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Site>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSiteDeployment(siteId: string, deploymentId: string): Promise<Models.Site>; + updateSiteDeployment( + paramsOrFirst: { siteId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Site> { + let params: { siteId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/sites/{siteId}/deployment'.replace('{siteId}', siteId); + const payload: Payload = {}; + if (typeof deploymentId !== 'undefined') { + payload['deploymentId'] = deploymentId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all the site's code deployments. You can use the query params to filter your results. + * + * @param {string} params.siteId - Site ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.DeploymentList>} + */ + listDeployments(params: { siteId: string, queries?: string[], search?: string, total?: boolean }): Promise<Models.DeploymentList>; + /** + * Get a list of all the site's code deployments. You can use the query params to filter your results. + * + * @param {string} siteId - Site ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.DeploymentList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listDeployments(siteId: string, queries?: string[], search?: string, total?: boolean): Promise<Models.DeploymentList>; + listDeployments( + paramsOrFirst: { siteId: string, queries?: string[], search?: string, total?: boolean } | string, + ...rest: [(string[])?, (string)?, (boolean)?] + ): Promise<Models.DeploymentList> { + let params: { siteId: string, queries?: string[], search?: string, total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], search?: string, total?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string, + total: rest[2] as boolean + }; + } + + const siteId = params.siteId; + const queries = params.queries; + const search = params.search; + const total = params.total; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + const apiPath = '/sites/{siteId}/deployments'.replace('{siteId}', siteId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID. + * + * @param {string} params.siteId - Site ID. + * @param {File} params.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. + * @param {string} params.installCommand - Install Commands. + * @param {string} params.buildCommand - Build Commands. + * @param {string} params.outputDirectory - Output Directory. + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createDeployment(params: { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void }): Promise<Models.Deployment>; + /** + * Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID. + * + * @param {string} siteId - Site ID. + * @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. + * @param {string} installCommand - Install Commands. + * @param {string} buildCommand - Build Commands. + * @param {string} outputDirectory - Output Directory. + * @param {boolean} activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDeployment(siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void): Promise<Models.Deployment>; + createDeployment( + paramsOrFirst: { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean, onProgress?: (progress: UploadProgress) => void } | string, + ...rest: [(File)?, (string)?, (string)?, (string)?, (boolean)?,((progress: UploadProgress) => void)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean }; + let onProgress: ((progress: UploadProgress) => void); + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, code: File, installCommand?: string, buildCommand?: string, outputDirectory?: string, activate?: boolean }; + onProgress = paramsOrFirst?.onProgress as ((progress: UploadProgress) => void); + } else { + params = { + siteId: paramsOrFirst as string, + code: rest[0] as File, + installCommand: rest[1] as string, + buildCommand: rest[2] as string, + outputDirectory: rest[3] as string, + activate: rest[4] as boolean + }; + onProgress = rest[5] as ((progress: UploadProgress) => void); + } + + const siteId = params.siteId; + const code = params.code; + const installCommand = params.installCommand; + const buildCommand = params.buildCommand; + const outputDirectory = params.outputDirectory; + const activate = params.activate; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof code === 'undefined') { + throw new AppwriteException('Missing required parameter: "code"'); + } + + const apiPath = '/sites/{siteId}/deployments'.replace('{siteId}', siteId); + const payload: Payload = {}; + if (typeof installCommand !== 'undefined') { + payload['installCommand'] = installCommand; + } + if (typeof buildCommand !== 'undefined') { + payload['buildCommand'] = buildCommand; + } + if (typeof outputDirectory !== 'undefined') { + payload['outputDirectory'] = outputDirectory; + } + if (typeof code !== 'undefined') { + payload['code'] = code; + } + if (typeof activate !== 'undefined') { + payload['activate'] = activate; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'multipart/form-data', + } + + return this.client.chunkedUpload( + 'post', + uri, + apiHeaders, + payload, + onProgress + ); + } + + /** + * Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createDuplicateDeployment(params: { siteId: string, deploymentId: string }): Promise<Models.Deployment>; + /** + * Create a new build for an existing site deployment. This endpoint allows you to rebuild a deployment with the updated site configuration, including its commands and output directory if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDuplicateDeployment(siteId: string, deploymentId: string): Promise<Models.Deployment>; + createDuplicateDeployment( + paramsOrFirst: { siteId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/sites/{siteId}/deployments/duplicate'.replace('{siteId}', siteId); + const payload: Payload = {}; + if (typeof deploymentId !== 'undefined') { + payload['deploymentId'] = deploymentId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a deployment based on a template. + * + * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.repository - Repository name of the template. + * @param {string} params.owner - The name of the owner of the template. + * @param {string} params.rootDirectory - Path to site code in the template repo. + * @param {TemplateReferenceType} params.type - Type for the reference provided. Can be commit, branch, or tag + * @param {string} params.reference - Reference value, can be a commit hash, branch name, or release tag + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createTemplateDeployment(params: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }): Promise<Models.Deployment>; + /** + * Create a deployment based on a template. + * + * Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/products/sites/templates) to find the template details. + * + * @param {string} siteId - Site ID. + * @param {string} repository - Repository name of the template. + * @param {string} owner - The name of the owner of the template. + * @param {string} rootDirectory - Path to site code in the template repo. + * @param {TemplateReferenceType} type - Type for the reference provided. Can be commit, branch, or tag + * @param {string} reference - Reference value, can be a commit hash, branch name, or release tag + * @param {boolean} activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTemplateDeployment(siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean): Promise<Models.Deployment>; + createTemplateDeployment( + paramsOrFirst: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (TemplateReferenceType)?, (string)?, (boolean)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, repository: string, owner: string, rootDirectory: string, type: TemplateReferenceType, reference: string, activate?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + repository: rest[0] as string, + owner: rest[1] as string, + rootDirectory: rest[2] as string, + type: rest[3] as TemplateReferenceType, + reference: rest[4] as string, + activate: rest[5] as boolean + }; + } + + const siteId = params.siteId; + const repository = params.repository; + const owner = params.owner; + const rootDirectory = params.rootDirectory; + const type = params.type; + const reference = params.reference; + const activate = params.activate; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof repository === 'undefined') { + throw new AppwriteException('Missing required parameter: "repository"'); + } + if (typeof owner === 'undefined') { + throw new AppwriteException('Missing required parameter: "owner"'); + } + if (typeof rootDirectory === 'undefined') { + throw new AppwriteException('Missing required parameter: "rootDirectory"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof reference === 'undefined') { + throw new AppwriteException('Missing required parameter: "reference"'); + } + + const apiPath = '/sites/{siteId}/deployments/template'.replace('{siteId}', siteId); + const payload: Payload = {}; + if (typeof repository !== 'undefined') { + payload['repository'] = repository; + } + if (typeof owner !== 'undefined') { + payload['owner'] = owner; + } + if (typeof rootDirectory !== 'undefined') { + payload['rootDirectory'] = rootDirectory; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof reference !== 'undefined') { + payload['reference'] = reference; + } + if (typeof activate !== 'undefined') { + payload['activate'] = activate; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a deployment when a site is connected to VCS. + * + * This endpoint lets you create deployment from a branch, commit, or a tag. + * + * @param {string} params.siteId - Site ID. + * @param {VCSReferenceType} params.type - Type of reference passed. Allowed values are: branch, commit + * @param {string} params.reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + * @param {boolean} params.activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + createVcsDeployment(params: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }): Promise<Models.Deployment>; + /** + * Create a deployment when a site is connected to VCS. + * + * This endpoint lets you create deployment from a branch, commit, or a tag. + * + * @param {string} siteId - Site ID. + * @param {VCSReferenceType} type - Type of reference passed. Allowed values are: branch, commit + * @param {string} reference - VCS reference to create deployment from. Depending on type this can be: branch name, commit hash + * @param {boolean} activate - Automatically activate the deployment when it is finished building. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVcsDeployment(siteId: string, type: VCSReferenceType, reference: string, activate?: boolean): Promise<Models.Deployment>; + createVcsDeployment( + paramsOrFirst: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean } | string, + ...rest: [(VCSReferenceType)?, (string)?, (boolean)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, type: VCSReferenceType, reference: string, activate?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + type: rest[0] as VCSReferenceType, + reference: rest[1] as string, + activate: rest[2] as boolean + }; + } + + const siteId = params.siteId; + const type = params.type; + const reference = params.reference; + const activate = params.activate; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof reference === 'undefined') { + throw new AppwriteException('Missing required parameter: "reference"'); + } + + const apiPath = '/sites/{siteId}/deployments/vcs'.replace('{siteId}', siteId); + const payload: Payload = {}; + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof reference !== 'undefined') { + payload['reference'] = reference; + } + if (typeof activate !== 'undefined') { + payload['activate'] = activate; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a site deployment by its unique ID. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + getDeployment(params: { siteId: string, deploymentId: string }): Promise<Models.Deployment>; + /** + * Get a site deployment by its unique ID. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDeployment(siteId: string, deploymentId: string): Promise<Models.Deployment>; + getDeployment( + paramsOrFirst: { siteId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/sites/{siteId}/deployments/{deploymentId}'.replace('{siteId}', siteId).replace('{deploymentId}', deploymentId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a site deployment by its unique ID. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteDeployment(params: { siteId: string, deploymentId: string }): Promise<{}>; + /** + * Delete a site deployment by its unique ID. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteDeployment(siteId: string, deploymentId: string): Promise<{}>; + deleteDeployment( + paramsOrFirst: { siteId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { siteId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/sites/{siteId}/deployments/{deploymentId}'.replace('{siteId}', siteId).replace('{deploymentId}', deploymentId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a site deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. + * @param {DeploymentDownloadType} params.type - Deployment file to download. Can be: "source", "output". + * @throws {AppwriteException} + * @returns {string} + */ + getDeploymentDownload(params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType }): string; + /** + * Get a site deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. + * @param {DeploymentDownloadType} type - Deployment file to download. Can be: "source", "output". + * @throws {AppwriteException} + * @returns {string} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getDeploymentDownload(siteId: string, deploymentId: string, type?: DeploymentDownloadType): string; + getDeploymentDownload( + paramsOrFirst: { siteId: string, deploymentId: string, type?: DeploymentDownloadType } | string, + ...rest: [(string)?, (DeploymentDownloadType)?] + ): string { + let params: { siteId: string, deploymentId: string, type?: DeploymentDownloadType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string, type?: DeploymentDownloadType }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string, + type: rest[1] as DeploymentDownloadType + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + const type = params.type; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/sites/{siteId}/deployments/{deploymentId}/download'.replace('{siteId}', siteId).replace('{deploymentId}', deploymentId); + const payload: Payload = {}; + if (typeof type !== 'undefined') { + payload['type'] = type; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; + + for (const [key, value] of Object.entries(Service.flatten(payload))) { + uri.searchParams.append(key, value); + } + + return uri.toString(); + } + + /** + * Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + */ + updateDeploymentStatus(params: { siteId: string, deploymentId: string }): Promise<Models.Deployment>; + /** + * Cancel an ongoing site deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details. + * + * @param {string} siteId - Site ID. + * @param {string} deploymentId - Deployment ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Deployment>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDeploymentStatus(siteId: string, deploymentId: string): Promise<Models.Deployment>; + updateDeploymentStatus( + paramsOrFirst: { siteId: string, deploymentId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Deployment> { + let params: { siteId: string, deploymentId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, deploymentId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + deploymentId: rest[0] as string + }; + } + + const siteId = params.siteId; + const deploymentId = params.deploymentId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof deploymentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + + const apiPath = '/sites/{siteId}/deployments/{deploymentId}/status'.replace('{siteId}', siteId).replace('{deploymentId}', deploymentId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all site logs. You can use the query params to filter your results. + * + * @param {string} params.siteId - Site ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ExecutionList>} + */ + listLogs(params: { siteId: string, queries?: string[], total?: boolean }): Promise<Models.ExecutionList>; + /** + * Get a list of all site logs. You can use the query params to filter your results. + * + * @param {string} siteId - Site ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ExecutionList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listLogs(siteId: string, queries?: string[], total?: boolean): Promise<Models.ExecutionList>; + listLogs( + paramsOrFirst: { siteId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.ExecutionList> { + let params: { siteId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], total?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const siteId = params.siteId; + const queries = params.queries; + const total = params.total; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + const apiPath = '/sites/{siteId}/logs'.replace('{siteId}', siteId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a site request log by its unique ID. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.logId - Log ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Execution>} + */ + getLog(params: { siteId: string, logId: string }): Promise<Models.Execution>; + /** + * Get a site request log by its unique ID. + * + * @param {string} siteId - Site ID. + * @param {string} logId - Log ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Execution>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getLog(siteId: string, logId: string): Promise<Models.Execution>; + getLog( + paramsOrFirst: { siteId: string, logId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Execution> { + let params: { siteId: string, logId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, logId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + logId: rest[0] as string + }; + } + + const siteId = params.siteId; + const logId = params.logId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof logId === 'undefined') { + throw new AppwriteException('Missing required parameter: "logId"'); + } + + const apiPath = '/sites/{siteId}/logs/{logId}'.replace('{siteId}', siteId).replace('{logId}', logId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a site log by its unique ID. + * + * @param {string} params.siteId - Site ID. + * @param {string} params.logId - Log ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteLog(params: { siteId: string, logId: string }): Promise<{}>; + /** + * Delete a site log by its unique ID. + * + * @param {string} siteId - Site ID. + * @param {string} logId - Log ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteLog(siteId: string, logId: string): Promise<{}>; + deleteLog( + paramsOrFirst: { siteId: string, logId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { siteId: string, logId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, logId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + logId: rest[0] as string + }; + } + + const siteId = params.siteId; + const logId = params.logId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof logId === 'undefined') { + throw new AppwriteException('Missing required parameter: "logId"'); + } + + const apiPath = '/sites/{siteId}/logs/{logId}'.replace('{siteId}', siteId).replace('{logId}', logId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all variables of a specific site. + * + * @param {string} params.siteId - Site unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.VariableList>} + */ + listVariables(params: { siteId: string, queries?: string[], total?: boolean }): Promise<Models.VariableList>; + /** + * Get a list of all variables of a specific site. + * + * @param {string} siteId - Site unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.VariableList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listVariables(siteId: string, queries?: string[], total?: boolean): Promise<Models.VariableList>; + listVariables( + paramsOrFirst: { siteId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.VariableList> { + let params: { siteId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, queries?: string[], total?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const siteId = params.siteId; + const queries = params.queries; + const total = params.total; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + const apiPath = '/sites/{siteId}/variables'.replace('{siteId}', siteId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. + * + * @param {string} params.siteId - Site unique ID. + * @param {string} params.variableId - Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + */ + createVariable(params: { siteId: string, variableId: string, key: string, value: string, secret?: boolean }): Promise<Models.Variable>; + /** + * Create a new site variable. These variables can be accessed during build and runtime (server-side rendering) as environment variables. + * + * @param {string} siteId - Site unique ID. + * @param {string} variableId - Variable ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVariable(siteId: string, variableId: string, key: string, value: string, secret?: boolean): Promise<Models.Variable>; + createVariable( + paramsOrFirst: { siteId: string, variableId: string, key: string, value: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Variable> { + let params: { siteId: string, variableId: string, key: string, value: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, variableId: string, key: string, value: string, secret?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + variableId: rest[0] as string, + key: rest[1] as string, + value: rest[2] as string, + secret: rest[3] as boolean + }; + } + + const siteId = params.siteId; + const variableId = params.variableId; + const key = params.key; + const value = params.value; + const secret = params.secret; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof value === 'undefined') { + throw new AppwriteException('Missing required parameter: "value"'); + } + + const apiPath = '/sites/{siteId}/variables'.replace('{siteId}', siteId); + const payload: Payload = {}; + if (typeof variableId !== 'undefined') { + payload['variableId'] = variableId; + } + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a variable by its unique ID. + * + * @param {string} params.siteId - Site unique ID. + * @param {string} params.variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + */ + getVariable(params: { siteId: string, variableId: string }): Promise<Models.Variable>; + /** + * Get a variable by its unique ID. + * + * @param {string} siteId - Site unique ID. + * @param {string} variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getVariable(siteId: string, variableId: string): Promise<Models.Variable>; + getVariable( + paramsOrFirst: { siteId: string, variableId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Variable> { + let params: { siteId: string, variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, variableId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + variableId: rest[0] as string + }; + } + + const siteId = params.siteId; + const variableId = params.variableId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', siteId).replace('{variableId}', variableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update variable by its unique ID. + * + * @param {string} params.siteId - Site unique ID. + * @param {string} params.variableId - Variable unique ID. + * @param {string} params.key - Variable key. Max length: 255 chars. + * @param {string} params.value - Variable value. Max length: 8192 chars. + * @param {boolean} params.secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + */ + updateVariable(params: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }): Promise<Models.Variable>; + /** + * Update variable by its unique ID. + * + * @param {string} siteId - Site unique ID. + * @param {string} variableId - Variable unique ID. + * @param {string} key - Variable key. Max length: 255 chars. + * @param {string} value - Variable value. Max length: 8192 chars. + * @param {boolean} secret - Secret variables can be updated or deleted, but only sites can read them during build and runtime. + * @throws {AppwriteException} + * @returns {Promise<Models.Variable>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateVariable(siteId: string, variableId: string, key?: string, value?: string, secret?: boolean): Promise<Models.Variable>; + updateVariable( + paramsOrFirst: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Variable> { + let params: { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, variableId: string, key?: string, value?: string, secret?: boolean }; + } else { + params = { + siteId: paramsOrFirst as string, + variableId: rest[0] as string, + key: rest[1] as string, + value: rest[2] as string, + secret: rest[3] as boolean + }; + } + + const siteId = params.siteId; + const variableId = params.variableId; + const key = params.key; + const value = params.value; + const secret = params.secret; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', siteId).replace('{variableId}', variableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof value !== 'undefined') { + payload['value'] = value; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a variable by its unique ID. + * + * @param {string} params.siteId - Site unique ID. + * @param {string} params.variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteVariable(params: { siteId: string, variableId: string }): Promise<{}>; + /** + * Delete a variable by its unique ID. + * + * @param {string} siteId - Site unique ID. + * @param {string} variableId - Variable unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteVariable(siteId: string, variableId: string): Promise<{}>; + deleteVariable( + paramsOrFirst: { siteId: string, variableId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { siteId: string, variableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { siteId: string, variableId: string }; + } else { + params = { + siteId: paramsOrFirst as string, + variableId: rest[0] as string + }; + } + + const siteId = params.siteId; + const variableId = params.variableId; + + if (typeof siteId === 'undefined') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + if (typeof variableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + + const apiPath = '/sites/{siteId}/variables/{variableId}'.replace('{siteId}', siteId).replace('{variableId}', variableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } +} + +const Sites = SitesRuntime as unknown as { + new (client: Client<ServerAuth>): Sites; +}; + +export { Sites }; diff --git a/src/services/storage.ts b/src/services/storage.ts index 814b14b7..fe671549 100644 --- a/src/services/storage.ts +++ b/src/services/storage.ts @@ -1,17 +1,452 @@ import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload, UploadProgress } from '../client'; import type { Models } from '../models'; +import { Compression } from '../enums/compression'; import { ImageGravity } from '../enums/image-gravity'; import { ImageFormat } from '../enums/image-format'; -export class Storage { - client: Client; +type StorageServerOnlyMethod = 'listBuckets' | 'createBucket' | 'getBucket' | 'updateBucket' | 'deleteBucket'; +type StorageClientOnlyMethod = never; - constructor(client: Client) { +export type Storage<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<StorageRuntime<TAuth>, 'client' | StorageServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<StorageRuntime<TAuth>, 'client' | StorageClientOnlyMethod> + : Omit<StorageRuntime<TAuth>, 'client'>; + +class StorageRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } + /** + * Get a list of all the storage buckets. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus, transformations + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.BucketList>} + */ + listBuckets(this: Storage<ServerAuth>, params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.BucketList>; + /** + * Get a list of all the storage buckets. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus, transformations + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.BucketList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listBuckets(this: Storage<ServerAuth>, queries?: string[], search?: string, total?: boolean): Promise<Models.BucketList>; + listBuckets( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise<Models.BucketList> { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/storage/buckets'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new storage bucket. + * + * @param {string} params.bucketId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Bucket name + * @param {string[]} params.permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. + * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. + * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + * @param {boolean} params.transformations - Are image transformations enabled? + * @throws {AppwriteException} + * @returns {Promise<Models.Bucket>} + */ + createBucket(this: Storage<ServerAuth>, params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }): Promise<Models.Bucket>; + /** + * Create a new storage bucket. + * + * @param {string} bucketId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Bucket name + * @param {string[]} permissions - An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. + * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. + * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + * @param {boolean} transformations - Are image transformations enabled? + * @throws {AppwriteException} + * @returns {Promise<Models.Bucket>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBucket(this: Storage<ServerAuth>, bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean): Promise<Models.Bucket>; + createBucket( + paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?, (boolean)?] + ): Promise<Models.Bucket> { + let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; + } else { + params = { + bucketId: paramsOrFirst as string, + name: rest[0] as string, + permissions: rest[1] as string[], + fileSecurity: rest[2] as boolean, + enabled: rest[3] as boolean, + maximumFileSize: rest[4] as number, + allowedFileExtensions: rest[5] as string[], + compression: rest[6] as Compression, + encryption: rest[7] as boolean, + antivirus: rest[8] as boolean, + transformations: rest[9] as boolean + }; + } + + const bucketId = params.bucketId; + const name = params.name; + const permissions = params.permissions; + const fileSecurity = params.fileSecurity; + const enabled = params.enabled; + const maximumFileSize = params.maximumFileSize; + const allowedFileExtensions = params.allowedFileExtensions; + const compression = params.compression; + const encryption = params.encryption; + const antivirus = params.antivirus; + const transformations = params.transformations; + + if (typeof bucketId === 'undefined') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/storage/buckets'; + const payload: Payload = {}; + if (typeof bucketId !== 'undefined') { + payload['bucketId'] = bucketId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof fileSecurity !== 'undefined') { + payload['fileSecurity'] = fileSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof maximumFileSize !== 'undefined') { + payload['maximumFileSize'] = maximumFileSize; + } + if (typeof allowedFileExtensions !== 'undefined') { + payload['allowedFileExtensions'] = allowedFileExtensions; + } + if (typeof compression !== 'undefined') { + payload['compression'] = compression; + } + if (typeof encryption !== 'undefined') { + payload['encryption'] = encryption; + } + if (typeof antivirus !== 'undefined') { + payload['antivirus'] = antivirus; + } + if (typeof transformations !== 'undefined') { + payload['transformations'] = transformations; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata. + * + * @param {string} params.bucketId - Bucket unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Bucket>} + */ + getBucket(this: Storage<ServerAuth>, params: { bucketId: string }): Promise<Models.Bucket>; + /** + * Get a storage bucket by its unique ID. This endpoint response returns a JSON object with the storage bucket metadata. + * + * @param {string} bucketId - Bucket unique ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Bucket>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getBucket(this: Storage<ServerAuth>, bucketId: string): Promise<Models.Bucket>; + getBucket( + paramsOrFirst: { bucketId: string } | string + ): Promise<Models.Bucket> { + let params: { bucketId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string }; + } else { + params = { + bucketId: paramsOrFirst as string + }; + } + + const bucketId = params.bucketId; + + if (typeof bucketId === 'undefined') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a storage bucket by its unique ID. + * + * @param {string} params.bucketId - Bucket unique ID. + * @param {string} params.name - Bucket name + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. + * @param {number} params.maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {string[]} params.allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. + * @param {Compression} params.compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean} params.encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {boolean} params.antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + * @param {boolean} params.transformations - Are image transformations enabled? + * @throws {AppwriteException} + * @returns {Promise<Models.Bucket>} + */ + updateBucket(this: Storage<ServerAuth>, params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }): Promise<Models.Bucket>; + /** + * Update a storage bucket by its unique ID. + * + * @param {string} bucketId - Bucket unique ID. + * @param {string} name - Bucket name + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} fileSecurity - Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. + * @param {number} maximumFileSize - Maximum file size allowed in bytes. Maximum allowed value is 5GB. + * @param {string[]} allowedFileExtensions - Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. + * @param {Compression} compression - Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + * @param {boolean} encryption - Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled + * @param {boolean} antivirus - Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled + * @param {boolean} transformations - Are image transformations enabled? + * @throws {AppwriteException} + * @returns {Promise<Models.Bucket>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBucket(this: Storage<ServerAuth>, bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean): Promise<Models.Bucket>; + updateBucket( + paramsOrFirst: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?, (boolean)?, (number)?, (string[])?, (Compression)?, (boolean)?, (boolean)?, (boolean)?] + ): Promise<Models.Bucket> { + let params: { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, name: string, permissions?: string[], fileSecurity?: boolean, enabled?: boolean, maximumFileSize?: number, allowedFileExtensions?: string[], compression?: Compression, encryption?: boolean, antivirus?: boolean, transformations?: boolean }; + } else { + params = { + bucketId: paramsOrFirst as string, + name: rest[0] as string, + permissions: rest[1] as string[], + fileSecurity: rest[2] as boolean, + enabled: rest[3] as boolean, + maximumFileSize: rest[4] as number, + allowedFileExtensions: rest[5] as string[], + compression: rest[6] as Compression, + encryption: rest[7] as boolean, + antivirus: rest[8] as boolean, + transformations: rest[9] as boolean + }; + } + + const bucketId = params.bucketId; + const name = params.name; + const permissions = params.permissions; + const fileSecurity = params.fileSecurity; + const enabled = params.enabled; + const maximumFileSize = params.maximumFileSize; + const allowedFileExtensions = params.allowedFileExtensions; + const compression = params.compression; + const encryption = params.encryption; + const antivirus = params.antivirus; + const transformations = params.transformations; + + if (typeof bucketId === 'undefined') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof fileSecurity !== 'undefined') { + payload['fileSecurity'] = fileSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof maximumFileSize !== 'undefined') { + payload['maximumFileSize'] = maximumFileSize; + } + if (typeof allowedFileExtensions !== 'undefined') { + payload['allowedFileExtensions'] = allowedFileExtensions; + } + if (typeof compression !== 'undefined') { + payload['compression'] = compression; + } + if (typeof encryption !== 'undefined') { + payload['encryption'] = encryption; + } + if (typeof antivirus !== 'undefined') { + payload['antivirus'] = antivirus; + } + if (typeof transformations !== 'undefined') { + payload['transformations'] = transformations; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a storage bucket by its unique ID. + * + * @param {string} params.bucketId - Bucket unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteBucket(this: Storage<ServerAuth>, params: { bucketId: string }): Promise<{}>; + /** + * Delete a storage bucket by its unique ID. + * + * @param {string} bucketId - Bucket unique ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteBucket(this: Storage<ServerAuth>, bucketId: string): Promise<{}>; + deleteBucket( + paramsOrFirst: { bucketId: string } | string + ): Promise<{}> { + let params: { bucketId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string }; + } else { + params = { + bucketId: paramsOrFirst as string + }; + } + + const bucketId = params.bucketId; + + if (typeof bucketId === 'undefined') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + const apiPath = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + /** * Get a list of all the user files. You can use the query params to filter your results. * @@ -434,7 +869,7 @@ export class Storage { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -578,7 +1013,7 @@ export class Storage { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -645,7 +1080,7 @@ export class Storage { const apiHeaders: { [header: string]: string } = { } - payload['project'] = this.client.config.project; + payload['project'] = (this.client.config as unknown as Record<string, string>)['project']; for (const [key, value] of Object.entries(Service.flatten(payload))) { uri.searchParams.append(key, value); @@ -654,3 +1089,9 @@ export class Storage { return uri.toString(); } } + +const Storage = StorageRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): Storage<TAuth>; +}; + +export { Storage }; diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index fa671f14..2aa9c974 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -1,15 +1,169 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload } from '../client'; import type { Models } from '../models'; +import { RelationshipType } from '../enums/relationship-type'; +import { RelationMutate } from '../enums/relation-mutate'; +import { TablesDBIndexType } from '../enums/tables-db-index-type'; +import { OrderBy } from '../enums/order-by'; -export class TablesDB { - client: Client; +type TablesDBServerOnlyMethod = 'list' | 'create' | 'get' | 'update' | 'delete' | 'listTables' | 'createTable' | 'getTable' | 'updateTable' | 'deleteTable' | 'listColumns' | 'createBigIntColumn' | 'updateBigIntColumn' | 'createBooleanColumn' | 'updateBooleanColumn' | 'createDatetimeColumn' | 'updateDatetimeColumn' | 'createEmailColumn' | 'updateEmailColumn' | 'createEnumColumn' | 'updateEnumColumn' | 'createFloatColumn' | 'updateFloatColumn' | 'createIntegerColumn' | 'updateIntegerColumn' | 'createIpColumn' | 'updateIpColumn' | 'createLineColumn' | 'updateLineColumn' | 'createLongtextColumn' | 'updateLongtextColumn' | 'createMediumtextColumn' | 'updateMediumtextColumn' | 'createPointColumn' | 'updatePointColumn' | 'createPolygonColumn' | 'updatePolygonColumn' | 'createRelationshipColumn' | 'createStringColumn' | 'updateStringColumn' | 'createTextColumn' | 'updateTextColumn' | 'createUrlColumn' | 'updateUrlColumn' | 'createVarcharColumn' | 'updateVarcharColumn' | 'getColumn' | 'deleteColumn' | 'updateRelationshipColumn' | 'listIndexes' | 'createIndex' | 'getIndex' | 'deleteIndex' | 'upsertRows' | 'updateRows' | 'deleteRows'; +type TablesDBClientOnlyMethod = never; - constructor(client: Client) { +export type TablesDB<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<TablesDBRuntime<TAuth>, 'client' | TablesDBServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<TablesDBRuntime<TAuth>, 'client' | TablesDBClientOnlyMethod> + : Omit<TablesDBRuntime<TAuth>, 'client'>; + +class TablesDBRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.DatabaseList>} + */ + list(this: TablesDB<ServerAuth>, params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.DatabaseList>; + /** + * Get a list of all databases from the current Appwrite project. You can use the search parameter to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.DatabaseList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(this: TablesDB<ServerAuth>, queries?: string[], search?: string, total?: boolean): Promise<Models.DatabaseList>; + list( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise<Models.DatabaseList> { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/tablesdb'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Database. + * + * + * @param {string} params.databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + */ + create(this: TablesDB<ServerAuth>, params: { databaseId: string, name: string, enabled?: boolean }): Promise<Models.Database>; + /** + * Create a new Database. + * + * + * @param {string} databaseId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(this: TablesDB<ServerAuth>, databaseId: string, name: string, enabled?: boolean): Promise<Models.Database>; + create( + paramsOrFirst: { databaseId: string, name: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.Database> { + let params: { databaseId: string, name: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/tablesdb'; + const payload: Payload = {}; + if (typeof databaseId !== 'undefined') { + payload['databaseId'] = databaseId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + /** * List transactions across all databases. * @@ -260,23 +414,4681 @@ export class TablesDB { transactionId: paramsOrFirst as string }; } - - const transactionId = params.transactionId; - - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + + const transactionId = params.transactionId; + + if (typeof transactionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + + const apiPath = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Create multiple operations in a single transaction. + * + * @param {string} params.transactionId - Transaction ID. + * @param {object[]} params.operations - Array of staged operations. + * @throws {AppwriteException} + * @returns {Promise<Models.Transaction>} + */ + createOperations(params: { transactionId: string, operations?: object[] }): Promise<Models.Transaction>; + /** + * Create multiple operations in a single transaction. + * + * @param {string} transactionId - Transaction ID. + * @param {object[]} operations - Array of staged operations. + * @throws {AppwriteException} + * @returns {Promise<Models.Transaction>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createOperations(transactionId: string, operations?: object[]): Promise<Models.Transaction>; + createOperations( + paramsOrFirst: { transactionId: string, operations?: object[] } | string, + ...rest: [(object[])?] + ): Promise<Models.Transaction> { + let params: { transactionId: string, operations?: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; + } else { + params = { + transactionId: paramsOrFirst as string, + operations: rest[0] as object[] + }; + } + + const transactionId = params.transactionId; + const operations = params.operations; + + if (typeof transactionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + + const apiPath = '/tablesdb/transactions/{transactionId}/operations'.replace('{transactionId}', transactionId); + const payload: Payload = {}; + if (typeof operations !== 'undefined') { + payload['operations'] = operations; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + */ + get(this: TablesDB<ServerAuth>, params: { databaseId: string }): Promise<Models.Database>; + /** + * Get a database by its unique ID. This endpoint response returns a JSON object with the database metadata. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(this: TablesDB<ServerAuth>, databaseId: string): Promise<Models.Database>; + get( + paramsOrFirst: { databaseId: string } | string + ): Promise<Models.Database> { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a database by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.name - Database name. Max length: 128 chars. + * @param {boolean} params.enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + */ + update(this: TablesDB<ServerAuth>, params: { databaseId: string, name?: string, enabled?: boolean }): Promise<Models.Database>; + /** + * Update a database by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} name - Database name. Max length: 128 chars. + * @param {boolean} enabled - Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + * @throws {AppwriteException} + * @returns {Promise<Models.Database>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(this: TablesDB<ServerAuth>, databaseId: string, name?: string, enabled?: boolean): Promise<Models.Database>; + update( + paramsOrFirst: { databaseId: string, name?: string, enabled?: boolean } | string, + ...rest: [(string)?, (boolean)?] + ): Promise<Models.Database> { + let params: { databaseId: string, name?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, name?: string, enabled?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean + }; + } + + const databaseId = params.databaseId; + const name = params.name; + const enabled = params.enabled; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} params.databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(this: TablesDB<ServerAuth>, params: { databaseId: string }): Promise<{}>; + /** + * Delete a database by its unique ID. Only API keys with with databases.write scope can delete a database. + * + * @param {string} databaseId - Database ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(this: TablesDB<ServerAuth>, databaseId: string): Promise<{}>; + delete( + paramsOrFirst: { databaseId: string } | string + ): Promise<{}> { + let params: { databaseId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string }; + } else { + params = { + databaseId: paramsOrFirst as string + }; + } + + const databaseId = params.databaseId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} params.databaseId - Database ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name, enabled, rowSecurity + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.TableList>} + */ + listTables(this: TablesDB<ServerAuth>, params: { databaseId: string, queries?: string[], search?: string, total?: boolean }): Promise<Models.TableList>; + /** + * Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. + * + * @param {string} databaseId - Database ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: name, enabled, rowSecurity + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.TableList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listTables(this: TablesDB<ServerAuth>, databaseId: string, queries?: string[], search?: string, total?: boolean): Promise<Models.TableList>; + listTables( + paramsOrFirst: { databaseId: string, queries?: string[], search?: string, total?: boolean } | string, + ...rest: [(string[])?, (string)?, (boolean)?] + ): Promise<Models.TableList> { + let params: { databaseId: string, queries?: string[], search?: string, total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, queries?: string[], search?: string, total?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string, + total: rest[2] as boolean + }; + } + + const databaseId = params.databaseId; + const queries = params.queries; + const search = params.search; + const total = params.total; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Table name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + * @param {object[]} params.columns - Array of column definitions to create. Each column should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} params.indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + */ + createTable(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] }): Promise<Models.Table>; + /** + * Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Table name. Max length: 128 chars. + * @param {string[]} permissions - An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + * @param {object[]} columns - Array of column definitions to create. Each column should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + * @param {object[]} indexes - Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTable(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[]): Promise<Models.Table>; + createTable( + paramsOrFirst: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (object[])?, (object[])?] + ): Promise<Models.Table> { + let params: { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, name: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, columns?: object[], indexes?: object[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + rowSecurity: rest[3] as boolean, + enabled: rest[4] as boolean, + columns: rest[5] as object[], + indexes: rest[6] as object[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const name = params.name; + const permissions = params.permissions; + const rowSecurity = params.rowSecurity; + const enabled = params.enabled; + const columns = params.columns; + const indexes = params.indexes; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables'.replace('{databaseId}', databaseId); + const payload: Payload = {}; + if (typeof tableId !== 'undefined') { + payload['tableId'] = tableId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof rowSecurity !== 'undefined') { + payload['rowSecurity'] = rowSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof columns !== 'undefined') { + payload['columns'] = columns; + } + if (typeof indexes !== 'undefined') { + payload['indexes'] = indexes; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + */ + getTable(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string }): Promise<Models.Table>; + /** + * Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getTable(this: TablesDB<ServerAuth>, databaseId: string, tableId: string): Promise<Models.Table>; + getTable( + paramsOrFirst: { databaseId: string, tableId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Table> { + let params: { databaseId: string, tableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a table by its unique ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.name - Table name. Max length: 128 chars. + * @param {string[]} params.permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + * @param {boolean} params.purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + */ + updateTable(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean }): Promise<Models.Table>; + /** + * Update a table by its unique ID. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} name - Table name. Max length: 128 chars. + * @param {string[]} permissions - An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} rowSecurity - Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} enabled - Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + * @param {boolean} purge - When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. + * @throws {AppwriteException} + * @returns {Promise<Models.Table>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTable(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean): Promise<Models.Table>; + updateTable( + paramsOrFirst: { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (boolean)?] + ): Promise<Models.Table> { + let params: { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, name?: string, permissions?: string[], rowSecurity?: boolean, enabled?: boolean, purge?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + name: rest[1] as string, + permissions: rest[2] as string[], + rowSecurity: rest[3] as boolean, + enabled: rest[4] as boolean, + purge: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const name = params.name; + const permissions = params.permissions; + const rowSecurity = params.rowSecurity; + const enabled = params.enabled; + const purge = params.purge; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof rowSecurity !== 'undefined') { + payload['rowSecurity'] = rowSecurity; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof purge !== 'undefined') { + payload['purge'] = purge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a table by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTable(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string }): Promise<{}>; + /** + * Delete a table by its unique ID. Only users with write permissions have access to delete this resource. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteTable(this: TablesDB<ServerAuth>, databaseId: string, tableId: string): Promise<{}>; + deleteTable( + paramsOrFirst: { databaseId: string, tableId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { databaseId: string, tableId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * List columns in the table. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, size, required, array, status, error + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnList>} + */ + listColumns(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }): Promise<Models.ColumnList>; + /** + * List columns in the table. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, size, required, array, status, error + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listColumns(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, queries?: string[], total?: boolean): Promise<Models.ColumnList>; + listColumns( + paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?] + ): Promise<Models.ColumnList> { + let params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], total?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + queries: rest[1] as string[], + total: rest[2] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const queries = params.queries; + const total = params.total; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a bigint column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBigint>} + */ + createBigIntColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise<Models.ColumnBigint>; + /** + * Create a bigint column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBigint>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBigIntColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise<Models.ColumnBigint>; + createBigIntColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + ): Promise<Models.ColumnBigint> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number | bigint, + max: rest[4] as number | bigint, + xdefault: rest[5] as number | bigint, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a bigint column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBigint>} + */ + updateBigIntColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise<Models.ColumnBigint>; + /** + * Update a bigint column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBigint>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBigIntColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise<Models.ColumnBigint>; + updateBigIntColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + ): Promise<Models.ColumnBigint> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number | bigint, + min: rest[4] as number | bigint, + max: rest[5] as number | bigint, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a boolean column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBoolean>} + */ + createBooleanColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }): Promise<Models.ColumnBoolean>; + /** + * Create a boolean column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBoolean>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBooleanColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean): Promise<Models.ColumnBoolean>; + createBooleanColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (boolean)?] + ): Promise<Models.ColumnBoolean> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as boolean, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a boolean column. Changing the `default` value will not update already existing rows. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {boolean} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBoolean>} + */ + updateBooleanColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }): Promise<Models.ColumnBoolean>; + /** + * Update a boolean column. Changing the `default` value will not update already existing rows. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {boolean} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBoolean>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateBooleanColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string): Promise<Models.ColumnBoolean>; + updateBooleanColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (boolean)?, (string)?] + ): Promise<Models.ColumnBoolean> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: boolean, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as boolean, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/boolean/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a date time column according to the ISO 8601 standard. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnDatetime>} + */ + createDatetimeColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.ColumnDatetime>; + /** + * Create a date time column according to the ISO 8601 standard. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnDatetime>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDatetimeColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnDatetime>; + createDatetimeColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.ColumnDatetime> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a date time column. Changing the `default` value will not update already existing rows. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnDatetime>} + */ + updateDatetimeColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnDatetime>; + /** + * Update a date time column. Changing the `default` value will not update already existing rows. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnDatetime>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateDatetimeColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnDatetime>; + updateDatetimeColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnDatetime> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/datetime/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create an email column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEmail>} + */ + createEmailColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.ColumnEmail>; + /** + * Create an email column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEmail>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEmailColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnEmail>; + createEmailColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.ColumnEmail> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/email'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an email column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEmail>} + */ + updateEmailColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnEmail>; + /** + * Update an email column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEmail>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmailColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnEmail>; + updateEmailColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnEmail> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/email/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {string[]} params.elements - Array of enum values. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEnum>} + */ + createEnumColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }): Promise<Models.ColumnEnum>; + /** + * Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {string[]} elements - Array of enum values. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEnum>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createEnumColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnEnum>; + createEnumColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.ColumnEnum> { + let params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + elements: rest[2] as string[], + required: rest[3] as boolean, + xdefault: rest[4] as string, + array: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const elements = params.elements; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof elements === 'undefined') { + throw new AppwriteException('Missing required parameter: "elements"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof elements !== 'undefined') { + payload['elements'] = elements; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an enum column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {string[]} params.elements - Updated list of enum values. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEnum>} + */ + updateEnumColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnEnum>; + /** + * Update an enum column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {string[]} elements - Updated list of enum values. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnEnum>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEnumColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnEnum>; + updateEnumColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnEnum> { + let params: { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, elements: string[], required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + elements: rest[2] as string[], + required: rest[3] as boolean, + xdefault: rest[4] as string, + newKey: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const elements = params.elements; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof elements === 'undefined') { + throw new AppwriteException('Missing required parameter: "elements"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/enum/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof elements !== 'undefined') { + payload['elements'] = elements; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a float column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number} params.min - Minimum value + * @param {number} params.max - Maximum value + * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnFloat>} + */ + createFloatColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }): Promise<Models.ColumnFloat>; + /** + * Create a float column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number} min - Minimum value + * @param {number} max - Maximum value + * @param {number} xdefault - Default value. Cannot be set when required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnFloat>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFloatColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean): Promise<Models.ColumnFloat>; + createFloatColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (boolean)?] + ): Promise<Models.ColumnFloat> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number, max?: number, xdefault?: number, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number, + max: rest[4] as number, + xdefault: rest[5] as number, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/float'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a float column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number} params.xdefault - Default value. Cannot be set when required. + * @param {number} params.min - Minimum value + * @param {number} params.max - Maximum value + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnFloat>} + */ + updateFloatColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }): Promise<Models.ColumnFloat>; + /** + * Update a float column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number} xdefault - Default value. Cannot be set when required. + * @param {number} min - Minimum value + * @param {number} max - Maximum value + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnFloat>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateFloatColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string): Promise<Models.ColumnFloat>; + updateFloatColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number)?, (number)?, (number)?, (string)?] + ): Promise<Models.ColumnFloat> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number, min?: number, max?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number, + min: rest[4] as number, + max: rest[5] as number, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/float/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create an integer column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnInteger>} + */ + createIntegerColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }): Promise<Models.ColumnInteger>; + /** + * Create an integer column. Optionally, minimum and maximum values can be provided. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnInteger>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIntegerColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean): Promise<Models.ColumnInteger>; + createIntegerColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (boolean)?] + ): Promise<Models.ColumnInteger> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, min?: number | bigint, max?: number | bigint, xdefault?: number | bigint, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + min: rest[3] as number | bigint, + max: rest[4] as number | bigint, + xdefault: rest[5] as number | bigint, + array: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const min = params.min; + const max = params.max; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an integer column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {number | bigint} params.xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint} params.min - Minimum value + * @param {number | bigint} params.max - Maximum value + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnInteger>} + */ + updateIntegerColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }): Promise<Models.ColumnInteger>; + /** + * Update an integer column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {number | bigint} xdefault - Default value. Cannot be set when column is required. + * @param {number | bigint} min - Minimum value + * @param {number | bigint} max - Maximum value + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnInteger>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateIntegerColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string): Promise<Models.ColumnInteger>; + updateIntegerColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (number | bigint)?, (number | bigint)?, (number | bigint)?, (string)?] + ): Promise<Models.ColumnInteger> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: number | bigint, min?: number | bigint, max?: number | bigint, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as number | bigint, + min: rest[4] as number | bigint, + max: rest[5] as number | bigint, + newKey: rest[6] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const min = params.min; + const max = params.max; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/integer/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof min !== 'undefined') { + payload['min'] = min; + } + if (typeof max !== 'undefined') { + payload['max'] = max; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create IP address column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIp>} + */ + createIpColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.ColumnIp>; + /** + * Create IP address column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIp>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIpColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnIp>; + createIpColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.ColumnIp> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an ip column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIp>} + */ + updateIpColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnIp>; + /** + * Update an ip column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIp>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateIpColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnIp>; + updateIpColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnIp> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/ip/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a geometric line column. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {any[]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnLine>} + */ + createLineColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] }): Promise<Models.ColumnLine>; + /** + * Create a geometric line column. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {any[]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnLine>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createLineColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[]): Promise<Models.ColumnLine>; + createLineColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?] + ): Promise<Models.ColumnLine> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/line'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a line column. Changing the `default` value will not update already existing rows. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {any[]} params.xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnLine>} + */ + updateLineColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }): Promise<Models.ColumnLine>; + /** + * Update a line column. Changing the `default` value will not update already existing rows. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {any[]} xdefault - Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnLine>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateLineColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string): Promise<Models.ColumnLine>; + updateLineColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?, (string)?] + ): Promise<Models.ColumnLine> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[], + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a longtext column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnLongtext>} + */ + createLongtextColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.ColumnLongtext>; + /** + * Create a longtext column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnLongtext>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createLongtextColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.ColumnLongtext>; + createLongtextColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.ColumnLongtext> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean, + encrypt: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a longtext column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnLongtext>} + */ + updateLongtextColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnLongtext>; + /** + * Update a longtext column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnLongtext>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateLongtextColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnLongtext>; + updateLongtextColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnLongtext> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a mediumtext column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnMediumtext>} + */ + createMediumtextColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.ColumnMediumtext>; + /** + * Create a mediumtext column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnMediumtext>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMediumtextColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.ColumnMediumtext>; + createMediumtextColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.ColumnMediumtext> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean, + encrypt: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a mediumtext column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnMediumtext>} + */ + updateMediumtextColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnMediumtext>; + /** + * Update a mediumtext column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnMediumtext>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMediumtextColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnMediumtext>; + updateMediumtextColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnMediumtext> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a geometric point column. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {any[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnPoint>} + */ + createPointColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] }): Promise<Models.ColumnPoint>; + /** + * Create a geometric point column. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {any[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnPoint>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPointColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[]): Promise<Models.ColumnPoint>; + createPointColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?] + ): Promise<Models.ColumnPoint> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/point'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a point column. Changing the `default` value will not update already existing rows. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {any[]} params.xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnPoint>} + */ + updatePointColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }): Promise<Models.ColumnPoint>; + /** + * Update a point column. Changing the `default` value will not update already existing rows. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {any[]} xdefault - Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnPoint>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePointColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string): Promise<Models.ColumnPoint>; + updatePointColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?, (string)?] + ): Promise<Models.ColumnPoint> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[], + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a geometric polygon column. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {any[]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnPolygon>} + */ + createPolygonColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] }): Promise<Models.ColumnPolygon>; + /** + * Create a geometric polygon column. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {any[]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnPolygon>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPolygonColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[]): Promise<Models.ColumnPolygon>; + createPolygonColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?] + ): Promise<Models.ColumnPolygon> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a polygon column. Changing the `default` value will not update already existing rows. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {any[]} params.xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnPolygon>} + */ + updatePolygonColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }): Promise<Models.ColumnPolygon>; + /** + * Update a polygon column. Changing the `default` value will not update already existing rows. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {any[]} xdefault - Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnPolygon>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePolygonColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string): Promise<Models.ColumnPolygon>; + updatePolygonColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (any[])?, (string)?] + ): Promise<Models.ColumnPolygon> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: any[], newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as any[], + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.relatedTableId - Related Table ID. + * @param {RelationshipType} params.type - Relation type + * @param {boolean} params.twoWay - Is Two Way? + * @param {string} params.key - Column Key. + * @param {string} params.twoWayKey - Two Way Column Key. + * @param {RelationMutate} params.onDelete - Constraints option + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnRelationship>} + */ + createRelationshipColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }): Promise<Models.ColumnRelationship>; + /** + * Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} relatedTableId - Related Table ID. + * @param {RelationshipType} type - Relation type + * @param {boolean} twoWay - Is Two Way? + * @param {string} key - Column Key. + * @param {string} twoWayKey - Two Way Column Key. + * @param {RelationMutate} onDelete - Constraints option + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnRelationship>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRelationshipColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate): Promise<Models.ColumnRelationship>; + createRelationshipColumn( + paramsOrFirst: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate } | string, + ...rest: [(string)?, (string)?, (RelationshipType)?, (boolean)?, (string)?, (string)?, (RelationMutate)?] + ): Promise<Models.ColumnRelationship> { + let params: { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, relatedTableId: string, type: RelationshipType, twoWay?: boolean, key?: string, twoWayKey?: string, onDelete?: RelationMutate }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + relatedTableId: rest[1] as string, + type: rest[2] as RelationshipType, + twoWay: rest[3] as boolean, + key: rest[4] as string, + twoWayKey: rest[5] as string, + onDelete: rest[6] as RelationMutate + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const relatedTableId = params.relatedTableId; + const type = params.type; + const twoWay = params.twoWay; + const key = params.key; + const twoWayKey = params.twoWayKey; + const onDelete = params.onDelete; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof relatedTableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "relatedTableId"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof relatedTableId !== 'undefined') { + payload['relatedTableId'] = relatedTableId; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof twoWay !== 'undefined') { + payload['twoWay'] = twoWay; + } + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof twoWayKey !== 'undefined') { + payload['twoWayKey'] = twoWayKey; + } + if (typeof onDelete !== 'undefined') { + payload['onDelete'] = onDelete; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a string column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {number} params.size - Column size for text columns, in number of characters. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnString>} + * @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. + */ + createStringColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.ColumnString>; + /** + * Create a string column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {number} size - Column size for text columns, in number of characters. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnString>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createStringColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.ColumnString>; + createStringColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.ColumnString> { + let params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + size: rest[2] as number, + required: rest[3] as boolean, + xdefault: rest[4] as string, + array: rest[5] as boolean, + encrypt: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const size = params.size; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof size === 'undefined') { + throw new AppwriteException('Missing required parameter: "size"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/string'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a string column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number} params.size - Maximum size of the string column. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnString>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. + */ + updateStringColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise<Models.ColumnString>; + /** + * Update a string column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number} size - Maximum size of the string column. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnString>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateStringColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise<Models.ColumnString>; + updateStringColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + ): Promise<Models.ColumnString> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + size: rest[4] as number, + newKey: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const size = params.size; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/string/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a text column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnText>} + */ + createTextColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.ColumnText>; + /** + * Create a text column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnText>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTextColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.ColumnText>; + createTextColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.ColumnText> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean, + encrypt: rest[5] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/text'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a text column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnText>} + */ + updateTextColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnText>; + /** + * Update a text column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnText>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTextColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnText>; + updateTextColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnText> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a URL column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnUrl>} + */ + createUrlColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }): Promise<Models.ColumnUrl>; + /** + * Create a URL column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnUrl>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createUrlColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean): Promise<Models.ColumnUrl>; + createUrlColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (boolean)?] + ): Promise<Models.ColumnUrl> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, array?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + array: rest[4] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update an url column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnUrl>} + */ + updateUrlColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }): Promise<Models.ColumnUrl>; + /** + * Update an url column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnUrl>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateUrlColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string): Promise<Models.ColumnUrl>; + updateUrlColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.ColumnUrl> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + newKey: rest[4] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/url/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a varchar column. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {number} params.size - Column size for varchar columns, in number of characters. Maximum size is 16381. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} params.array - Is column an array? + * @param {boolean} params.encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnVarchar>} + */ + createVarcharColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }): Promise<Models.ColumnVarchar>; + /** + * Create a varchar column. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {number} size - Column size for varchar columns, in number of characters. Maximum size is 16381. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {boolean} array - Is column an array? + * @param {boolean} encrypt - Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnVarchar>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVarcharColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean): Promise<Models.ColumnVarchar>; + createVarcharColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (boolean)?, (string)?, (boolean)?, (boolean)?] + ): Promise<Models.ColumnVarchar> { + let params: { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, size: number, required: boolean, xdefault?: string, array?: boolean, encrypt?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + size: rest[2] as number, + required: rest[3] as boolean, + xdefault: rest[4] as string, + array: rest[5] as boolean, + encrypt: rest[6] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const size = params.size; + const required = params.required; + const xdefault = params.xdefault; + const array = params.array; + const encrypt = params.encrypt; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof size === 'undefined') { + throw new AppwriteException('Missing required parameter: "size"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof array !== 'undefined') { + payload['array'] = array; + } + if (typeof encrypt !== 'undefined') { + payload['encrypt'] = encrypt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a varchar column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Column Key. + * @param {boolean} params.required - Is column required? + * @param {string} params.xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number} params.size - Maximum size of the varchar column. + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnVarchar>} + */ + updateVarcharColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }): Promise<Models.ColumnVarchar>; + /** + * Update a varchar column. Changing the `default` value will not update already existing rows. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Column Key. + * @param {boolean} required - Is column required? + * @param {string} xdefault - Default value for column when not provided. Cannot be set when column is required. + * @param {number} size - Maximum size of the varchar column. + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnVarchar>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateVarcharColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string): Promise<Models.ColumnVarchar>; + updateVarcharColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string } | string, + ...rest: [(string)?, (string)?, (boolean)?, (string)?, (number)?, (string)?] + ): Promise<Models.ColumnVarchar> { + let params: { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, required: boolean, xdefault?: string, size?: number, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + required: rest[2] as boolean, + xdefault: rest[3] as string, + size: rest[4] as number, + newKey: rest[5] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const required = params.required; + const xdefault = params.xdefault; + const size = params.size; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof required === 'undefined') { + throw new AppwriteException('Missing required parameter: "required"'); + } + if (typeof xdefault === 'undefined') { + throw new AppwriteException('Missing required parameter: "xdefault"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof required !== 'undefined') { + payload['required'] = required; + } + if (typeof xdefault !== 'undefined') { + payload['default'] = xdefault; + } + if (typeof size !== 'undefined') { + payload['size'] = size; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get column by ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString>} + */ + getColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string }): Promise<Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString>; + /** + * Get column by ID. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string): Promise<Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString>; + getColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.ColumnBoolean | Models.ColumnInteger | Models.ColumnFloat | Models.ColumnEmail | Models.ColumnEnum | Models.ColumnUrl | Models.ColumnIp | Models.ColumnDatetime | Models.ColumnRelationship | Models.ColumnString> { + let params: { databaseId: string, tableId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Deletes a column. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string }): Promise<{}>; + /** + * Deletes a column. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string): Promise<{}>; + deleteColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, tableId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {string} params.key - Column Key. + * @param {RelationMutate} params.onDelete - Constraints option + * @param {string} params.newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnRelationship>} + */ + updateRelationshipColumn(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }): Promise<Models.ColumnRelationship>; + /** + * Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {string} key - Column Key. + * @param {RelationMutate} onDelete - Constraints option + * @param {string} newKey - New Column Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnRelationship>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRelationshipColumn(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string): Promise<Models.ColumnRelationship>; + updateRelationshipColumn( + paramsOrFirst: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string } | string, + ...rest: [(string)?, (string)?, (RelationMutate)?, (string)?] + ): Promise<Models.ColumnRelationship> { + let params: { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, onDelete?: RelationMutate, newKey?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + onDelete: rest[2] as RelationMutate, + newKey: rest[3] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const onDelete = params.onDelete; + const newKey = params.newKey; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); + const payload: Payload = {}; + if (typeof onDelete !== 'undefined') { + payload['onDelete'] = onDelete; + } + if (typeof newKey !== 'undefined') { + payload['newKey'] = newKey; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * List indexes on the table. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, status, attributes, error + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndexList>} + */ + listIndexes(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }): Promise<Models.ColumnIndexList>; + /** + * List indexes on the table. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following columns: key, type, status, attributes, error + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndexList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listIndexes(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, queries?: string[], total?: boolean): Promise<Models.ColumnIndexList>; + listIndexes( + paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?] + ): Promise<Models.ColumnIndexList> { + let params: { databaseId: string, tableId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], total?: boolean }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + queries: rest[1] as string[], + total: rest[2] as boolean + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const queries = params.queries; + const total = params.total; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Creates an index on the columns listed. Your index should include all the columns you will query in a single request. + * Type can be `key`, `fulltext`, or `unique`. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Index Key. + * @param {TablesDBIndexType} params.type - Index type. + * @param {string[]} params.columns - Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. + * @param {OrderBy[]} params.orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} params.lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndex>} + */ + createIndex(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }): Promise<Models.ColumnIndex>; + /** + * Creates an index on the columns listed. Your index should include all the columns you will query in a single request. + * Type can be `key`, `fulltext`, or `unique`. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Index Key. + * @param {TablesDBIndexType} type - Index type. + * @param {string[]} columns - Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. + * @param {OrderBy[]} orders - Array of index orders. Maximum of 100 orders are allowed. + * @param {number[]} lengths - Length of index. Maximum of 100 + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndex>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createIndex(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[]): Promise<Models.ColumnIndex>; + createIndex( + paramsOrFirst: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] } | string, + ...rest: [(string)?, (string)?, (TablesDBIndexType)?, (string[])?, (OrderBy[])?, (number[])?] + ): Promise<Models.ColumnIndex> { + let params: { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string, type: TablesDBIndexType, columns: string[], orders?: OrderBy[], lengths?: number[] }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string, + type: rest[2] as TablesDBIndexType, + columns: rest[3] as string[], + orders: rest[4] as OrderBy[], + lengths: rest[5] as number[] + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + const type = params.type; + const columns = params.columns; + const orders = params.orders; + const lengths = params.lengths; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof columns === 'undefined') { + throw new AppwriteException('Missing required parameter: "columns"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof key !== 'undefined') { + payload['key'] = key; + } + if (typeof type !== 'undefined') { + payload['type'] = type; + } + if (typeof columns !== 'undefined') { + payload['columns'] = columns; + } + if (typeof orders !== 'undefined') { + payload['orders'] = orders; + } + if (typeof lengths !== 'undefined') { + payload['lengths'] = lengths; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get index by ID. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndex>} + */ + getIndex(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string }): Promise<Models.ColumnIndex>; + /** + * Get index by ID. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Index Key. + * @throws {AppwriteException} + * @returns {Promise<Models.ColumnIndex>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getIndex(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string): Promise<Models.ColumnIndex>; + getIndex( + paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.ColumnIndex> { + let params: { databaseId: string, tableId: string, key: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); } - const apiPath = '/tablesdb/transactions/{transactionId}'.replace('{transactionId}', transactionId); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { - 'content-type': 'application/json', } return this.client.call( - 'delete', + 'get', uri, apiHeaders, payload @@ -284,51 +5096,58 @@ export class TablesDB { } /** - * Create multiple operations in a single transaction. + * Delete an index. * - * @param {string} params.transactionId - Transaction ID. - * @param {object[]} params.operations - Array of staged operations. + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} params.key - Index Key. * @throws {AppwriteException} - * @returns {Promise<Models.Transaction>} + * @returns {Promise<{}>} */ - createOperations(params: { transactionId: string, operations?: object[] }): Promise<Models.Transaction>; + deleteIndex(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, key: string }): Promise<{}>; /** - * Create multiple operations in a single transaction. + * Delete an index. * - * @param {string} transactionId - Transaction ID. - * @param {object[]} operations - Array of staged operations. + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string} key - Index Key. * @throws {AppwriteException} - * @returns {Promise<Models.Transaction>} + * @returns {Promise<{}>} * @deprecated Use the object parameter style method for a better developer experience. */ - createOperations(transactionId: string, operations?: object[]): Promise<Models.Transaction>; - createOperations( - paramsOrFirst: { transactionId: string, operations?: object[] } | string, - ...rest: [(object[])?] - ): Promise<Models.Transaction> { - let params: { transactionId: string, operations?: object[] }; + deleteIndex(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, key: string): Promise<{}>; + deleteIndex( + paramsOrFirst: { databaseId: string, tableId: string, key: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<{}> { + let params: { databaseId: string, tableId: string, key: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, key: string }; } else { params = { - transactionId: paramsOrFirst as string, - operations: rest[0] as object[] + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + key: rest[1] as string }; } - const transactionId = params.transactionId; - const operations = params.operations; + const databaseId = params.databaseId; + const tableId = params.tableId; + const key = params.key; - if (typeof transactionId === 'undefined') { - throw new AppwriteException('Missing required parameter: "transactionId"'); + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof key === 'undefined') { + throw new AppwriteException('Missing required parameter: "key"'); } - const apiPath = '/tablesdb/transactions/{transactionId}/operations'.replace('{transactionId}', transactionId); + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{tableId}', tableId).replace('{key}', key); const payload: Payload = {}; - if (typeof operations !== 'undefined') { - payload['operations'] = operations; - } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -336,7 +5155,7 @@ export class TablesDB { } return this.client.call( - 'post', + 'delete', uri, apiHeaders, payload @@ -438,11 +5257,12 @@ export class TablesDB { * @param {string} params.rowId - Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} params.data - Row data as JSON object. * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {object[]} params.rows - Array of rows data as JSON objects. * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ - createRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string }): Promise<Row>; + createRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId?: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], rows?: object[], transactionId?: string }): Promise<Row>; /** * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * @@ -451,20 +5271,21 @@ export class TablesDB { * @param {string} rowId - Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} data - Row data as JSON object. * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {object[]} rows - Array of rows data as JSON objects. * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. */ - createRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string): Promise<Row>; + createRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId?: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], rows?: object[], transactionId?: string): Promise<Row>; createRow<Row extends Models.Row = Models.DefaultRow>( - paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, (string[])?, (string)?] + paramsOrFirst: { databaseId: string, tableId: string, rowId?: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], rows?: object[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, (string[])?, (object[])?, (string)?] ): Promise<Row> { - let params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string }; + let params: { databaseId: string, tableId: string, rowId?: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], rows?: object[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId?: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], rows?: object[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, @@ -472,7 +5293,8 @@ export class TablesDB { rowId: rest[1] as string, data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions: rest[3] as string[], - transactionId: rest[4] as string + rows: rest[4] as object[], + transactionId: rest[5] as string }; } @@ -481,6 +5303,7 @@ export class TablesDB { const rowId = params.rowId; const data = params.data; const permissions = params.permissions; + const rows = params.rows; const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { @@ -489,12 +5312,6 @@ export class TablesDB { if (typeof tableId === 'undefined') { throw new AppwriteException('Missing required parameter: "tableId"'); } - if (typeof rowId === 'undefined') { - throw new AppwriteException('Missing required parameter: "rowId"'); - } - if (typeof data === 'undefined') { - throw new AppwriteException('Missing required parameter: "data"'); - } const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); const payload: Payload = {}; @@ -507,6 +5324,9 @@ export class TablesDB { if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof rows !== 'undefined') { + payload['rows'] = rows; + } if (typeof transactionId !== 'undefined') { payload['transactionId'] = transactionId; } @@ -524,6 +5344,240 @@ export class TablesDB { ); } + /** + * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. + * + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {object[]} params.rows - Array of row data as JSON objects. May contain partial rows. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + */ + upsertRows<Row extends Models.Row = Models.DefaultRow>(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }): Promise<Models.RowList<Row>>; + /** + * Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. + * + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {object[]} rows - Array of row data as JSON objects. May contain partial rows. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsertRows<Row extends Models.Row = Models.DefaultRow>(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, rows: object[], transactionId?: string): Promise<Models.RowList<Row>>; + upsertRows<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, rows: object[], transactionId?: string } | string, + ...rest: [(string)?, (object[])?, (string)?] + ): Promise<Models.RowList<Row>> { + let params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rows: rest[1] as object[], + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rows = params.rows; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rows === 'undefined') { + throw new AppwriteException('Missing required parameter: "rows"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof rows !== 'undefined') { + payload['rows'] = rows; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. + * @param {object} params.data - Row data as JSON object. Include only column and value pairs to be updated. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + */ + updateRows<Row extends Models.Row = Models.DefaultRow>(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }): Promise<Models.RowList<Row>>; + /** + * Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. + * @param {object} data - Row data as JSON object. Include only column and value pairs to be updated. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateRows<Row extends Models.Row = Models.DefaultRow>(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string): Promise<Models.RowList<Row>>; + updateRows<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (object)?, (string[])?, (string)?] + ): Promise<Models.RowList<Row>> { + let params: { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, data?: object, queries?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + data: rest[1] as object, + queries: rest[2] as string[], + transactionId: rest[3] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const data = params.data; + const queries = params.queries; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof data !== 'undefined') { + payload['data'] = data; + } + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Bulk delete rows using queries, if no queries are passed then all rows are deleted. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + */ + deleteRows<Row extends Models.Row = Models.DefaultRow>(this: TablesDB<ServerAuth>, params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string }): Promise<Models.RowList<Row>>; + /** + * Bulk delete rows using queries, if no queries are passed then all rows are deleted. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteRows<Row extends Models.Row = Models.DefaultRow>(this: TablesDB<ServerAuth>, databaseId: string, tableId: string, queries?: string[], transactionId?: string): Promise<Models.RowList<Row>>; + deleteRows<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, queries?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string[])?, (string)?] + ): Promise<Models.RowList<Row>> { + let params: { databaseId: string, tableId: string, queries?: string[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, queries?: string[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + queries: rest[1] as string[], + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const queries = params.queries; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + /** * Get a row by its unique ID. This endpoint response returns a JSON object with the row data. * @@ -1044,3 +6098,9 @@ export class TablesDB { ); } } + +const TablesDB = TablesDBRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): TablesDB<TAuth>; +}; + +export { TablesDB }; diff --git a/src/services/teams.ts b/src/services/teams.ts index 870f8a5b..cdcf75ca 100644 --- a/src/services/teams.ts +++ b/src/services/teams.ts @@ -1,12 +1,21 @@ -import { Service } from '../service'; -import { AppwriteException, Client, type Payload, UploadProgress } from '../client'; +import { AppwriteException, Client, type ClientAuth, type ServerAuth, type Payload } from '../client'; import type { Models } from '../models'; -export class Teams { - client: Client; +type TeamsServerOnlyMethod = never; +type TeamsClientOnlyMethod = never; - constructor(client: Client) { +export type Teams<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = + TAuth extends ClientAuth + ? Omit<TeamsRuntime<TAuth>, 'client' | TeamsServerOnlyMethod> + : TAuth extends ServerAuth + ? Omit<TeamsRuntime<TAuth>, 'client' | TeamsClientOnlyMethod> + : Omit<TeamsRuntime<TAuth>, 'client'>; + +class TeamsRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> { + client: Client<TAuth>; + + constructor(client: Client<TAuth>) { this.client = client; } @@ -891,3 +900,9 @@ export class Teams { ); } } + +const Teams = TeamsRuntime as unknown as { + new <TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth>(client: Client<TAuth>): Teams<TAuth>; +}; + +export { Teams }; diff --git a/src/services/tokens.ts b/src/services/tokens.ts new file mode 100644 index 00000000..eb904d5c --- /dev/null +++ b/src/services/tokens.ts @@ -0,0 +1,322 @@ +import { AppwriteException, Client, type ServerAuth, type Payload } from '../client'; +import type { Models } from '../models'; + + +export type Tokens = Omit<TokensRuntime, 'client'>; + +class TokensRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * List all the tokens created for a specific file or bucket. You can use the query params to filter your results. + * + * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File unique ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceTokenList>} + */ + list(params: { bucketId: string, fileId: string, queries?: string[], total?: boolean }): Promise<Models.ResourceTokenList>; + /** + * List all the tokens created for a specific file or bucket. You can use the query params to filter your results. + * + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File unique ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceTokenList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(bucketId: string, fileId: string, queries?: string[], total?: boolean): Promise<Models.ResourceTokenList>; + list( + paramsOrFirst: { bucketId: string, fileId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string)?, (string[])?, (boolean)?] + ): Promise<Models.ResourceTokenList> { + let params: { bucketId: string, fileId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, queries?: string[], total?: boolean }; + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string, + queries: rest[1] as string[], + total: rest[2] as boolean + }; + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + const queries = params.queries; + const total = params.total; + + if (typeof bucketId === 'undefined') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + if (typeof fileId === 'undefined') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + + const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. + * + * @param {string} params.bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} params.fileId - File unique ID. + * @param {string} params.expire - Token expiry date + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceToken>} + */ + createFileToken(params: { bucketId: string, fileId: string, expire?: string }): Promise<Models.ResourceToken>; + /** + * Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. + * + * @param {string} bucketId - Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). + * @param {string} fileId - File unique ID. + * @param {string} expire - Token expiry date + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceToken>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFileToken(bucketId: string, fileId: string, expire?: string): Promise<Models.ResourceToken>; + createFileToken( + paramsOrFirst: { bucketId: string, fileId: string, expire?: string } | string, + ...rest: [(string)?, (string)?] + ): Promise<Models.ResourceToken> { + let params: { bucketId: string, fileId: string, expire?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { bucketId: string, fileId: string, expire?: string }; + } else { + params = { + bucketId: paramsOrFirst as string, + fileId: rest[0] as string, + expire: rest[1] as string + }; + } + + const bucketId = params.bucketId; + const fileId = params.fileId; + const expire = params.expire; + + if (typeof bucketId === 'undefined') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + if (typeof fileId === 'undefined') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + + const apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); + const payload: Payload = {}; + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a token by its unique ID. + * + * @param {string} params.tokenId - Token ID. + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceToken>} + */ + get(params: { tokenId: string }): Promise<Models.ResourceToken>; + /** + * Get a token by its unique ID. + * + * @param {string} tokenId - Token ID. + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceToken>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(tokenId: string): Promise<Models.ResourceToken>; + get( + paramsOrFirst: { tokenId: string } | string + ): Promise<Models.ResourceToken> { + let params: { tokenId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { tokenId: string }; + } else { + params = { + tokenId: paramsOrFirst as string + }; + } + + const tokenId = params.tokenId; + + if (typeof tokenId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + + const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a token by its unique ID. Use this endpoint to update a token's expiry date. + * + * @param {string} params.tokenId - Token unique ID. + * @param {string} params.expire - File token expiry date + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceToken>} + */ + update(params: { tokenId: string, expire?: string }): Promise<Models.ResourceToken>; + /** + * Update a token by its unique ID. Use this endpoint to update a token's expiry date. + * + * @param {string} tokenId - Token unique ID. + * @param {string} expire - File token expiry date + * @throws {AppwriteException} + * @returns {Promise<Models.ResourceToken>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(tokenId: string, expire?: string): Promise<Models.ResourceToken>; + update( + paramsOrFirst: { tokenId: string, expire?: string } | string, + ...rest: [(string)?] + ): Promise<Models.ResourceToken> { + let params: { tokenId: string, expire?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { tokenId: string, expire?: string }; + } else { + params = { + tokenId: paramsOrFirst as string, + expire: rest[0] as string + }; + } + + const tokenId = params.tokenId; + const expire = params.expire; + + if (typeof tokenId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + + const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId); + const payload: Payload = {}; + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a token by its unique ID. + * + * @param {string} params.tokenId - Token ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { tokenId: string }): Promise<{}>; + /** + * Delete a token by its unique ID. + * + * @param {string} tokenId - Token ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(tokenId: string): Promise<{}>; + delete( + paramsOrFirst: { tokenId: string } | string + ): Promise<{}> { + let params: { tokenId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { tokenId: string }; + } else { + params = { + tokenId: paramsOrFirst as string + }; + } + + const tokenId = params.tokenId; + + if (typeof tokenId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + + const apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } +} + +const Tokens = TokensRuntime as unknown as { + new (client: Client<ServerAuth>): Tokens; +}; + +export { Tokens }; diff --git a/src/services/usage.ts b/src/services/usage.ts new file mode 100644 index 00000000..faadcdb5 --- /dev/null +++ b/src/services/usage.ts @@ -0,0 +1,137 @@ +import { AppwriteException, Client, type ServerAuth, type Payload } from '../client'; +import type { Models } from '../models'; + + +export type Usage = Omit<UsageRuntime, 'client'>; + +class UsageRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * Query usage event metrics from the usage database. Returns individual event rows with full metadata. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, path, method, status, resource, resourceId, country, userAgent, time (these match the underlying column names — note that the response surfaces `resource` as `resourceType` and `country` as `countryCode`). When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. + * + * @param {string[]} params.queries - Array of query strings as JSON. Supported: equal("metric", [...]), equal("path", [...]), equal("method", [...]), equal("status", [...]), equal("resource", [...]), equal("resourceId", [...]), equal("country", [...]), equal("userAgent", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N). + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.UsageEventList>} + */ + listEvents(params?: { queries?: string[], total?: boolean }): Promise<Models.UsageEventList>; + /** + * Query usage event metrics from the usage database. Returns individual event rows with full metadata. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, path, method, status, resource, resourceId, country, userAgent, time (these match the underlying column names — note that the response surfaces `resource` as `resourceType` and `country` as `countryCode`). When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. + * + * @param {string[]} queries - Array of query strings as JSON. Supported: equal("metric", [...]), equal("path", [...]), equal("method", [...]), equal("status", [...]), equal("resource", [...]), equal("resourceId", [...]), equal("country", [...]), equal("userAgent", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N). + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.UsageEventList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listEvents(queries?: string[], total?: boolean): Promise<Models.UsageEventList>; + listEvents( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.UsageEventList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/usage/events'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Query usage gauge metrics (point-in-time resource snapshots) from the usage database. Returns individual gauge snapshots with metric, value, and timestamp. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, time. Use `orderDesc("time"), limit(1)` to fetch the most recent snapshot. When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. + * + * @param {string[]} params.queries - Array of query strings as JSON. Supported: equal("metric", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N). + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.UsageGaugeList>} + */ + listGauges(params?: { queries?: string[], total?: boolean }): Promise<Models.UsageGaugeList>; + /** + * Query usage gauge metrics (point-in-time resource snapshots) from the usage database. Returns individual gauge snapshots with metric, value, and timestamp. Pass Query objects as JSON strings to filter, paginate, and order results. Supported query methods: equal, greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter attributes: metric, time. Use `orderDesc("time"), limit(1)` to fetch the most recent snapshot. When no time filter is supplied the endpoint defaults to the last 7 days. Default `limit(100)` is applied if none is given; user-supplied limits are capped at 500. The `total` field is capped at 5000 to keep counts predictable — pass `total=false` to skip the count entirely. + * + * @param {string[]} queries - Array of query strings as JSON. Supported: equal("metric", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N). + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.UsageGaugeList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listGauges(queries?: string[], total?: boolean): Promise<Models.UsageGaugeList>; + listGauges( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.UsageGaugeList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/usage/gauges'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } +} + +const Usage = UsageRuntime as unknown as { + new (client: Client<ServerAuth>): Usage; +}; + +export { Usage }; diff --git a/src/services/users.ts b/src/services/users.ts new file mode 100644 index 00000000..dc82ee16 --- /dev/null +++ b/src/services/users.ts @@ -0,0 +1,2948 @@ +import { AppwriteException, Client, type ServerAuth, type Payload } from '../client'; +import type { Models } from '../models'; + +import { PasswordHash } from '../enums/password-hash'; +import { AuthenticatorType } from '../enums/authenticator-type'; +import { MessagingProviderType } from '../enums/messaging-provider-type'; + +export type Users = Omit<UsersRuntime, 'client'>; + +class UsersRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * Get a list of all the project's users. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.UserList<Preferences>>} + */ + list<Preferences extends Models.Preferences = Models.DefaultPreferences>(params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.UserList<Preferences>>; + /** + * Get a list of all the project's users. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.UserList<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list<Preferences extends Models.Preferences = Models.DefaultPreferences>(queries?: string[], search?: string, total?: boolean): Promise<Models.UserList<Preferences>>; + list<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise<Models.UserList<Preferences>> { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/users'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new user. + * + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} params.password - Plain text user password. Must be at least 8 chars. + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + create<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email?: string, phone?: string, password?: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} phone - Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. + * @param {string} password - Plain text user password. Must be at least 8 chars. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email?: string, phone?: string, password?: string, name?: string): Promise<Models.User<Preferences>>; + create<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email?: string, phone?: string, password?: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email?: string, phone?: string, password?: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email?: string, phone?: string, password?: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + phone: rest[1] as string, + password: rest[2] as string, + name: rest[3] as string + }; + } + + const userId = params.userId; + const email = params.email; + const phone = params.phone; + const password = params.password; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof phone !== 'undefined') { + payload['phone'] = phone; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using Argon2. + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + createArgon2User<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using Argon2. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createArgon2User<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>>; + createArgon2User<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + name: rest[2] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (typeof password === 'undefined') { + throw new AppwriteException('Missing required parameter: "password"'); + } + + const apiPath = '/users/argon2'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using Bcrypt. + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + createBcryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using Bcrypt. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createBcryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>>; + createBcryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + name: rest[2] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (typeof password === 'undefined') { + throw new AppwriteException('Missing required parameter: "password"'); + } + + const apiPath = '/users/bcrypt'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get identities for all users. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.IdentityList>} + */ + listIdentities(params?: { queries?: string[], search?: string, total?: boolean }): Promise<Models.IdentityList>; + /** + * Get identities for all users. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.IdentityList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listIdentities(queries?: string[], search?: string, total?: boolean): Promise<Models.IdentityList>; + listIdentities( + paramsOrFirst?: { queries?: string[], search?: string, total?: boolean } | string[], + ...rest: [(string)?, (boolean)?] + ): Promise<Models.IdentityList> { + let params: { queries?: string[], search?: string, total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], search?: string, total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + search: rest[0] as string, + total: rest[1] as boolean + }; + } + + const queries = params.queries; + const search = params.search; + const total = params.total; + + + const apiPath = '/users/identities'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete an identity by its unique ID. + * + * @param {string} params.identityId - Identity ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteIdentity(params: { identityId: string }): Promise<{}>; + /** + * Delete an identity by its unique ID. + * + * @param {string} identityId - Identity ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteIdentity(identityId: string): Promise<{}>; + deleteIdentity( + paramsOrFirst: { identityId: string } | string + ): Promise<{}> { + let params: { identityId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { identityId: string }; + } else { + params = { + identityId: paramsOrFirst as string + }; + } + + const identityId = params.identityId; + + if (typeof identityId === 'undefined') { + throw new AppwriteException('Missing required parameter: "identityId"'); + } + + const apiPath = '/users/identities/{identityId}'.replace('{identityId}', identityId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using MD5. + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + createMD5User<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using MD5. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMD5User<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>>; + createMD5User<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + name: rest[2] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (typeof password === 'undefined') { + throw new AppwriteException('Missing required parameter: "password"'); + } + + const apiPath = '/users/md5'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} params.userId - User ID. Choose a custom ID or pass the string `ID.unique()`to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using PHPass. + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + createPHPassUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or pass the string `ID.unique()`to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using PHPass. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createPHPassUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>>; + createPHPassUser<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + name: rest[2] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (typeof password === 'undefined') { + throw new AppwriteException('Missing required parameter: "password"'); + } + + const apiPath = '/users/phpass'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using Scrypt. + * @param {string} params.passwordSalt - Optional salt used to hash password. + * @param {number} params.passwordCpu - Optional CPU cost used to hash password. + * @param {number} params.passwordMemory - Optional memory cost used to hash password. + * @param {number} params.passwordParallel - Optional parallelization cost used to hash password. + * @param {number} params.passwordLength - Optional hash length used to hash password. + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + createScryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using Scrypt. + * @param {string} passwordSalt - Optional salt used to hash password. + * @param {number} passwordCpu - Optional CPU cost used to hash password. + * @param {number} passwordMemory - Optional memory cost used to hash password. + * @param {number} passwordParallel - Optional parallelization cost used to hash password. + * @param {number} passwordLength - Optional hash length used to hash password. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createScryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string): Promise<Models.User<Preferences>>; + createScryptUser<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (number)?, (number)?, (number)?, (number)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + passwordSalt: rest[2] as string, + passwordCpu: rest[3] as number, + passwordMemory: rest[4] as number, + passwordParallel: rest[5] as number, + passwordLength: rest[6] as number, + name: rest[7] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const passwordSalt = params.passwordSalt; + const passwordCpu = params.passwordCpu; + const passwordMemory = params.passwordMemory; + const passwordParallel = params.passwordParallel; + const passwordLength = params.passwordLength; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (typeof password === 'undefined') { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (typeof passwordSalt === 'undefined') { + throw new AppwriteException('Missing required parameter: "passwordSalt"'); + } + if (typeof passwordCpu === 'undefined') { + throw new AppwriteException('Missing required parameter: "passwordCpu"'); + } + if (typeof passwordMemory === 'undefined') { + throw new AppwriteException('Missing required parameter: "passwordMemory"'); + } + if (typeof passwordParallel === 'undefined') { + throw new AppwriteException('Missing required parameter: "passwordParallel"'); + } + if (typeof passwordLength === 'undefined') { + throw new AppwriteException('Missing required parameter: "passwordLength"'); + } + + const apiPath = '/users/scrypt'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof passwordSalt !== 'undefined') { + payload['passwordSalt'] = passwordSalt; + } + if (typeof passwordCpu !== 'undefined') { + payload['passwordCpu'] = passwordCpu; + } + if (typeof passwordMemory !== 'undefined') { + payload['passwordMemory'] = passwordMemory; + } + if (typeof passwordParallel !== 'undefined') { + payload['passwordParallel'] = passwordParallel; + } + if (typeof passwordLength !== 'undefined') { + payload['passwordLength'] = passwordLength; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using Scrypt Modified. + * @param {string} params.passwordSalt - Salt used to hash password. + * @param {string} params.passwordSaltSeparator - Salt separator used to hash password. + * @param {string} params.passwordSignerKey - Signer key used to hash password. + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + createScryptModifiedUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using Scrypt Modified. + * @param {string} passwordSalt - Salt used to hash password. + * @param {string} passwordSaltSeparator - Salt separator used to hash password. + * @param {string} passwordSignerKey - Signer key used to hash password. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createScryptModifiedUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string): Promise<Models.User<Preferences>>; + createScryptModifiedUser<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + passwordSalt: rest[2] as string, + passwordSaltSeparator: rest[3] as string, + passwordSignerKey: rest[4] as string, + name: rest[5] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const passwordSalt = params.passwordSalt; + const passwordSaltSeparator = params.passwordSaltSeparator; + const passwordSignerKey = params.passwordSignerKey; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (typeof password === 'undefined') { + throw new AppwriteException('Missing required parameter: "password"'); + } + if (typeof passwordSalt === 'undefined') { + throw new AppwriteException('Missing required parameter: "passwordSalt"'); + } + if (typeof passwordSaltSeparator === 'undefined') { + throw new AppwriteException('Missing required parameter: "passwordSaltSeparator"'); + } + if (typeof passwordSignerKey === 'undefined') { + throw new AppwriteException('Missing required parameter: "passwordSignerKey"'); + } + + const apiPath = '/users/scrypt-modified'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof passwordSalt !== 'undefined') { + payload['passwordSalt'] = passwordSalt; + } + if (typeof passwordSaltSeparator !== 'undefined') { + payload['passwordSaltSeparator'] = passwordSaltSeparator; + } + if (typeof passwordSignerKey !== 'undefined') { + payload['passwordSignerKey'] = passwordSignerKey; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.email - User email. + * @param {string} params.password - User password hashed using SHA. + * @param {PasswordHash} params.passwordVersion - Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512' + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + createSHAUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }): Promise<Models.User<Preferences>>; + /** + * Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} email - User email. + * @param {string} password - User password hashed using SHA. + * @param {PasswordHash} passwordVersion - Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512' + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSHAUser<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string): Promise<Models.User<Preferences>>; + createSHAUser<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string } | string, + ...rest: [(string)?, (string)?, (PasswordHash)?, (string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string, password: string, passwordVersion?: PasswordHash, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string, + password: rest[1] as string, + passwordVersion: rest[2] as PasswordHash, + name: rest[3] as string + }; + } + + const userId = params.userId; + const email = params.email; + const password = params.password; + const passwordVersion = params.passwordVersion; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); + } + if (typeof password === 'undefined') { + throw new AppwriteException('Missing required parameter: "password"'); + } + + const apiPath = '/users/sha'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof email !== 'undefined') { + payload['email'] = email; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof passwordVersion !== 'undefined') { + payload['passwordVersion'] = passwordVersion; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a user by its unique ID. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + get<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string }): Promise<Models.User<Preferences>>; + /** + * Get a user by its unique ID. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string): Promise<Models.User<Preferences>>; + get<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string } | string + ): Promise<Models.User<Preferences>> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { userId: string }): Promise<{}>; + /** + * Delete a user by its unique ID, thereby releasing it's ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(userId: string): Promise<{}>; + delete( + paramsOrFirst: { userId: string } | string + ): Promise<{}> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the user email by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.email - User email. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, email: string }): Promise<Models.User<Preferences>>; + /** + * Update the user email by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} email - User email. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, email: string): Promise<Models.User<Preferences>>; + updateEmail<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, email: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, email: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, email: string }; + } else { + params = { + userId: paramsOrFirst as string, + email: rest[0] as string + }; + } + + const userId = params.userId; + const email = params.email; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof email === 'undefined') { + throw new AppwriteException('Missing required parameter: "email"'); + } + + const apiPath = '/users/{userId}/email'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof email !== 'undefined') { + payload['email'] = email; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. + * + * + * @param {string} params.userId - User ID. + * @param {boolean} params.impersonator - Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateImpersonator<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, impersonator: boolean }): Promise<Models.User<Preferences>>; + /** + * Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. + * + * + * @param {string} userId - User ID. + * @param {boolean} impersonator - Whether the user can impersonate other users. When true, the user can browse project users to choose a target and can pass impersonation headers to act as that user. Internal audit logs still attribute impersonated actions to the original impersonator and store the target user details only in internal audit payload data. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateImpersonator<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, impersonator: boolean): Promise<Models.User<Preferences>>; + updateImpersonator<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, impersonator: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, impersonator: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, impersonator: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + impersonator: rest[0] as boolean + }; + } + + const userId = params.userId; + const impersonator = params.impersonator; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof impersonator === 'undefined') { + throw new AppwriteException('Missing required parameter: "impersonator"'); + } + + const apiPath = '/users/{userId}/impersonator'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof impersonator !== 'undefined') { + payload['impersonator'] = impersonator; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. + * + * @param {string} params.userId - User ID. + * @param {string} params.sessionId - Session ID. Use the string 'recent' to use the most recent session. Defaults to the most recent session. + * @param {number} params.duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Jwt>} + */ + createJWT(params: { userId: string, sessionId?: string, duration?: number }): Promise<Models.Jwt>; + /** + * Use this endpoint to create a JSON Web Token for user by its unique ID. You can use the resulting JWT to authenticate on behalf of the user. The JWT secret will become invalid if the session it uses gets deleted. + * + * @param {string} userId - User ID. + * @param {string} sessionId - Session ID. Use the string 'recent' to use the most recent session. Defaults to the most recent session. + * @param {number} duration - Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. + * @throws {AppwriteException} + * @returns {Promise<Models.Jwt>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createJWT(userId: string, sessionId?: string, duration?: number): Promise<Models.Jwt>; + createJWT( + paramsOrFirst: { userId: string, sessionId?: string, duration?: number } | string, + ...rest: [(string)?, (number)?] + ): Promise<Models.Jwt> { + let params: { userId: string, sessionId?: string, duration?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, sessionId?: string, duration?: number }; + } else { + params = { + userId: paramsOrFirst as string, + sessionId: rest[0] as string, + duration: rest[1] as number + }; + } + + const userId = params.userId; + const sessionId = params.sessionId; + const duration = params.duration; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/jwts'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof sessionId !== 'undefined') { + payload['sessionId'] = sessionId; + } + if (typeof duration !== 'undefined') { + payload['duration'] = duration; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the user labels by its unique ID. + * + * Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. + * + * @param {string} params.userId - User ID. + * @param {string[]} params.labels - Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateLabels<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, labels: string[] }): Promise<Models.User<Preferences>>; + /** + * Update the user labels by its unique ID. + * + * Labels can be used to grant access to resources. While teams are a way for user's to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info. + * + * @param {string} userId - User ID. + * @param {string[]} labels - Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateLabels<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, labels: string[]): Promise<Models.User<Preferences>>; + updateLabels<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, labels: string[] } | string, + ...rest: [(string[])?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, labels: string[] }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, labels: string[] }; + } else { + params = { + userId: paramsOrFirst as string, + labels: rest[0] as string[] + }; + } + + const userId = params.userId; + const labels = params.labels; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof labels === 'undefined') { + throw new AppwriteException('Missing required parameter: "labels"'); + } + + const apiPath = '/users/{userId}/labels'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof labels !== 'undefined') { + payload['labels'] = labels; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the user activity logs list by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + */ + listLogs(params: { userId: string, queries?: string[], total?: boolean }): Promise<Models.LogList>; + /** + * Get the user activity logs list by its unique ID. + * + * @param {string} userId - User ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.LogList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listLogs(userId: string, queries?: string[], total?: boolean): Promise<Models.LogList>; + listLogs( + paramsOrFirst: { userId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.LogList> { + let params: { userId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, queries?: string[], total?: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const userId = params.userId; + const queries = params.queries; + const total = params.total; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/logs'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the user membership list by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles + * @param {string} params.search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.MembershipList>} + */ + listMemberships(params: { userId: string, queries?: string[], search?: string, total?: boolean }): Promise<Models.MembershipList>; + /** + * Get the user membership list by its unique ID. + * + * @param {string} userId - User ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles + * @param {string} search - Search term to filter your list results. Max length: 256 chars. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.MembershipList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listMemberships(userId: string, queries?: string[], search?: string, total?: boolean): Promise<Models.MembershipList>; + listMemberships( + paramsOrFirst: { userId: string, queries?: string[], search?: string, total?: boolean } | string, + ...rest: [(string[])?, (string)?, (boolean)?] + ): Promise<Models.MembershipList> { + let params: { userId: string, queries?: string[], search?: string, total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, queries?: string[], search?: string, total?: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + queries: rest[0] as string[], + search: rest[1] as string, + total: rest[2] as boolean + }; + } + + const userId = params.userId; + const queries = params.queries; + const search = params.search; + const total = params.total; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/memberships'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof search !== 'undefined') { + payload['search'] = search; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Enable or disable MFA on a user account. + * + * @param {string} params.userId - User ID. + * @param {boolean} params.mfa - Enable or disable MFA. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.updateMFA` instead. + */ + updateMfa<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, mfa: boolean }): Promise<Models.User<Preferences>>; + /** + * Enable or disable MFA on a user account. + * + * @param {string} userId - User ID. + * @param {boolean} mfa - Enable or disable MFA. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMfa<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, mfa: boolean): Promise<Models.User<Preferences>>; + updateMfa<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, mfa: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, mfa: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, mfa: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + mfa: rest[0] as boolean + }; + } + + const userId = params.userId; + const mfa = params.mfa; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof mfa === 'undefined') { + throw new AppwriteException('Missing required parameter: "mfa"'); + } + + const apiPath = '/users/{userId}/mfa'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof mfa !== 'undefined') { + payload['mfa'] = mfa; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete an authenticator app. + * + * @param {string} params.userId - User ID. + * @param {AuthenticatorType} params.type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.deleteMFAAuthenticator` instead. + */ + deleteMfaAuthenticator(params: { userId: string, type: AuthenticatorType }): Promise<{}>; + /** + * Delete an authenticator app. + * + * @param {string} userId - User ID. + * @param {AuthenticatorType} type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteMfaAuthenticator(userId: string, type: AuthenticatorType): Promise<{}>; + deleteMfaAuthenticator( + paramsOrFirst: { userId: string, type: AuthenticatorType } | string, + ...rest: [(AuthenticatorType)?] + ): Promise<{}> { + let params: { userId: string, type: AuthenticatorType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, type: AuthenticatorType }; + } else { + params = { + userId: paramsOrFirst as string, + type: rest[0] as AuthenticatorType + }; + } + + const userId = params.userId; + const type = params.type; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', userId).replace('{type}', type); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * List the factors available on the account to be used as a MFA challange. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaFactors>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.listMFAFactors` instead. + */ + listMfaFactors(params: { userId: string }): Promise<Models.MfaFactors>; + /** + * List the factors available on the account to be used as a MFA challange. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaFactors>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listMfaFactors(userId: string): Promise<Models.MfaFactors>; + listMfaFactors( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaFactors> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.getMFARecoveryCodes` instead. + */ + getMfaRecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + getMfaRecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.updateMFARecoveryCodes` instead. + */ + updateMfaRecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + updateMfaRecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Users.createMFARecoveryCodes` instead. + */ + createMfaRecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMfaRecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + createMfaRecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the user name by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, name: string }): Promise<Models.User<Preferences>>; + /** + * Update the user name by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} name - User name. Max length: 128 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, name: string): Promise<Models.User<Preferences>>; + updateName<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, name: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, name: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, name: string }; + } else { + params = { + userId: paramsOrFirst as string, + name: rest[0] as string + }; + } + + const userId = params.userId; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/users/{userId}/name'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the user password by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.password - New user password. Must be at least 8 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, password: string }): Promise<Models.User<Preferences>>; + /** + * Update the user password by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} password - New user password. Must be at least 8 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, password: string): Promise<Models.User<Preferences>>; + updatePassword<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, password: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, password: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, password: string }; + } else { + params = { + userId: paramsOrFirst as string, + password: rest[0] as string + }; + } + + const userId = params.userId; + const password = params.password; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof password === 'undefined') { + throw new AppwriteException('Missing required parameter: "password"'); + } + + const apiPath = '/users/{userId}/password'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof password !== 'undefined') { + payload['password'] = password; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the user phone by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.number - User phone number. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, number: string }): Promise<Models.User<Preferences>>; + /** + * Update the user phone by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} number - User phone number. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, number: string): Promise<Models.User<Preferences>>; + updatePhone<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, number: string } | string, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, number: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, number: string }; + } else { + params = { + userId: paramsOrFirst as string, + number: rest[0] as string + }; + } + + const userId = params.userId; + const number = params.number; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof number === 'undefined') { + throw new AppwriteException('Missing required parameter: "number"'); + } + + const apiPath = '/users/{userId}/phone'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof number !== 'undefined') { + payload['number'] = number; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the user preferences by its unique ID. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Preferences>} + */ + getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string }): Promise<Preferences>; + /** + * Get the user preferences by its unique ID. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Preferences>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string): Promise<Preferences>; + getPrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string } | string + ): Promise<Preferences> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/prefs'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. + * + * @param {string} params.userId - User ID. + * @param {object} params.prefs - Prefs key-value JSON object. + * @throws {AppwriteException} + * @returns {Promise<Preferences>} + */ + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, prefs: object }): Promise<Preferences>; + /** + * Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded. + * + * @param {string} userId - User ID. + * @param {object} prefs - Prefs key-value JSON object. + * @throws {AppwriteException} + * @returns {Promise<Preferences>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, prefs: object): Promise<Preferences>; + updatePrefs<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, prefs: object } | string, + ...rest: [(object)?] + ): Promise<Preferences> { + let params: { userId: string, prefs: object }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, prefs: object }; + } else { + params = { + userId: paramsOrFirst as string, + prefs: rest[0] as object + }; + } + + const userId = params.userId; + const prefs = params.prefs; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof prefs === 'undefined') { + throw new AppwriteException('Missing required parameter: "prefs"'); + } + + const apiPath = '/users/{userId}/prefs'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof prefs !== 'undefined') { + payload['prefs'] = prefs; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Get the user sessions list by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.SessionList>} + */ + listSessions(params: { userId: string, total?: boolean }): Promise<Models.SessionList>; + /** + * Get the user sessions list by its unique ID. + * + * @param {string} userId - User ID. + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.SessionList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listSessions(userId: string, total?: boolean): Promise<Models.SessionList>; + listSessions( + paramsOrFirst: { userId: string, total?: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.SessionList> { + let params: { userId: string, total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, total?: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + total: rest[0] as boolean + }; + } + + const userId = params.userId; + const total = params.total; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Creates a session for a user. Returns an immediately usable session object. + * + * If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint. + * + * @param {string} params.userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + */ + createSession(params: { userId: string }): Promise<Models.Session>; + /** + * Creates a session for a user. Returns an immediately usable session object. + * + * If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint. + * + * @param {string} userId - User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSession(userId: string): Promise<Models.Session>; + createSession( + paramsOrFirst: { userId: string } | string + ): Promise<Models.Session> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete all user's sessions by using the user's unique ID. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteSessions(params: { userId: string }): Promise<{}>; + /** + * Delete all user's sessions by using the user's unique ID. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteSessions(userId: string): Promise<{}>; + deleteSessions( + paramsOrFirst: { userId: string } | string + ): Promise<{}> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a user sessions by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.sessionId - Session ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteSession(params: { userId: string, sessionId: string }): Promise<{}>; + /** + * Delete a user sessions by its unique ID. + * + * @param {string} userId - User ID. + * @param {string} sessionId - Session ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteSession(userId: string, sessionId: string): Promise<{}>; + deleteSession( + paramsOrFirst: { userId: string, sessionId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { userId: string, sessionId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, sessionId: string }; + } else { + params = { + userId: paramsOrFirst as string, + sessionId: rest[0] as string + }; + } + + const userId = params.userId; + const sessionId = params.sessionId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof sessionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + + const apiPath = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. + * + * @param {string} params.userId - User ID. + * @param {boolean} params.status - User Status. To activate the user pass `true` and to block the user pass `false`. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateStatus<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, status: boolean }): Promise<Models.User<Preferences>>; + /** + * Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user's ID reserved. + * + * @param {string} userId - User ID. + * @param {boolean} status - User Status. To activate the user pass `true` and to block the user pass `false`. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateStatus<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, status: boolean): Promise<Models.User<Preferences>>; + updateStatus<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, status: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, status: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, status: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + status: rest[0] as boolean + }; + } + + const userId = params.userId; + const status = params.status; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof status === 'undefined') { + throw new AppwriteException('Missing required parameter: "status"'); + } + + const apiPath = '/users/{userId}/status'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof status !== 'undefined') { + payload['status'] = status; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * List the messaging targets that are associated with a user. + * + * @param {string} params.userId - User ID. + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.TargetList>} + */ + listTargets(params: { userId: string, queries?: string[], total?: boolean }): Promise<Models.TargetList>; + /** + * List the messaging targets that are associated with a user. + * + * @param {string} userId - User ID. + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.TargetList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listTargets(userId: string, queries?: string[], total?: boolean): Promise<Models.TargetList>; + listTargets( + paramsOrFirst: { userId: string, queries?: string[], total?: boolean } | string, + ...rest: [(string[])?, (boolean)?] + ): Promise<Models.TargetList> { + let params: { userId: string, queries?: string[], total?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, queries?: string[], total?: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + queries: rest[0] as string[], + total: rest[1] as boolean + }; + } + + const userId = params.userId; + const queries = params.queries; + const total = params.total; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/targets'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a messaging target. + * + * @param {string} params.userId - User ID. + * @param {string} params.targetId - Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {MessagingProviderType} params.providerType - The target provider type. Can be one of the following: `email`, `sms` or `push`. + * @param {string} params.identifier - The target identifier (token, email, phone etc.) + * @param {string} params.providerId - Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @param {string} params.name - Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. + * @throws {AppwriteException} + * @returns {Promise<Models.Target>} + */ + createTarget(params: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }): Promise<Models.Target>; + /** + * Create a messaging target. + * + * @param {string} userId - User ID. + * @param {string} targetId - Target ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {MessagingProviderType} providerType - The target provider type. Can be one of the following: `email`, `sms` or `push`. + * @param {string} identifier - The target identifier (token, email, phone etc.) + * @param {string} providerId - Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @param {string} name - Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. + * @throws {AppwriteException} + * @returns {Promise<Models.Target>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createTarget(userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string): Promise<Models.Target>; + createTarget( + paramsOrFirst: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string } | string, + ...rest: [(string)?, (MessagingProviderType)?, (string)?, (string)?, (string)?] + ): Promise<Models.Target> { + let params: { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, targetId: string, providerType: MessagingProviderType, identifier: string, providerId?: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + targetId: rest[0] as string, + providerType: rest[1] as MessagingProviderType, + identifier: rest[2] as string, + providerId: rest[3] as string, + name: rest[4] as string + }; + } + + const userId = params.userId; + const targetId = params.targetId; + const providerType = params.providerType; + const identifier = params.identifier; + const providerId = params.providerId; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof targetId === 'undefined') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + if (typeof providerType === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerType"'); + } + if (typeof identifier === 'undefined') { + throw new AppwriteException('Missing required parameter: "identifier"'); + } + + const apiPath = '/users/{userId}/targets'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof targetId !== 'undefined') { + payload['targetId'] = targetId; + } + if (typeof providerType !== 'undefined') { + payload['providerType'] = providerType; + } + if (typeof identifier !== 'undefined') { + payload['identifier'] = identifier; + } + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a user's push notification target by ID. + * + * @param {string} params.userId - User ID. + * @param {string} params.targetId - Target ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Target>} + */ + getTarget(params: { userId: string, targetId: string }): Promise<Models.Target>; + /** + * Get a user's push notification target by ID. + * + * @param {string} userId - User ID. + * @param {string} targetId - Target ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Target>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getTarget(userId: string, targetId: string): Promise<Models.Target>; + getTarget( + paramsOrFirst: { userId: string, targetId: string } | string, + ...rest: [(string)?] + ): Promise<Models.Target> { + let params: { userId: string, targetId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, targetId: string }; + } else { + params = { + userId: paramsOrFirst as string, + targetId: rest[0] as string + }; + } + + const userId = params.userId; + const targetId = params.targetId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof targetId === 'undefined') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + + const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a messaging target. + * + * @param {string} params.userId - User ID. + * @param {string} params.targetId - Target ID. + * @param {string} params.identifier - The target identifier (token, email, phone etc.) + * @param {string} params.providerId - Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @param {string} params.name - Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. + * @throws {AppwriteException} + * @returns {Promise<Models.Target>} + */ + updateTarget(params: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }): Promise<Models.Target>; + /** + * Update a messaging target. + * + * @param {string} userId - User ID. + * @param {string} targetId - Target ID. + * @param {string} identifier - The target identifier (token, email, phone etc.) + * @param {string} providerId - Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used. + * @param {string} name - Target name. Max length: 128 chars. For example: My Awesome App Galaxy S23. + * @throws {AppwriteException} + * @returns {Promise<Models.Target>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateTarget(userId: string, targetId: string, identifier?: string, providerId?: string, name?: string): Promise<Models.Target>; + updateTarget( + paramsOrFirst: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?] + ): Promise<Models.Target> { + let params: { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, targetId: string, identifier?: string, providerId?: string, name?: string }; + } else { + params = { + userId: paramsOrFirst as string, + targetId: rest[0] as string, + identifier: rest[1] as string, + providerId: rest[2] as string, + name: rest[3] as string + }; + } + + const userId = params.userId; + const targetId = params.targetId; + const identifier = params.identifier; + const providerId = params.providerId; + const name = params.name; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof targetId === 'undefined') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + + const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); + const payload: Payload = {}; + if (typeof identifier !== 'undefined') { + payload['identifier'] = identifier; + } + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a messaging target. + * + * @param {string} params.userId - User ID. + * @param {string} params.targetId - Target ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteTarget(params: { userId: string, targetId: string }): Promise<{}>; + /** + * Delete a messaging target. + * + * @param {string} userId - User ID. + * @param {string} targetId - Target ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteTarget(userId: string, targetId: string): Promise<{}>; + deleteTarget( + paramsOrFirst: { userId: string, targetId: string } | string, + ...rest: [(string)?] + ): Promise<{}> { + let params: { userId: string, targetId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, targetId: string }; + } else { + params = { + userId: paramsOrFirst as string, + targetId: rest[0] as string + }; + } + + const userId = params.userId; + const targetId = params.targetId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof targetId === 'undefined') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + + const apiPath = '/users/{userId}/targets/{targetId}'.replace('{userId}', userId).replace('{targetId}', targetId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. + * + * + * @param {string} params.userId - User ID. + * @param {number} params.length - Token length in characters. The default length is 6 characters + * @param {number} params.expire - Token expiration period in seconds. The default expiration is 15 minutes. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + */ + createToken(params: { userId: string, length?: number, expire?: number }): Promise<Models.Token>; + /** + * Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. + * + * + * @param {string} userId - User ID. + * @param {number} length - Token length in characters. The default length is 6 characters + * @param {number} expire - Token expiration period in seconds. The default expiration is 15 minutes. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createToken(userId: string, length?: number, expire?: number): Promise<Models.Token>; + createToken( + paramsOrFirst: { userId: string, length?: number, expire?: number } | string, + ...rest: [(number)?, (number)?] + ): Promise<Models.Token> { + let params: { userId: string, length?: number, expire?: number }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, length?: number, expire?: number }; + } else { + params = { + userId: paramsOrFirst as string, + length: rest[0] as number, + expire: rest[1] as number + }; + } + + const userId = params.userId; + const length = params.length; + const expire = params.expire; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/tokens'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof length !== 'undefined') { + payload['length'] = length; + } + if (typeof expire !== 'undefined') { + payload['expire'] = expire; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the user email verification status by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {boolean} params.emailVerification - User email verification status. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateEmailVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, emailVerification: boolean }): Promise<Models.User<Preferences>>; + /** + * Update the user email verification status by its unique ID. + * + * @param {string} userId - User ID. + * @param {boolean} emailVerification - User email verification status. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateEmailVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, emailVerification: boolean): Promise<Models.User<Preferences>>; + updateEmailVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, emailVerification: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, emailVerification: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, emailVerification: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + emailVerification: rest[0] as boolean + }; + } + + const userId = params.userId; + const emailVerification = params.emailVerification; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof emailVerification === 'undefined') { + throw new AppwriteException('Missing required parameter: "emailVerification"'); + } + + const apiPath = '/users/{userId}/verification'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof emailVerification !== 'undefined') { + payload['emailVerification'] = emailVerification; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the user phone verification status by its unique ID. + * + * @param {string} params.userId - User ID. + * @param {boolean} params.phoneVerification - User phone verification status. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updatePhoneVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, phoneVerification: boolean }): Promise<Models.User<Preferences>>; + /** + * Update the user phone verification status by its unique ID. + * + * @param {string} userId - User ID. + * @param {boolean} phoneVerification - User phone verification status. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updatePhoneVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, phoneVerification: boolean): Promise<Models.User<Preferences>>; + updatePhoneVerification<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, phoneVerification: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, phoneVerification: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, phoneVerification: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + phoneVerification: rest[0] as boolean + }; + } + + const userId = params.userId; + const phoneVerification = params.phoneVerification; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof phoneVerification === 'undefined') { + throw new AppwriteException('Missing required parameter: "phoneVerification"'); + } + + const apiPath = '/users/{userId}/verification/phone'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof phoneVerification !== 'undefined') { + payload['phoneVerification'] = phoneVerification; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } +} + +const Users = UsersRuntime as unknown as { + new (client: Client<ServerAuth>): Users; +}; + +export { Users }; diff --git a/src/services/webhooks.ts b/src/services/webhooks.ts new file mode 100644 index 00000000..4347018b --- /dev/null +++ b/src/services/webhooks.ts @@ -0,0 +1,473 @@ +import { AppwriteException, Client, type ServerAuth, type Payload } from '../client'; +import type { Models } from '../models'; + + +export type Webhooks = Omit<WebhooksRuntime, 'client'>; + +class WebhooksRuntime { + client: Client<ServerAuth>; + + constructor(client: Client<ServerAuth>) { + this.client = client; + } + + /** + * Get a list of all webhooks belonging to the project. You can use the query params to filter your results. + * + * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, authUsername, tls, events, enabled, logs, attempts + * @param {boolean} params.total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WebhookList>} + */ + list(params?: { queries?: string[], total?: boolean }): Promise<Models.WebhookList>; + /** + * Get a list of all webhooks belonging to the project. You can use the query params to filter your results. + * + * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, authUsername, tls, events, enabled, logs, attempts + * @param {boolean} total - When set to false, the total count returned will be 0 and will not be calculated. + * @throws {AppwriteException} + * @returns {Promise<Models.WebhookList>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + list(queries?: string[], total?: boolean): Promise<Models.WebhookList>; + list( + paramsOrFirst?: { queries?: string[], total?: boolean } | string[], + ...rest: [(boolean)?] + ): Promise<Models.WebhookList> { + let params: { queries?: string[], total?: boolean }; + + if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { queries?: string[], total?: boolean }; + } else { + params = { + queries: paramsOrFirst as string[], + total: rest[0] as boolean + }; + } + + const queries = params.queries; + const total = params.total; + + + const apiPath = '/webhooks'; + const payload: Payload = {}; + if (typeof queries !== 'undefined') { + payload['queries'] = queries; + } + if (typeof total !== 'undefined') { + payload['total'] = total; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. + * + * @param {string} params.webhookId - Webhook ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.url - Webhook URL. + * @param {string} params.name - Webhook name. Max length: 128 chars. + * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. + * @param {boolean} params.enabled - Enable or disable a webhook. + * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. + * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @throws {AppwriteException} + * @returns {Promise<Models.Webhook>} + */ + create(params: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string }): Promise<Models.Webhook>; + /** + * Create a new webhook. Use this endpoint to configure a URL that will receive events from Appwrite when specific events occur. + * + * @param {string} webhookId - Webhook ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} url - Webhook URL. + * @param {string} name - Webhook name. Max length: 128 chars. + * @param {string[]} events - Events list. Maximum of 100 events are allowed. + * @param {boolean} enabled - Enable or disable a webhook. + * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. + * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. + * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @throws {AppwriteException} + * @returns {Promise<Models.Webhook>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + create(webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string): Promise<Models.Webhook>; + create( + paramsOrFirst: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (string)?, (string)?, (string)?] + ): Promise<Models.Webhook> { + let params: { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { webhookId: string, url: string, name: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string, secret?: string }; + } else { + params = { + webhookId: paramsOrFirst as string, + url: rest[0] as string, + name: rest[1] as string, + events: rest[2] as string[], + enabled: rest[3] as boolean, + tls: rest[4] as boolean, + authUsername: rest[5] as string, + authPassword: rest[6] as string, + secret: rest[7] as string + }; + } + + const webhookId = params.webhookId; + const url = params.url; + const name = params.name; + const events = params.events; + const enabled = params.enabled; + const tls = params.tls; + const authUsername = params.authUsername; + const authPassword = params.authPassword; + const secret = params.secret; + + if (typeof webhookId === 'undefined') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + if (typeof url === 'undefined') { + throw new AppwriteException('Missing required parameter: "url"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof events === 'undefined') { + throw new AppwriteException('Missing required parameter: "events"'); + } + + const apiPath = '/webhooks'; + const payload: Payload = {}; + if (typeof webhookId !== 'undefined') { + payload['webhookId'] = webhookId; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof events !== 'undefined') { + payload['events'] = events; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof tls !== 'undefined') { + payload['tls'] = tls; + } + if (typeof authUsername !== 'undefined') { + payload['authUsername'] = authUsername; + } + if (typeof authPassword !== 'undefined') { + payload['authPassword'] = authPassword; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. + * + * @param {string} params.webhookId - Webhook ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Webhook>} + */ + get(params: { webhookId: string }): Promise<Models.Webhook>; + /** + * Get a webhook by its unique ID. This endpoint returns details about a specific webhook configured for a project. + * + * @param {string} webhookId - Webhook ID. + * @throws {AppwriteException} + * @returns {Promise<Models.Webhook>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + get(webhookId: string): Promise<Models.Webhook>; + get( + paramsOrFirst: { webhookId: string } | string + ): Promise<Models.Webhook> { + let params: { webhookId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { webhookId: string }; + } else { + params = { + webhookId: paramsOrFirst as string + }; + } + + const webhookId = params.webhookId; + + if (typeof webhookId === 'undefined') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + + const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', webhookId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. + * + * @param {string} params.webhookId - Webhook ID. + * @param {string} params.name - Webhook name. Max length: 128 chars. + * @param {string} params.url - Webhook URL. + * @param {string[]} params.events - Events list. Maximum of 100 events are allowed. + * @param {boolean} params.enabled - Enable or disable a webhook. + * @param {boolean} params.tls - Certificate verification, false for disabled or true for enabled. + * @param {string} params.authUsername - Webhook HTTP user. Max length: 256 chars. + * @param {string} params.authPassword - Webhook HTTP password. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Webhook>} + */ + update(params: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string }): Promise<Models.Webhook>; + /** + * Update a webhook by its unique ID. Use this endpoint to update the URL, events, or status of an existing webhook. + * + * @param {string} webhookId - Webhook ID. + * @param {string} name - Webhook name. Max length: 128 chars. + * @param {string} url - Webhook URL. + * @param {string[]} events - Events list. Maximum of 100 events are allowed. + * @param {boolean} enabled - Enable or disable a webhook. + * @param {boolean} tls - Certificate verification, false for disabled or true for enabled. + * @param {string} authUsername - Webhook HTTP user. Max length: 256 chars. + * @param {string} authPassword - Webhook HTTP password. Max length: 256 chars. + * @throws {AppwriteException} + * @returns {Promise<Models.Webhook>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update(webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string): Promise<Models.Webhook>; + update( + paramsOrFirst: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string } | string, + ...rest: [(string)?, (string)?, (string[])?, (boolean)?, (boolean)?, (string)?, (string)?] + ): Promise<Models.Webhook> { + let params: { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { webhookId: string, name: string, url: string, events: string[], enabled?: boolean, tls?: boolean, authUsername?: string, authPassword?: string }; + } else { + params = { + webhookId: paramsOrFirst as string, + name: rest[0] as string, + url: rest[1] as string, + events: rest[2] as string[], + enabled: rest[3] as boolean, + tls: rest[4] as boolean, + authUsername: rest[5] as string, + authPassword: rest[6] as string + }; + } + + const webhookId = params.webhookId; + const name = params.name; + const url = params.url; + const events = params.events; + const enabled = params.enabled; + const tls = params.tls; + const authUsername = params.authUsername; + const authPassword = params.authPassword; + + if (typeof webhookId === 'undefined') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof url === 'undefined') { + throw new AppwriteException('Missing required parameter: "url"'); + } + if (typeof events === 'undefined') { + throw new AppwriteException('Missing required parameter: "events"'); + } + + const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', webhookId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof url !== 'undefined') { + payload['url'] = url; + } + if (typeof events !== 'undefined') { + payload['events'] = events; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof tls !== 'undefined') { + payload['tls'] = tls; + } + if (typeof authUsername !== 'undefined') { + payload['authUsername'] = authUsername; + } + if (typeof authPassword !== 'undefined') { + payload['authPassword'] = authPassword; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. + * + * @param {string} params.webhookId - Webhook ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + delete(params: { webhookId: string }): Promise<{}>; + /** + * Delete a webhook by its unique ID. Once deleted, the webhook will no longer receive project events. + * + * @param {string} webhookId - Webhook ID. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + delete(webhookId: string): Promise<{}>; + delete( + paramsOrFirst: { webhookId: string } | string + ): Promise<{}> { + let params: { webhookId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { webhookId: string }; + } else { + params = { + webhookId: paramsOrFirst as string + }; + } + + const webhookId = params.webhookId; + + if (typeof webhookId === 'undefined') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + + const apiPath = '/webhooks/{webhookId}'.replace('{webhookId}', webhookId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + + /** + * Update the webhook signing key. This endpoint can be used to regenerate the signing key used to sign and validate payload deliveries for a specific webhook. + * + * @param {string} params.webhookId - Webhook ID. + * @param {string} params.secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @throws {AppwriteException} + * @returns {Promise<Models.Webhook>} + */ + updateSecret(params: { webhookId: string, secret?: string }): Promise<Models.Webhook>; + /** + * Update the webhook signing key. This endpoint can be used to regenerate the signing key used to sign and validate payload deliveries for a specific webhook. + * + * @param {string} webhookId - Webhook ID. + * @param {string} secret - Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. + * @throws {AppwriteException} + * @returns {Promise<Models.Webhook>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSecret(webhookId: string, secret?: string): Promise<Models.Webhook>; + updateSecret( + paramsOrFirst: { webhookId: string, secret?: string } | string, + ...rest: [(string)?] + ): Promise<Models.Webhook> { + let params: { webhookId: string, secret?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { webhookId: string, secret?: string }; + } else { + params = { + webhookId: paramsOrFirst as string, + secret: rest[0] as string + }; + } + + const webhookId = params.webhookId; + const secret = params.secret; + + if (typeof webhookId === 'undefined') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + + const apiPath = '/webhooks/{webhookId}/secret'.replace('{webhookId}', webhookId); + const payload: Payload = {}; + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } +} + +const Webhooks = WebhooksRuntime as unknown as { + new (client: Client<ServerAuth>): Webhooks; +}; + +export { Webhooks }; From be1797af99b203c56976a31f6b973afba079179e Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal <chiragaggarwal5k@gmail.com> Date: Tue, 19 May 2026 14:53:06 +0530 Subject: [PATCH 2/2] chore: update Web SDK to 26.0.0 --- .../account/create-mfa-authenticator.md | 2 +- docs/examples/account/create-mfa-challenge.md | 2 +- .../account/create-mfa-recovery-codes.md | 2 +- docs/examples/account/create-verification.md | 15 + .../account/delete-mfa-authenticator.md | 2 +- .../account/get-mfa-recovery-codes.md | 2 +- docs/examples/account/list-mfa-factors.md | 2 +- .../account/update-mfa-authenticator.md | 2 +- docs/examples/account/update-mfa-challenge.md | 2 +- .../account/update-mfa-recovery-codes.md | 2 +- docs/examples/account/update-verification.md | 16 + docs/examples/databases/create-document.md | 5 +- docs/examples/databases/create-documents.md | 18 + .../messaging/create-apns-provider.md | 2 +- .../examples/messaging/create-fcm-provider.md | 2 +- docs/examples/messaging/create-sms.md | 2 +- .../messaging/create-smtp-provider.md | 2 +- .../messaging/update-apns-provider.md | 2 +- .../examples/messaging/update-fcm-provider.md | 2 +- docs/examples/messaging/update-sms.md | 2 +- .../messaging/update-smtp-provider.md | 2 +- docs/examples/presences/update-presence.md | 21 + docs/examples/presences/update.md | 1 - docs/examples/presences/upsert.md | 2 +- docs/examples/tablesdb/create-row.md | 5 +- docs/examples/tablesdb/create-rows.md | 18 + .../users/create-mfa-recovery-codes.md | 2 +- .../users/delete-mfa-authenticator.md | 2 +- docs/examples/users/get-mfa-recovery-codes.md | 2 +- docs/examples/users/list-mfa-factors.md | 2 +- .../users/update-mfa-recovery-codes.md | 2 +- docs/examples/users/update-mfa.md | 2 +- src/services/account.ts | 511 ++++++++ src/services/databases.ts | 99 +- src/services/messaging.ts | 1149 ++++++++++++++--- src/services/presences.ts | 214 ++- src/services/tables-db.ts | 98 +- src/services/users.ts | 329 +++++ 38 files changed, 2333 insertions(+), 214 deletions(-) create mode 100644 docs/examples/account/create-verification.md create mode 100644 docs/examples/account/update-verification.md create mode 100644 docs/examples/databases/create-documents.md create mode 100644 docs/examples/presences/update-presence.md create mode 100644 docs/examples/tablesdb/create-rows.md diff --git a/docs/examples/account/create-mfa-authenticator.md b/docs/examples/account/create-mfa-authenticator.md index df016baf..cf6a6098 100644 --- a/docs/examples/account/create-mfa-authenticator.md +++ b/docs/examples/account/create-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.createMfaAuthenticator({ +const result = await account.createMFAAuthenticator({ type: AuthenticatorType.Totp }); diff --git a/docs/examples/account/create-mfa-challenge.md b/docs/examples/account/create-mfa-challenge.md index 03c03be3..d9d9856d 100644 --- a/docs/examples/account/create-mfa-challenge.md +++ b/docs/examples/account/create-mfa-challenge.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.createMfaChallenge({ +const result = await account.createMFAChallenge({ factor: AuthenticationFactor.Email }); diff --git a/docs/examples/account/create-mfa-recovery-codes.md b/docs/examples/account/create-mfa-recovery-codes.md index 42aa7ac0..3c292f26 100644 --- a/docs/examples/account/create-mfa-recovery-codes.md +++ b/docs/examples/account/create-mfa-recovery-codes.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.createMfaRecoveryCodes(); +const result = await account.createMFARecoveryCodes(); console.log(result); ``` diff --git a/docs/examples/account/create-verification.md b/docs/examples/account/create-verification.md new file mode 100644 index 00000000..0795d0ac --- /dev/null +++ b/docs/examples/account/create-verification.md @@ -0,0 +1,15 @@ +```javascript +import { Client, Account } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const account = new Account(client); + +const result = await account.createVerification({ + url: 'https://example.com' +}); + +console.log(result); +``` diff --git a/docs/examples/account/delete-mfa-authenticator.md b/docs/examples/account/delete-mfa-authenticator.md index 626b4172..079f0b95 100644 --- a/docs/examples/account/delete-mfa-authenticator.md +++ b/docs/examples/account/delete-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.deleteMfaAuthenticator({ +const result = await account.deleteMFAAuthenticator({ type: AuthenticatorType.Totp }); diff --git a/docs/examples/account/get-mfa-recovery-codes.md b/docs/examples/account/get-mfa-recovery-codes.md index a2bca114..1d102583 100644 --- a/docs/examples/account/get-mfa-recovery-codes.md +++ b/docs/examples/account/get-mfa-recovery-codes.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.getMfaRecoveryCodes(); +const result = await account.getMFARecoveryCodes(); console.log(result); ``` diff --git a/docs/examples/account/list-mfa-factors.md b/docs/examples/account/list-mfa-factors.md index 63148467..9950129b 100644 --- a/docs/examples/account/list-mfa-factors.md +++ b/docs/examples/account/list-mfa-factors.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.listMfaFactors(); +const result = await account.listMFAFactors(); console.log(result); ``` diff --git a/docs/examples/account/update-mfa-authenticator.md b/docs/examples/account/update-mfa-authenticator.md index 7aa949c7..bf25c76b 100644 --- a/docs/examples/account/update-mfa-authenticator.md +++ b/docs/examples/account/update-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.updateMfaAuthenticator({ +const result = await account.updateMFAAuthenticator({ type: AuthenticatorType.Totp, otp: '<OTP>' }); diff --git a/docs/examples/account/update-mfa-challenge.md b/docs/examples/account/update-mfa-challenge.md index 34e5b267..a16ea43a 100644 --- a/docs/examples/account/update-mfa-challenge.md +++ b/docs/examples/account/update-mfa-challenge.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.updateMfaChallenge({ +const result = await account.updateMFAChallenge({ challengeId: '<CHALLENGE_ID>', otp: '<OTP>' }); diff --git a/docs/examples/account/update-mfa-recovery-codes.md b/docs/examples/account/update-mfa-recovery-codes.md index 3d22c889..8bc8273c 100644 --- a/docs/examples/account/update-mfa-recovery-codes.md +++ b/docs/examples/account/update-mfa-recovery-codes.md @@ -7,7 +7,7 @@ const client = new Client() const account = new Account(client); -const result = await account.updateMfaRecoveryCodes(); +const result = await account.updateMFARecoveryCodes(); console.log(result); ``` diff --git a/docs/examples/account/update-verification.md b/docs/examples/account/update-verification.md new file mode 100644 index 00000000..3b52a83c --- /dev/null +++ b/docs/examples/account/update-verification.md @@ -0,0 +1,16 @@ +```javascript +import { Client, Account } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const account = new Account(client); + +const result = await account.updateVerification({ + userId: '<USER_ID>', + secret: '<SECRET>' +}); + +console.log(result); +``` diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index eff84945..4d8d7f90 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -10,16 +10,15 @@ const databases = new Databases(client); const result = await databases.createDocument({ databaseId: '<DATABASE_ID>', collectionId: '<COLLECTION_ID>', - documentId: '<DOCUMENT_ID>', // optional + documentId: '<DOCUMENT_ID>', data: { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 30, "isAdmin": false - }, // optional + }, permissions: [Permission.read(Role.any())], // optional - documents: [], // optional transactionId: '<TRANSACTION_ID>' // optional }); diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md new file mode 100644 index 00000000..cd94cc96 --- /dev/null +++ b/docs/examples/databases/create-documents.md @@ -0,0 +1,18 @@ +```javascript +import { Client, Databases } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const databases = new Databases(client); + +const result = await databases.createDocuments({ + databaseId: '<DATABASE_ID>', + collectionId: '<COLLECTION_ID>', + documents: [], + transactionId: '<TRANSACTION_ID>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/messaging/create-apns-provider.md b/docs/examples/messaging/create-apns-provider.md index 5859a952..eeb8f955 100644 --- a/docs/examples/messaging/create-apns-provider.md +++ b/docs/examples/messaging/create-apns-provider.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const result = await messaging.createApnsProvider({ +const result = await messaging.createAPNSProvider({ providerId: '<PROVIDER_ID>', name: '<NAME>', authKey: '<AUTH_KEY>', // optional diff --git a/docs/examples/messaging/create-fcm-provider.md b/docs/examples/messaging/create-fcm-provider.md index aba9af52..1b3a13a2 100644 --- a/docs/examples/messaging/create-fcm-provider.md +++ b/docs/examples/messaging/create-fcm-provider.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const result = await messaging.createFcmProvider({ +const result = await messaging.createFCMProvider({ providerId: '<PROVIDER_ID>', name: '<NAME>', serviceAccountJSON: {}, // optional diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 152b0542..b5093eb4 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const result = await messaging.createSms({ +const result = await messaging.createSMS({ messageId: '<MESSAGE_ID>', content: '<CONTENT>', topics: [], // optional diff --git a/docs/examples/messaging/create-smtp-provider.md b/docs/examples/messaging/create-smtp-provider.md index 5ce889c4..f94b8cd6 100644 --- a/docs/examples/messaging/create-smtp-provider.md +++ b/docs/examples/messaging/create-smtp-provider.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const result = await messaging.createSmtpProvider({ +const result = await messaging.createSMTPProvider({ providerId: '<PROVIDER_ID>', name: '<NAME>', host: '<HOST>', diff --git a/docs/examples/messaging/update-apns-provider.md b/docs/examples/messaging/update-apns-provider.md index 33d44077..72a38c0f 100644 --- a/docs/examples/messaging/update-apns-provider.md +++ b/docs/examples/messaging/update-apns-provider.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const result = await messaging.updateApnsProvider({ +const result = await messaging.updateAPNSProvider({ providerId: '<PROVIDER_ID>', name: '<NAME>', // optional enabled: false, // optional diff --git a/docs/examples/messaging/update-fcm-provider.md b/docs/examples/messaging/update-fcm-provider.md index 860952e3..c941807c 100644 --- a/docs/examples/messaging/update-fcm-provider.md +++ b/docs/examples/messaging/update-fcm-provider.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const result = await messaging.updateFcmProvider({ +const result = await messaging.updateFCMProvider({ providerId: '<PROVIDER_ID>', name: '<NAME>', // optional enabled: false, // optional diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 40df7c77..07624dea 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const result = await messaging.updateSms({ +const result = await messaging.updateSMS({ messageId: '<MESSAGE_ID>', topics: [], // optional users: [], // optional diff --git a/docs/examples/messaging/update-smtp-provider.md b/docs/examples/messaging/update-smtp-provider.md index aaeae762..f1f1531d 100644 --- a/docs/examples/messaging/update-smtp-provider.md +++ b/docs/examples/messaging/update-smtp-provider.md @@ -7,7 +7,7 @@ const client = new Client() const messaging = new Messaging(client); -const result = await messaging.updateSmtpProvider({ +const result = await messaging.updateSMTPProvider({ providerId: '<PROVIDER_ID>', name: '<NAME>', // optional host: '<HOST>', // optional diff --git a/docs/examples/presences/update-presence.md b/docs/examples/presences/update-presence.md new file mode 100644 index 00000000..06dcfdbd --- /dev/null +++ b/docs/examples/presences/update-presence.md @@ -0,0 +1,21 @@ +```javascript +import { Client, Presences, Permission, Role } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const presences = new Presences(client); + +const result = await presences.updatePresence({ + presenceId: '<PRESENCE_ID>', + userId: '<USER_ID>', + status: '<STATUS>', // optional + expiresAt: '2020-10-15T06:38:00.000+00:00', // optional + metadata: {}, // optional + permissions: [Permission.read(Role.any())], // optional + purge: false // optional +}); + +console.log(result); +``` diff --git a/docs/examples/presences/update.md b/docs/examples/presences/update.md index 01cc3fc7..79e5aa91 100644 --- a/docs/examples/presences/update.md +++ b/docs/examples/presences/update.md @@ -9,7 +9,6 @@ const presences = new Presences(client); const result = await presences.update({ presenceId: '<PRESENCE_ID>', - userId: '<USER_ID>', // optional status: '<STATUS>', // optional expiresAt: '2020-10-15T06:38:00.000+00:00', // optional metadata: {}, // optional diff --git a/docs/examples/presences/upsert.md b/docs/examples/presences/upsert.md index 3d13e32e..7c32bf10 100644 --- a/docs/examples/presences/upsert.md +++ b/docs/examples/presences/upsert.md @@ -9,8 +9,8 @@ const presences = new Presences(client); const result = await presences.upsert({ presenceId: '<PRESENCE_ID>', + userId: '<USER_ID>', status: '<STATUS>', - userId: '<USER_ID>', // optional permissions: [Permission.read(Role.any())], // optional expiresAt: '2020-10-15T06:38:00.000+00:00', // optional metadata: {} // optional diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 3ca869aa..105c4445 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -10,16 +10,15 @@ const tablesDB = new TablesDB(client); const result = await tablesDB.createRow({ databaseId: '<DATABASE_ID>', tableId: '<TABLE_ID>', - rowId: '<ROW_ID>', // optional + rowId: '<ROW_ID>', data: { "username": "walter.obrien", "email": "walter.obrien@example.com", "fullName": "Walter O'Brien", "age": 30, "isAdmin": false - }, // optional + }, permissions: [Permission.read(Role.any())], // optional - rows: [], // optional transactionId: '<TRANSACTION_ID>' // optional }); diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md new file mode 100644 index 00000000..fa838105 --- /dev/null +++ b/docs/examples/tablesdb/create-rows.md @@ -0,0 +1,18 @@ +```javascript +import { Client, TablesDB } from "appwrite"; + +const client = new Client() + .setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('<YOUR_PROJECT_ID>'); // Your project ID + +const tablesDB = new TablesDB(client); + +const result = await tablesDB.createRows({ + databaseId: '<DATABASE_ID>', + tableId: '<TABLE_ID>', + rows: [], + transactionId: '<TRANSACTION_ID>' // optional +}); + +console.log(result); +``` diff --git a/docs/examples/users/create-mfa-recovery-codes.md b/docs/examples/users/create-mfa-recovery-codes.md index a9cc4bd4..af94a61c 100644 --- a/docs/examples/users/create-mfa-recovery-codes.md +++ b/docs/examples/users/create-mfa-recovery-codes.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const result = await users.createMfaRecoveryCodes({ +const result = await users.createMFARecoveryCodes({ userId: '<USER_ID>' }); diff --git a/docs/examples/users/delete-mfa-authenticator.md b/docs/examples/users/delete-mfa-authenticator.md index 81d5b18b..5cbc46e5 100644 --- a/docs/examples/users/delete-mfa-authenticator.md +++ b/docs/examples/users/delete-mfa-authenticator.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const result = await users.deleteMfaAuthenticator({ +const result = await users.deleteMFAAuthenticator({ userId: '<USER_ID>', type: AuthenticatorType.Totp }); diff --git a/docs/examples/users/get-mfa-recovery-codes.md b/docs/examples/users/get-mfa-recovery-codes.md index c9c19e22..cdc0905b 100644 --- a/docs/examples/users/get-mfa-recovery-codes.md +++ b/docs/examples/users/get-mfa-recovery-codes.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const result = await users.getMfaRecoveryCodes({ +const result = await users.getMFARecoveryCodes({ userId: '<USER_ID>' }); diff --git a/docs/examples/users/list-mfa-factors.md b/docs/examples/users/list-mfa-factors.md index b15be0c8..2e2e23ab 100644 --- a/docs/examples/users/list-mfa-factors.md +++ b/docs/examples/users/list-mfa-factors.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const result = await users.listMfaFactors({ +const result = await users.listMFAFactors({ userId: '<USER_ID>' }); diff --git a/docs/examples/users/update-mfa-recovery-codes.md b/docs/examples/users/update-mfa-recovery-codes.md index c79714d6..480b73ab 100644 --- a/docs/examples/users/update-mfa-recovery-codes.md +++ b/docs/examples/users/update-mfa-recovery-codes.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const result = await users.updateMfaRecoveryCodes({ +const result = await users.updateMFARecoveryCodes({ userId: '<USER_ID>' }); diff --git a/docs/examples/users/update-mfa.md b/docs/examples/users/update-mfa.md index 9a4c579c..8bdcab01 100644 --- a/docs/examples/users/update-mfa.md +++ b/docs/examples/users/update-mfa.md @@ -7,7 +7,7 @@ const client = new Client() const users = new Users(client); -const result = await users.updateMfa({ +const result = await users.updateMFA({ userId: '<USER_ID>', mfa: false }); diff --git a/src/services/account.ts b/src/services/account.ts index 2ef0d393..0a9985fa 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -529,6 +529,58 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. + * + * @param {AuthenticatorType} params.type - Type of authenticator. Must be `totp` + * @throws {AppwriteException} + * @returns {Promise<Models.MfaType>} + */ + createMFAAuthenticator(params: { type: AuthenticatorType }): Promise<Models.MfaType>; + /** + * Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method. + * + * @param {AuthenticatorType} type - Type of authenticator. Must be `totp` + * @throws {AppwriteException} + * @returns {Promise<Models.MfaType>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMFAAuthenticator(type: AuthenticatorType): Promise<Models.MfaType>; + createMFAAuthenticator( + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + ): Promise<Models.MfaType> { + let params: { type: AuthenticatorType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { type: AuthenticatorType }; + } else { + params = { + type: paramsOrFirst as AuthenticatorType + }; + } + + const type = params.type; + + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + /** * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. * @@ -593,6 +645,69 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. + * + * @param {AuthenticatorType} params.type - Type of authenticator. + * @param {string} params.otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateMFAAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { type: AuthenticatorType, otp: string }): Promise<Models.User<Preferences>>; + /** + * Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. + * + * @param {AuthenticatorType} type - Type of authenticator. + * @param {string} otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMFAAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>(type: AuthenticatorType, otp: string): Promise<Models.User<Preferences>>; + updateMFAAuthenticator<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { type: AuthenticatorType, otp: string } | AuthenticatorType, + ...rest: [(string)?] + ): Promise<Models.User<Preferences>> { + let params: { type: AuthenticatorType, otp: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst || 'otp' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { type: AuthenticatorType, otp: string }; + } else { + params = { + type: paramsOrFirst as AuthenticatorType, + otp: rest[0] as string + }; + } + + const type = params.type; + const otp = params.otp; + + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + if (typeof otp === 'undefined') { + throw new AppwriteException('Missing required parameter: "otp"'); + } + + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); + const payload: Payload = {}; + if (typeof otp !== 'undefined') { + payload['otp'] = otp; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + /** * Delete an authenticator for a user by ID. * @@ -646,6 +761,58 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * Delete an authenticator for a user by ID. + * + * @param {AuthenticatorType} params.type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteMFAAuthenticator(params: { type: AuthenticatorType }): Promise<{}>; + /** + * Delete an authenticator for a user by ID. + * + * @param {AuthenticatorType} type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteMFAAuthenticator(type: AuthenticatorType): Promise<{}>; + deleteMFAAuthenticator( + paramsOrFirst: { type: AuthenticatorType } | AuthenticatorType + ): Promise<{}> { + let params: { type: AuthenticatorType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('type' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { type: AuthenticatorType }; + } else { + params = { + type: paramsOrFirst as AuthenticatorType + }; + } + + const type = params.type; + + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/account/mfa/authenticators/{type}'.replace('{type}', type); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + /** * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. * @@ -702,6 +869,61 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. + * + * @param {AuthenticationFactor} params.factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaChallenge>} + */ + createMFAChallenge(params: { factor: AuthenticationFactor }): Promise<Models.MfaChallenge>; + /** + * Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method. + * + * @param {AuthenticationFactor} factor - Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaChallenge>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMFAChallenge(factor: AuthenticationFactor): Promise<Models.MfaChallenge>; + createMFAChallenge( + paramsOrFirst: { factor: AuthenticationFactor } | AuthenticationFactor + ): Promise<Models.MfaChallenge> { + let params: { factor: AuthenticationFactor }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst) && ('factor' in paramsOrFirst))) { + params = (paramsOrFirst || {}) as { factor: AuthenticationFactor }; + } else { + params = { + factor: paramsOrFirst as AuthenticationFactor + }; + } + + const factor = params.factor; + + if (typeof factor === 'undefined') { + throw new AppwriteException('Missing required parameter: "factor"'); + } + + const apiPath = '/account/mfa/challenges'; + const payload: Payload = {}; + if (typeof factor !== 'undefined') { + payload['factor'] = factor; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + /** * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -769,6 +991,72 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. + * + * @param {string} params.challengeId - ID of the challenge. + * @param {string} params.otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + */ + updateMFAChallenge(params: { challengeId: string, otp: string }): Promise<Models.Session>; + /** + * Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. + * + * @param {string} challengeId - ID of the challenge. + * @param {string} otp - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Session>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMFAChallenge(challengeId: string, otp: string): Promise<Models.Session>; + updateMFAChallenge( + paramsOrFirst: { challengeId: string, otp: string } | string, + ...rest: [(string)?] + ): Promise<Models.Session> { + let params: { challengeId: string, otp: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { challengeId: string, otp: string }; + } else { + params = { + challengeId: paramsOrFirst as string, + otp: rest[0] as string + }; + } + + const challengeId = params.challengeId; + const otp = params.otp; + + if (typeof challengeId === 'undefined') { + throw new AppwriteException('Missing required parameter: "challengeId"'); + } + if (typeof otp === 'undefined') { + throw new AppwriteException('Missing required parameter: "otp"'); + } + + const apiPath = '/account/mfa/challenges'; + const payload: Payload = {}; + if (typeof challengeId !== 'undefined') { + payload['challengeId'] = challengeId; + } + if (typeof otp !== 'undefined') { + payload['otp'] = otp; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + /** * List the factors available on the account to be used as a MFA challange. * @@ -793,6 +1081,29 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * List the factors available on the account to be used as a MFA challange. + * + * @throws {AppwriteException} + * @returns {Promise<Models.MfaFactors>} + */ + listMFAFactors(): Promise<Models.MfaFactors> { + + const apiPath = '/account/mfa/factors'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + /** * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. * @@ -817,6 +1128,29 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes. + * + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + */ + getMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + + const apiPath = '/account/mfa/recovery-codes'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + /** * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. * @@ -842,6 +1176,30 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method. + * + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + */ + createMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + + const apiPath = '/account/mfa/recovery-codes'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + /** * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. * @@ -867,6 +1225,30 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes. + * + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + */ + updateMFARecoveryCodes(): Promise<Models.MfaRecoveryCodes> { + + const apiPath = '/account/mfa/recovery-codes'; + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + /** * Update currently logged in user account name. * @@ -2455,6 +2837,68 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. + * + * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + * + * + * @param {string} params.url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead. + */ + createVerification(params: { url: string }): Promise<Models.Token>; + /** + * Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days. + * + * Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. + * + * + * @param {string} url - URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createVerification(url: string): Promise<Models.Token>; + createVerification( + paramsOrFirst: { url: string } | string + ): Promise<Models.Token> { + let params: { url: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { url: string }; + } else { + params = { + url: paramsOrFirst as string + }; + } + + const url = params.url; + + if (typeof url === 'undefined') { + throw new AppwriteException('Missing required parameter: "url"'); + } + + const apiPath = '/account/verifications/email'; + const payload: Payload = {}; + if (typeof url !== 'undefined') { + payload['url'] = url; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + /** * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. * @@ -2521,6 +2965,73 @@ class AccountRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Server ); } + /** + * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. + * + * @param {string} params.userId - User ID. + * @param {string} params.secret - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead. + */ + updateVerification(params: { userId: string, secret: string }): Promise<Models.Token>; + /** + * Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code. + * + * @param {string} userId - User ID. + * @param {string} secret - Valid verification token. + * @throws {AppwriteException} + * @returns {Promise<Models.Token>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateVerification(userId: string, secret: string): Promise<Models.Token>; + updateVerification( + paramsOrFirst: { userId: string, secret: string } | string, + ...rest: [(string)?] + ): Promise<Models.Token> { + let params: { userId: string, secret: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, secret: string }; + } else { + params = { + userId: paramsOrFirst as string, + secret: rest[0] as string + }; + } + + const userId = params.userId; + const secret = params.secret; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof secret === 'undefined') { + throw new AppwriteException('Missing required parameter: "secret"'); + } + + const apiPath = '/account/verifications/email'; + const payload: Payload = {}; + if (typeof userId !== 'undefined') { + payload['userId'] = userId; + } + if (typeof secret !== 'undefined') { + payload['secret'] = secret; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + /** * Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes. * diff --git a/src/services/databases.ts b/src/services/databases.ts index e4c5ef0d..334f3204 100644 --- a/src/services/databases.ts +++ b/src/services/databases.ts @@ -4987,13 +4987,12 @@ class DatabasesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @param {string} params.documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} params.data - Document data as JSON object. * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {object[]} params.documents - Array of documents data as JSON objects. * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead. */ - createDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId?: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], documents?: object[], transactionId?: string }): Promise<Document>; + createDocument<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], transactionId?: string }): Promise<Document>; /** * Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. * @@ -5002,21 +5001,20 @@ class DatabasesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @param {string} documentId - Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>} data - Document data as JSON object. * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {object[]} documents - Array of documents data as JSON objects. * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Document>} * @deprecated Use the object parameter style method for a better developer experience. */ - createDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId?: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], documents?: object[], transactionId?: string): Promise<Document>; + createDocument<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], transactionId?: string): Promise<Document>; createDocument<Document extends Models.Document = Models.DefaultDocument>( - paramsOrFirst: { databaseId: string, collectionId: string, documentId?: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], documents?: object[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, (string[])?, (object[])?, (string)?] + paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>)?, (string[])?, (string)?] ): Promise<Document> { - let params: { databaseId: string, collectionId: string, documentId?: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], documents?: object[], transactionId?: string }; + let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId?: string, data?: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], documents?: object[], transactionId?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, @@ -5024,8 +5022,7 @@ class DatabasesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv documentId: rest[1] as string, data: rest[2] as Document extends Models.DefaultDocument ? Partial<Models.Document> & Record<string, any> : Partial<Models.Document> & Omit<Document, keyof Models.Document>, permissions: rest[3] as string[], - documents: rest[4] as object[], - transactionId: rest[5] as string + transactionId: rest[4] as string }; } @@ -5034,7 +5031,6 @@ class DatabasesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv const documentId = params.documentId; const data = params.data; const permissions = params.permissions; - const documents = params.documents; const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { @@ -5043,6 +5039,12 @@ class DatabasesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv if (typeof collectionId === 'undefined') { throw new AppwriteException('Missing required parameter: "collectionId"'); } + if (typeof documentId === 'undefined') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); const payload: Payload = {}; @@ -5055,6 +5057,81 @@ class DatabasesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} params.documents - Array of documents data as JSON objects. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRows` instead. + */ + createDocuments<Document extends Models.Document = Models.DefaultDocument>(params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }): Promise<Models.DocumentList<Document>>; + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param {object[]} documents - Array of documents data as JSON objects. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.DocumentList<Document>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createDocuments<Document extends Models.Document = Models.DefaultDocument>(databaseId: string, collectionId: string, documents: object[], transactionId?: string): Promise<Models.DocumentList<Document>>; + createDocuments<Document extends Models.Document = Models.DefaultDocument>( + paramsOrFirst: { databaseId: string, collectionId: string, documents: object[], transactionId?: string } | string, + ...rest: [(string)?, (object[])?, (string)?] + ): Promise<Models.DocumentList<Document>> { + let params: { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documents: object[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + collectionId: rest[0] as string, + documents: rest[1] as object[], + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const collectionId = params.collectionId; + const documents = params.documents; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof collectionId === 'undefined') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + if (typeof documents === 'undefined') { + throw new AppwriteException('Missing required parameter: "documents"'); + } + + const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); + const payload: Payload = {}; if (typeof documents !== 'undefined') { payload['documents'] = documents; } diff --git a/src/services/messaging.ts b/src/services/messaging.ts index 117be78a..35acc289 100644 --- a/src/services/messaging.ts +++ b/src/services/messaging.ts @@ -4,7 +4,7 @@ import type { Models } from '../models'; import { MessagePriority } from '../enums/message-priority'; import { SmtpEncryption } from '../enums/smtp-encryption'; -type MessagingServerOnlyMethod = 'listMessages' | 'createEmail' | 'updateEmail' | 'createPush' | 'updatePush' | 'createSms' | 'updateSms' | 'getMessage' | 'delete' | 'listMessageLogs' | 'listTargets' | 'listProviders' | 'createApnsProvider' | 'updateApnsProvider' | 'createFcmProvider' | 'updateFcmProvider' | 'createMailgunProvider' | 'updateMailgunProvider' | 'createMsg91Provider' | 'updateMsg91Provider' | 'createResendProvider' | 'updateResendProvider' | 'createSendgridProvider' | 'updateSendgridProvider' | 'createSmtpProvider' | 'updateSmtpProvider' | 'createTelesignProvider' | 'updateTelesignProvider' | 'createTextmagicProvider' | 'updateTextmagicProvider' | 'createTwilioProvider' | 'updateTwilioProvider' | 'createVonageProvider' | 'updateVonageProvider' | 'getProvider' | 'deleteProvider' | 'listProviderLogs' | 'listSubscriberLogs' | 'listTopics' | 'createTopic' | 'getTopic' | 'updateTopic' | 'deleteTopic' | 'listTopicLogs' | 'listSubscribers' | 'getSubscriber'; +type MessagingServerOnlyMethod = 'listMessages' | 'createEmail' | 'updateEmail' | 'createPush' | 'updatePush' | 'createSms' | 'createSMS' | 'updateSms' | 'updateSMS' | 'getMessage' | 'delete' | 'listMessageLogs' | 'listTargets' | 'listProviders' | 'createApnsProvider' | 'createAPNSProvider' | 'updateApnsProvider' | 'updateAPNSProvider' | 'createFcmProvider' | 'createFCMProvider' | 'updateFcmProvider' | 'updateFCMProvider' | 'createMailgunProvider' | 'updateMailgunProvider' | 'createMsg91Provider' | 'updateMsg91Provider' | 'createResendProvider' | 'updateResendProvider' | 'createSendgridProvider' | 'updateSendgridProvider' | 'createSmtpProvider' | 'createSMTPProvider' | 'updateSmtpProvider' | 'updateSMTPProvider' | 'createTelesignProvider' | 'updateTelesignProvider' | 'createTextmagicProvider' | 'updateTextmagicProvider' | 'createTwilioProvider' | 'updateTwilioProvider' | 'createVonageProvider' | 'updateVonageProvider' | 'getProvider' | 'deleteProvider' | 'listProviderLogs' | 'listSubscriberLogs' | 'listTopics' | 'createTopic' | 'getTopic' | 'updateTopic' | 'deleteTopic' | 'listTopicLogs' | 'listSubscribers' | 'getSubscriber'; type MessagingClientOnlyMethod = never; export type Messaging<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = @@ -823,6 +823,107 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv ); } + /** + * Create a new SMS message. + * + * @param {string} params.messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.content - SMS Content. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + createSMS(this: Messaging<ServerAuth>, params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }): Promise<Models.Message>; + /** + * Create a new SMS message. + * + * @param {string} messageId - Message ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} content - SMS Content. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSMS(this: Messaging<ServerAuth>, messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise<Models.Message>; + createSMS( + paramsOrFirst: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string } | string, + ...rest: [(string)?, (string[])?, (string[])?, (string[])?, (boolean)?, (string)?] + ): Promise<Models.Message> { + let params: { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string }; + } else { + params = { + messageId: paramsOrFirst as string, + content: rest[0] as string, + topics: rest[1] as string[], + users: rest[2] as string[], + targets: rest[3] as string[], + draft: rest[4] as boolean, + scheduledAt: rest[5] as string + }; + } + + const messageId = params.messageId; + const content = params.content; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + if (typeof content === 'undefined') { + throw new AppwriteException('Missing required parameter: "content"'); + } + + const apiPath = '/messaging/messages/sms'; + const payload: Payload = {}; + if (typeof messageId !== 'undefined') { + payload['messageId'] = messageId; + } + if (typeof content !== 'undefined') { + payload['content'] = content; + } + if (typeof topics !== 'undefined') { + payload['topics'] = topics; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + if (typeof targets !== 'undefined') { + payload['targets'] = targets; + } + if (typeof draft !== 'undefined') { + payload['draft'] = draft; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + /** * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. * @@ -921,6 +1022,103 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv ); } + /** + * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} params.messageId - Message ID. + * @param {string[]} params.topics - List of Topic IDs. + * @param {string[]} params.users - List of User IDs. + * @param {string[]} params.targets - List of Targets IDs. + * @param {string} params.content - Email Content. + * @param {boolean} params.draft - Is message a draft + * @param {string} params.scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + */ + updateSMS(this: Messaging<ServerAuth>, params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }): Promise<Models.Message>; + /** + * Update an SMS message by its unique ID. This endpoint only works on messages that are in draft status. Messages that are already processing, sent, or failed cannot be updated. + * + * + * @param {string} messageId - Message ID. + * @param {string[]} topics - List of Topic IDs. + * @param {string[]} users - List of User IDs. + * @param {string[]} targets - List of Targets IDs. + * @param {string} content - Email Content. + * @param {boolean} draft - Is message a draft + * @param {string} scheduledAt - Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + * @throws {AppwriteException} + * @returns {Promise<Models.Message>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSMS(this: Messaging<ServerAuth>, messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise<Models.Message>; + updateSMS( + paramsOrFirst: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string } | string, + ...rest: [(string[])?, (string[])?, (string[])?, (string)?, (boolean)?, (string)?] + ): Promise<Models.Message> { + let params: { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string }; + } else { + params = { + messageId: paramsOrFirst as string, + topics: rest[0] as string[], + users: rest[1] as string[], + targets: rest[2] as string[], + content: rest[3] as string, + draft: rest[4] as boolean, + scheduledAt: rest[5] as string + }; + } + + const messageId = params.messageId; + const topics = params.topics; + const users = params.users; + const targets = params.targets; + const content = params.content; + const draft = params.draft; + const scheduledAt = params.scheduledAt; + + if (typeof messageId === 'undefined') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + + const apiPath = '/messaging/messages/sms/{messageId}'.replace('{messageId}', messageId); + const payload: Payload = {}; + if (typeof topics !== 'undefined') { + payload['topics'] = topics; + } + if (typeof users !== 'undefined') { + payload['users'] = users; + } + if (typeof targets !== 'undefined') { + payload['targets'] = targets; + } + if (typeof content !== 'undefined') { + payload['content'] = content; + } + if (typeof draft !== 'undefined') { + payload['draft'] = draft; + } + if (typeof scheduledAt !== 'undefined') { + payload['scheduledAt'] = scheduledAt; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + /** * Get a message by its unique ID. * @@ -1334,79 +1532,81 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv } /** - * Update a Apple Push Notification service provider by its unique ID. + * Create a new Apple Push Notification service provider. * - * @param {string} params.providerId - Provider ID. + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. * @param {string} params.authKey - APNS authentication key. * @param {string} params.authKeyId - APNS authentication key ID. * @param {string} params.teamId - APNS team ID. * @param {string} params.bundleId - APNS bundle ID. * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @param {boolean} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} - * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. */ - updateApnsProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }): Promise<Models.Provider>; + createAPNSProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }): Promise<Models.Provider>; /** - * Update a Apple Push Notification service provider by its unique ID. + * Create a new Apple Push Notification service provider. * - * @param {string} providerId - Provider ID. + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. * @param {string} authKey - APNS authentication key. * @param {string} authKeyId - APNS authentication key ID. * @param {string} teamId - APNS team ID. * @param {string} bundleId - APNS bundle ID. * @param {boolean} sandbox - Use APNS sandbox environment. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateApnsProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise<Models.Provider>; - updateApnsProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + createAPNSProvider(this: Messaging<ServerAuth>, providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise<Models.Provider>; + createAPNSProvider( + paramsOrFirst: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?, (boolean)?] ): Promise<Models.Provider> { - let params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + let params: { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + params = (paramsOrFirst || {}) as { providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - authKey: rest[2] as string, - authKeyId: rest[3] as string, - teamId: rest[4] as string, - bundleId: rest[5] as string, - sandbox: rest[6] as boolean + authKey: rest[1] as string, + authKeyId: rest[2] as string, + teamId: rest[3] as string, + bundleId: rest[4] as string, + sandbox: rest[5] as boolean, + enabled: rest[6] as boolean }; } const providerId = params.providerId; const name = params.name; - const enabled = params.enabled; const authKey = params.authKey; const authKeyId = params.authKeyId; const teamId = params.teamId; const bundleId = params.bundleId; const sandbox = params.sandbox; + const enabled = params.enabled; if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } - const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', providerId); + const apiPath = '/messaging/providers/apns'; const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } if (typeof name !== 'undefined') { payload['name'] = name; } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; - } if (typeof authKey !== 'undefined') { payload['authKey'] = authKey; } @@ -1422,6 +1622,9 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv if (typeof sandbox !== 'undefined') { payload['sandbox'] = sandbox; } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1429,7 +1632,7 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv } return this.client.call( - 'patch', + 'post', uri, apiHeaders, payload @@ -1437,72 +1640,432 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv } /** - * Create a new Firebase Cloud Messaging provider. + * Update a Apple Push Notification service provider by its unique ID. * - * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. - * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.authKey - APNS authentication key. + * @param {string} params.authKeyId - APNS authentication key ID. + * @param {string} params.teamId - APNS team ID. + * @param {string} params.bundleId - APNS bundle ID. + * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateAPNSProvider` instead. + */ + updateApnsProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }): Promise<Models.Provider>; + /** + * Update a Apple Push Notification service provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} authKey - APNS authentication key. + * @param {string} authKeyId - APNS authentication key ID. + * @param {string} teamId - APNS team ID. + * @param {string} bundleId - APNS bundle ID. + * @param {boolean} sandbox - Use APNS sandbox environment. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateApnsProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise<Models.Provider>; + updateApnsProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + authKey: rest[2] as string, + authKeyId: rest[3] as string, + teamId: rest[4] as string, + bundleId: rest[5] as string, + sandbox: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const authKey = params.authKey; + const authKeyId = params.authKeyId; + const teamId = params.teamId; + const bundleId = params.bundleId; + const sandbox = params.sandbox; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof authKey !== 'undefined') { + payload['authKey'] = authKey; + } + if (typeof authKeyId !== 'undefined') { + payload['authKeyId'] = authKeyId; + } + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + if (typeof bundleId !== 'undefined') { + payload['bundleId'] = bundleId; + } + if (typeof sandbox !== 'undefined') { + payload['sandbox'] = sandbox; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Apple Push Notification service provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.authKey - APNS authentication key. + * @param {string} params.authKeyId - APNS authentication key ID. + * @param {string} params.teamId - APNS team ID. + * @param {string} params.bundleId - APNS bundle ID. + * @param {boolean} params.sandbox - Use APNS sandbox environment. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateAPNSProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }): Promise<Models.Provider>; + /** + * Update a Apple Push Notification service provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} authKey - APNS authentication key. + * @param {string} authKeyId - APNS authentication key ID. + * @param {string} teamId - APNS team ID. + * @param {string} bundleId - APNS bundle ID. + * @param {boolean} sandbox - Use APNS sandbox environment. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateAPNSProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise<Models.Provider>; + updateAPNSProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + authKey: rest[2] as string, + authKeyId: rest[3] as string, + teamId: rest[4] as string, + bundleId: rest[5] as string, + sandbox: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const authKey = params.authKey; + const authKeyId = params.authKeyId; + const teamId = params.teamId; + const bundleId = params.bundleId; + const sandbox = params.sandbox; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/apns/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof authKey !== 'undefined') { + payload['authKey'] = authKey; + } + if (typeof authKeyId !== 'undefined') { + payload['authKeyId'] = authKeyId; + } + if (typeof teamId !== 'undefined') { + payload['teamId'] = teamId; + } + if (typeof bundleId !== 'undefined') { + payload['bundleId'] = bundleId; + } + if (typeof sandbox !== 'undefined') { + payload['sandbox'] = sandbox; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {object} params.serviceAccountJSON - FCM service account JSON. * @param {boolean} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead. */ - createFcmProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }): Promise<Models.Provider>; + createFcmProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFcmProvider(this: Messaging<ServerAuth>, providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise<Models.Provider>; + createFcmProvider( + paramsOrFirst: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean } | string, + ...rest: [(string)?, (object)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + serviceAccountJSON: rest[1] as object, + enabled: rest[2] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const serviceAccountJSON = params.serviceAccountJSON; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/fcm'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof serviceAccountJSON !== 'undefined') { + payload['serviceAccountJSON'] = serviceAccountJSON; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createFCMProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Firebase Cloud Messaging provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {object} serviceAccountJSON - FCM service account JSON. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createFCMProvider(this: Messaging<ServerAuth>, providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise<Models.Provider>; + createFCMProvider( + paramsOrFirst: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean } | string, + ...rest: [(string)?, (object)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + serviceAccountJSON: rest[1] as object, + enabled: rest[2] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const serviceAccountJSON = params.serviceAccountJSON; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/fcm'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof serviceAccountJSON !== 'undefined') { + payload['serviceAccountJSON'] = serviceAccountJSON; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Firebase Cloud Messaging provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {object} params.serviceAccountJSON - FCM service account JSON. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. + */ + updateFcmProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }): Promise<Models.Provider>; /** - * Create a new Firebase Cloud Messaging provider. + * Update a Firebase Cloud Messaging provider by its unique ID. * - * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} providerId - Provider ID. * @param {string} name - Provider name. - * @param {object} serviceAccountJSON - FCM service account JSON. * @param {boolean} enabled - Set as enabled. + * @param {object} serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. */ - createFcmProvider(this: Messaging<ServerAuth>, providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise<Models.Provider>; - createFcmProvider( - paramsOrFirst: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean } | string, - ...rest: [(string)?, (object)?, (boolean)?] + updateFcmProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise<Models.Provider>; + updateFcmProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object } | string, + ...rest: [(string)?, (boolean)?, (object)?] ): Promise<Models.Provider> { - let params: { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + let params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean }; + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - serviceAccountJSON: rest[1] as object, - enabled: rest[2] as boolean + enabled: rest[1] as boolean, + serviceAccountJSON: rest[2] as object }; } const providerId = params.providerId; const name = params.name; - const serviceAccountJSON = params.serviceAccountJSON; const enabled = params.enabled; + const serviceAccountJSON = params.serviceAccountJSON; if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - const apiPath = '/messaging/providers/fcm'; + const apiPath = '/messaging/providers/fcm/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; - if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; - } if (typeof name !== 'undefined') { payload['name'] = name; } - if (typeof serviceAccountJSON !== 'undefined') { - payload['serviceAccountJSON'] = serviceAccountJSON; - } if (typeof enabled !== 'undefined') { payload['enabled'] = enabled; } + if (typeof serviceAccountJSON !== 'undefined') { + payload['serviceAccountJSON'] = serviceAccountJSON; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -1510,7 +2073,7 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv } return this.client.call( - 'post', + 'patch', uri, apiHeaders, payload @@ -1526,9 +2089,8 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @param {object} params.serviceAccountJSON - FCM service account JSON. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} - * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateFCMProvider` instead. */ - updateFcmProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }): Promise<Models.Provider>; + updateFCMProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object }): Promise<Models.Provider>; /** * Update a Firebase Cloud Messaging provider by its unique ID. * @@ -1540,8 +2102,8 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateFcmProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise<Models.Provider>; - updateFcmProvider( + updateFCMProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise<Models.Provider>; + updateFCMProvider( paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object } | string, ...rest: [(string)?, (boolean)?, (object)?] ): Promise<Models.Provider> { @@ -2227,7 +2789,223 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {string} params.apiKey - Sendgrid API key. + * @param {string} params.apiKey - Sendgrid API key. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} params.enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + createSendgridProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + /** + * Create a new Sendgrid provider. + * + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} name - Provider name. + * @param {string} apiKey - Sendgrid API key. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} enabled - Set as enabled. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createSendgridProvider(this: Messaging<ServerAuth>, providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createSendgridProvider( + paramsOrFirst: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + apiKey: rest[1] as string, + fromName: rest[2] as string, + fromEmail: rest[3] as string, + replyToName: rest[4] as string, + replyToEmail: rest[5] as string, + enabled: rest[6] as boolean + }; + } + + const providerId = params.providerId; + const name = params.name; + const apiKey = params.apiKey; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + const enabled = params.enabled; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + + const apiPath = '/messaging/providers/sendgrid'; + const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Update a Sendgrid provider by its unique ID. + * + * @param {string} params.providerId - Provider ID. + * @param {string} params.name - Provider name. + * @param {boolean} params.enabled - Set as enabled. + * @param {string} params.apiKey - Sendgrid API key. + * @param {string} params.fromName - Sender Name. + * @param {string} params.fromEmail - Sender email address. + * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + */ + updateSendgridProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise<Models.Provider>; + /** + * Update a Sendgrid provider by its unique ID. + * + * @param {string} providerId - Provider ID. + * @param {string} name - Provider name. + * @param {boolean} enabled - Set as enabled. + * @param {string} apiKey - Sendgrid API key. + * @param {string} fromName - Sender Name. + * @param {string} fromEmail - Sender email address. + * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @throws {AppwriteException} + * @returns {Promise<Models.Provider>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateSendgridProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider>; + updateSendgridProvider( + paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, + ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?] + ): Promise<Models.Provider> { + let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + } else { + params = { + providerId: paramsOrFirst as string, + name: rest[0] as string, + enabled: rest[1] as boolean, + apiKey: rest[2] as string, + fromName: rest[3] as string, + fromEmail: rest[4] as string, + replyToName: rest[5] as string, + replyToEmail: rest[6] as string + }; + } + + const providerId = params.providerId; + const name = params.name; + const enabled = params.enabled; + const apiKey = params.apiKey; + const fromName = params.fromName; + const fromEmail = params.fromEmail; + const replyToName = params.replyToName; + const replyToEmail = params.replyToEmail; + + if (typeof providerId === 'undefined') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + + const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace('{providerId}', providerId); + const payload: Payload = {}; + if (typeof name !== 'undefined') { + payload['name'] = name; + } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } + if (typeof apiKey !== 'undefined') { + payload['apiKey'] = apiKey; + } + if (typeof fromName !== 'undefined') { + payload['fromName'] = fromName; + } + if (typeof fromEmail !== 'undefined') { + payload['fromEmail'] = fromEmail; + } + if (typeof replyToName !== 'undefined') { + payload['replyToName'] = replyToName; + } + if (typeof replyToEmail !== 'undefined') { + payload['replyToEmail'] = replyToEmail; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + + /** + * Create a new SMTP provider. + * + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.name - Provider name. + * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} params.port - The default SMTP server port. + * @param {string} params.username - Authentication username. + * @param {string} params.password - Authentication password. + * @param {SmtpEncryption} params.encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -2235,14 +3013,21 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @param {boolean} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. */ - createSendgridProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + createSmtpProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; /** - * Create a new Sendgrid provider. + * Create a new SMTP provider. * * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {string} apiKey - Sendgrid API key. + * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} port - The default SMTP server port. + * @param {string} username - Authentication username. + * @param {string} password - Authentication password. + * @param {SmtpEncryption} encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. @@ -2252,31 +3037,43 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. */ - createSendgridProvider(this: Messaging<ServerAuth>, providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; - createSendgridProvider( - paramsOrFirst: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, - ...rest: [(string)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] + createSmtpProvider(this: Messaging<ServerAuth>, providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createSmtpProvider( + paramsOrFirst: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] ): Promise<Models.Provider> { - let params: { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + params = (paramsOrFirst || {}) as { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - apiKey: rest[1] as string, - fromName: rest[2] as string, - fromEmail: rest[3] as string, - replyToName: rest[4] as string, - replyToEmail: rest[5] as string, - enabled: rest[6] as boolean + host: rest[1] as string, + port: rest[2] as number, + username: rest[3] as string, + password: rest[4] as string, + encryption: rest[5] as SmtpEncryption, + autoTLS: rest[6] as boolean, + mailer: rest[7] as string, + fromName: rest[8] as string, + fromEmail: rest[9] as string, + replyToName: rest[10] as string, + replyToEmail: rest[11] as string, + enabled: rest[12] as boolean }; } const providerId = params.providerId; const name = params.name; - const apiKey = params.apiKey; + const host = params.host; + const port = params.port; + const username = params.username; + const password = params.password; + const encryption = params.encryption; + const autoTLS = params.autoTLS; + const mailer = params.mailer; const fromName = params.fromName; const fromEmail = params.fromEmail; const replyToName = params.replyToName; @@ -2289,8 +3086,11 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv if (typeof name === 'undefined') { throw new AppwriteException('Missing required parameter: "name"'); } + if (typeof host === 'undefined') { + throw new AppwriteException('Missing required parameter: "host"'); + } - const apiPath = '/messaging/providers/sendgrid'; + const apiPath = '/messaging/providers/smtp'; const payload: Payload = {}; if (typeof providerId !== 'undefined') { payload['providerId'] = providerId; @@ -2298,8 +3098,26 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv if (typeof name !== 'undefined') { payload['name'] = name; } - if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + if (typeof host !== 'undefined') { + payload['host'] = host; + } + if (typeof port !== 'undefined') { + payload['port'] = port; + } + if (typeof username !== 'undefined') { + payload['username'] = username; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof encryption !== 'undefined') { + payload['encryption'] = encryption; + } + if (typeof autoTLS !== 'undefined') { + payload['autoTLS'] = autoTLS; + } + if (typeof mailer !== 'undefined') { + payload['mailer'] = mailer; } if (typeof fromName !== 'undefined') { payload['fromName'] = fromName; @@ -2331,80 +3149,128 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv } /** - * Update a Sendgrid provider by its unique ID. + * Create a new SMTP provider. * - * @param {string} params.providerId - Provider ID. + * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} params.name - Provider name. - * @param {boolean} params.enabled - Set as enabled. - * @param {string} params.apiKey - Sendgrid API key. + * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} params.port - The default SMTP server port. + * @param {string} params.username - Authentication username. + * @param {string} params.password - Authentication password. + * @param {SmtpEncryption} params.encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. + * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. - * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. - * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ - updateSendgridProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }): Promise<Models.Provider>; + createSMTPProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; /** - * Update a Sendgrid provider by its unique ID. + * Create a new SMTP provider. * - * @param {string} providerId - Provider ID. + * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {string} name - Provider name. - * @param {boolean} enabled - Set as enabled. - * @param {string} apiKey - Sendgrid API key. + * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. + * @param {number} port - The default SMTP server port. + * @param {string} username - Authentication username. + * @param {string} password - Authentication password. + * @param {SmtpEncryption} encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. + * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. - * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. - * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. + * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. + * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSendgridProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider>; - updateSendgridProvider( - paramsOrFirst: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string } | string, - ...rest: [(string)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?] + createSMTPProvider(this: Messaging<ServerAuth>, providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + createSMTPProvider( + paramsOrFirst: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] ): Promise<Models.Provider> { - let params: { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + let params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string }; + params = (paramsOrFirst || {}) as { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; } else { params = { providerId: paramsOrFirst as string, name: rest[0] as string, - enabled: rest[1] as boolean, - apiKey: rest[2] as string, - fromName: rest[3] as string, - fromEmail: rest[4] as string, - replyToName: rest[5] as string, - replyToEmail: rest[6] as string + host: rest[1] as string, + port: rest[2] as number, + username: rest[3] as string, + password: rest[4] as string, + encryption: rest[5] as SmtpEncryption, + autoTLS: rest[6] as boolean, + mailer: rest[7] as string, + fromName: rest[8] as string, + fromEmail: rest[9] as string, + replyToName: rest[10] as string, + replyToEmail: rest[11] as string, + enabled: rest[12] as boolean }; } const providerId = params.providerId; const name = params.name; - const enabled = params.enabled; - const apiKey = params.apiKey; + const host = params.host; + const port = params.port; + const username = params.username; + const password = params.password; + const encryption = params.encryption; + const autoTLS = params.autoTLS; + const mailer = params.mailer; const fromName = params.fromName; const fromEmail = params.fromEmail; const replyToName = params.replyToName; const replyToEmail = params.replyToEmail; + const enabled = params.enabled; if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } + if (typeof name === 'undefined') { + throw new AppwriteException('Missing required parameter: "name"'); + } + if (typeof host === 'undefined') { + throw new AppwriteException('Missing required parameter: "host"'); + } - const apiPath = '/messaging/providers/sendgrid/{providerId}'.replace('{providerId}', providerId); + const apiPath = '/messaging/providers/smtp'; const payload: Payload = {}; + if (typeof providerId !== 'undefined') { + payload['providerId'] = providerId; + } if (typeof name !== 'undefined') { payload['name'] = name; } - if (typeof enabled !== 'undefined') { - payload['enabled'] = enabled; + if (typeof host !== 'undefined') { + payload['host'] = host; } - if (typeof apiKey !== 'undefined') { - payload['apiKey'] = apiKey; + if (typeof port !== 'undefined') { + payload['port'] = port; + } + if (typeof username !== 'undefined') { + payload['username'] = username; + } + if (typeof password !== 'undefined') { + payload['password'] = password; + } + if (typeof encryption !== 'undefined') { + payload['encryption'] = encryption; + } + if (typeof autoTLS !== 'undefined') { + payload['autoTLS'] = autoTLS; + } + if (typeof mailer !== 'undefined') { + payload['mailer'] = mailer; } if (typeof fromName !== 'undefined') { payload['fromName'] = fromName; @@ -2418,6 +3284,9 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv if (typeof replyToEmail !== 'undefined') { payload['replyToEmail'] = replyToEmail; } + if (typeof enabled !== 'undefined') { + payload['enabled'] = enabled; + } const uri = new URL(this.client.config.endpoint + apiPath); const apiHeaders: { [header: string]: string } = { @@ -2425,7 +3294,7 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv } return this.client.call( - 'patch', + 'post', uri, apiHeaders, payload @@ -2433,57 +3302,57 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv } /** - * Create a new SMTP provider. + * Update a SMTP provider by its unique ID. * - * @param {string} params.providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} params.providerId - Provider ID. * @param {string} params.name - Provider name. * @param {string} params.host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} params.port - The default SMTP server port. + * @param {number} params.port - SMTP port. * @param {string} params.username - Authentication username. * @param {string} params.password - Authentication password. - * @param {SmtpEncryption} params.encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {SmtpEncryption} params.encryption - Encryption type. Can be 'ssl' or 'tls' * @param {boolean} params.autoTLS - Enable SMTP AutoTLS feature. * @param {string} params.mailer - The value to use for the X-Mailer header. * @param {string} params.fromName - Sender Name. * @param {string} params.fromEmail - Sender email address. - * @param {string} params.replyToName - Name set in the reply to field for the mail. Default value is sender name. - * @param {string} params.replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {string} params.replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} params.replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. * @param {boolean} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} - * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.createSMTPProvider` instead. + * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. */ - createSmtpProvider(this: Messaging<ServerAuth>, params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + updateSmtpProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; /** - * Create a new SMTP provider. + * Update a SMTP provider by its unique ID. * - * @param {string} providerId - Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + * @param {string} providerId - Provider ID. * @param {string} name - Provider name. * @param {string} host - SMTP hosts. Either a single hostname or multiple semicolon-delimited hostnames. You can also specify a different port for each host such as `smtp1.example.com:25;smtp2.example.com`. You can also specify encryption type, for example: `tls://smtp1.example.com:587;ssl://smtp2.example.com:465"`. Hosts will be tried in order. - * @param {number} port - The default SMTP server port. + * @param {number} port - SMTP port. * @param {string} username - Authentication username. * @param {string} password - Authentication password. - * @param {SmtpEncryption} encryption - Encryption type. Can be omitted, 'ssl', or 'tls' + * @param {SmtpEncryption} encryption - Encryption type. Can be 'ssl' or 'tls' * @param {boolean} autoTLS - Enable SMTP AutoTLS feature. * @param {string} mailer - The value to use for the X-Mailer header. * @param {string} fromName - Sender Name. * @param {string} fromEmail - Sender email address. - * @param {string} replyToName - Name set in the reply to field for the mail. Default value is sender name. - * @param {string} replyToEmail - Email set in the reply to field for the mail. Default value is sender email. + * @param {string} replyToName - Name set in the Reply To field for the mail. Default value is Sender Name. + * @param {string} replyToEmail - Email set in the Reply To field for the mail. Default value is Sender Email. * @param {boolean} enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. */ - createSmtpProvider(this: Messaging<ServerAuth>, providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; - createSmtpProvider( - paramsOrFirst: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, + updateSmtpProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + updateSmtpProvider( + paramsOrFirst: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] ): Promise<Models.Provider> { - let params: { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + let params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; + params = (paramsOrFirst || {}) as { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }; } else { params = { providerId: paramsOrFirst as string, @@ -2521,18 +3390,9 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv if (typeof providerId === 'undefined') { throw new AppwriteException('Missing required parameter: "providerId"'); } - if (typeof name === 'undefined') { - throw new AppwriteException('Missing required parameter: "name"'); - } - if (typeof host === 'undefined') { - throw new AppwriteException('Missing required parameter: "host"'); - } - const apiPath = '/messaging/providers/smtp'; + const apiPath = '/messaging/providers/smtp/{providerId}'.replace('{providerId}', providerId); const payload: Payload = {}; - if (typeof providerId !== 'undefined') { - payload['providerId'] = providerId; - } if (typeof name !== 'undefined') { payload['name'] = name; } @@ -2579,7 +3439,7 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv } return this.client.call( - 'post', + 'patch', uri, apiHeaders, payload @@ -2605,9 +3465,8 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @param {boolean} params.enabled - Set as enabled. * @throws {AppwriteException} * @returns {Promise<Models.Provider>} - * @deprecated This API has been deprecated since 1.8.0. Please use `Messaging.updateSMTPProvider` instead. */ - updateSmtpProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; + updateSMTPProvider(this: Messaging<ServerAuth>, params: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean }): Promise<Models.Provider>; /** * Update a SMTP provider by its unique ID. * @@ -2629,8 +3488,8 @@ class MessagingRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @returns {Promise<Models.Provider>} * @deprecated Use the object parameter style method for a better developer experience. */ - updateSmtpProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; - updateSmtpProvider( + updateSMTPProvider(this: Messaging<ServerAuth>, providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; + updateSMTPProvider( paramsOrFirst: { providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean } | string, ...rest: [(string)?, (string)?, (number)?, (string)?, (string)?, (SmtpEncryption)?, (boolean)?, (string)?, (string)?, (string)?, (string)?, (string)?, (boolean)?] ): Promise<Models.Provider> { diff --git a/src/services/presences.ts b/src/services/presences.ts index fe696fc1..6ea7b001 100644 --- a/src/services/presences.ts +++ b/src/services/presences.ts @@ -3,7 +3,7 @@ import type { Models } from '../models'; type PresencesServerOnlyMethod = never; -type PresencesClientOnlyMethod = 'upsert' | 'update'; +type PresencesClientOnlyMethod = 'upsert' | 'update' | 'updatePresence'; export type Presences<TAuth extends ClientAuth | ServerAuth = ClientAuth | ServerAuth> = TAuth extends ClientAuth @@ -146,21 +146,107 @@ class PresencesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * * @param {string} params.presenceId - Presence unique ID. * @param {string} params.status - Presence status. - * @param {string} params.userId - User ID. * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {string} params.expiresAt - Presence expiry datetime. * @param {object} params.metadata - Presence metadata object. * @throws {AppwriteException} * @returns {Promise<Presence>} */ - upsert<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, params: { presenceId: string, status: string, userId?: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise<Presence>; + upsert<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, params: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise<Presence>; /** * Create or update a presence log by its user ID. * * * @param {string} presenceId - Presence unique ID. * @param {string} status - Presence status. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} expiresAt - Presence expiry datetime. + * @param {object} metadata - Presence metadata object. + * @throws {AppwriteException} + * @returns {Promise<Presence>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + upsert<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise<Presence>; + upsert<Presence extends Models.Presence = Models.DefaultPresence>( + paramsOrFirst: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object } | string, + ...rest: [(string)?, (string[])?, (string)?, (object)?] + ): Promise<Presence> { + let params: { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { presenceId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; + } else { + params = { + presenceId: paramsOrFirst as string, + status: rest[0] as string, + permissions: rest[1] as string[], + expiresAt: rest[2] as string, + metadata: rest[3] as object + }; + } + + const presenceId = params.presenceId; + const status = params.status; + const permissions = params.permissions; + const expiresAt = params.expiresAt; + const metadata = params.metadata; + + if (typeof presenceId === 'undefined') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + if (typeof status === 'undefined') { + throw new AppwriteException('Missing required parameter: "status"'); + } + + const apiPath = '/presences/{presenceId}'.replace('{presenceId}', presenceId); + const payload: Payload = {}; + if (typeof status !== 'undefined') { + payload['status'] = status; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof expiresAt !== 'undefined') { + payload['expiresAt'] = expiresAt; + } + if (typeof metadata !== 'undefined') { + payload['metadata'] = metadata; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + + /** + * Create or update a presence log by its user ID. + * + * + * @param {string} params.presenceId - Presence unique ID. + * @param {string} params.userId - User ID. + * @param {string} params.status - Presence status. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {string} params.expiresAt - Presence expiry datetime. + * @param {object} params.metadata - Presence metadata object. + * @throws {AppwriteException} + * @returns {Promise<Presence>} + */ + upsert<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, params: { presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }): Promise<Presence>; + /** + * Create or update a presence log by its user ID. + * + * + * @param {string} presenceId - Presence unique ID. * @param {string} userId - User ID. + * @param {string} status - Presence status. * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). * @param {string} expiresAt - Presence expiry datetime. * @param {object} metadata - Presence metadata object. @@ -168,20 +254,20 @@ class PresencesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @returns {Promise<Presence>} * @deprecated Use the object parameter style method for a better developer experience. */ - upsert<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, presenceId: string, status: string, userId?: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise<Presence>; + upsert<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object): Promise<Presence>; upsert<Presence extends Models.Presence = Models.DefaultPresence>( - paramsOrFirst: { presenceId: string, status: string, userId?: string, permissions?: string[], expiresAt?: string, metadata?: object } | string, + paramsOrFirst: { presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object } | string, ...rest: [(string)?, (string)?, (string[])?, (string)?, (object)?] ): Promise<Presence> { - let params: { presenceId: string, status: string, userId?: string, permissions?: string[], expiresAt?: string, metadata?: object }; + let params: { presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { presenceId: string, status: string, userId?: string, permissions?: string[], expiresAt?: string, metadata?: object }; + params = (paramsOrFirst || {}) as { presenceId: string, userId: string, status: string, permissions?: string[], expiresAt?: string, metadata?: object }; } else { params = { presenceId: paramsOrFirst as string, - status: rest[0] as string, - userId: rest[1] as string, + userId: rest[0] as string, + status: rest[1] as string, permissions: rest[2] as string[], expiresAt: rest[3] as string, metadata: rest[4] as object @@ -189,8 +275,8 @@ class PresencesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv } const presenceId = params.presenceId; - const status = params.status; const userId = params.userId; + const status = params.status; const permissions = params.permissions; const expiresAt = params.expiresAt; const metadata = params.metadata; @@ -198,6 +284,9 @@ class PresencesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv if (typeof presenceId === 'undefined') { throw new AppwriteException('Missing required parameter: "presenceId"'); } + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } if (typeof status === 'undefined') { throw new AppwriteException('Missing required parameter: "status"'); } @@ -233,6 +322,96 @@ class PresencesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv ); } + /** + * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * + * @param {string} params.presenceId - Presence unique ID. + * @param {string} params.status - Presence status. + * @param {string} params.expiresAt - Presence expiry datetime. + * @param {object} params.metadata - Presence metadata object. + * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} params.purge - When true, purge cached responses used by list presences endpoint. + * @throws {AppwriteException} + * @returns {Promise<Presence>} + */ + update<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, params: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise<Presence>; + /** + * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. + * + * + * @param {string} presenceId - Presence unique ID. + * @param {string} status - Presence status. + * @param {string} expiresAt - Presence expiry datetime. + * @param {object} metadata - Presence metadata object. + * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param {boolean} purge - When true, purge cached responses used by list presences endpoint. + * @throws {AppwriteException} + * @returns {Promise<Presence>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + update<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise<Presence>; + update<Presence extends Models.Presence = Models.DefaultPresence>( + paramsOrFirst: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean } | string, + ...rest: [(string)?, (string)?, (object)?, (string[])?, (boolean)?] + ): Promise<Presence> { + let params: { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { presenceId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; + } else { + params = { + presenceId: paramsOrFirst as string, + status: rest[0] as string, + expiresAt: rest[1] as string, + metadata: rest[2] as object, + permissions: rest[3] as string[], + purge: rest[4] as boolean + }; + } + + const presenceId = params.presenceId; + const status = params.status; + const expiresAt = params.expiresAt; + const metadata = params.metadata; + const permissions = params.permissions; + const purge = params.purge; + + if (typeof presenceId === 'undefined') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + + const apiPath = '/presences/{presenceId}'.replace('{presenceId}', presenceId); + const payload: Payload = {}; + if (typeof status !== 'undefined') { + payload['status'] = status; + } + if (typeof expiresAt !== 'undefined') { + payload['expiresAt'] = expiresAt; + } + if (typeof metadata !== 'undefined') { + payload['metadata'] = metadata; + } + if (typeof permissions !== 'undefined') { + payload['permissions'] = permissions; + } + if (typeof purge !== 'undefined') { + payload['purge'] = purge; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + /** * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -247,7 +426,7 @@ class PresencesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @throws {AppwriteException} * @returns {Promise<Presence>} */ - update<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, params: { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise<Presence>; + updatePresence<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, params: { presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }): Promise<Presence>; /** * Update a presence log by its unique ID. Using the patch method you can pass only specific fields that will get updated. * @@ -263,15 +442,15 @@ class PresencesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv * @returns {Promise<Presence>} * @deprecated Use the object parameter style method for a better developer experience. */ - update<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise<Presence>; - update<Presence extends Models.Presence = Models.DefaultPresence>( - paramsOrFirst: { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean } | string, + updatePresence<Presence extends Models.Presence = Models.DefaultPresence>(this: Presences<ClientAuth>, presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean): Promise<Presence>; + updatePresence<Presence extends Models.Presence = Models.DefaultPresence>( + paramsOrFirst: { presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean } | string, ...rest: [(string)?, (string)?, (string)?, (object)?, (string[])?, (boolean)?] ): Promise<Presence> { - let params: { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; + let params: { presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { presenceId: string, userId?: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; + params = (paramsOrFirst || {}) as { presenceId: string, userId: string, status?: string, expiresAt?: string, metadata?: object, permissions?: string[], purge?: boolean }; } else { params = { presenceId: paramsOrFirst as string, @@ -295,6 +474,9 @@ class PresencesRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serv if (typeof presenceId === 'undefined') { throw new AppwriteException('Missing required parameter: "presenceId"'); } + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } const apiPath = '/presences/{presenceId}'.replace('{presenceId}', presenceId); const payload: Payload = {}; diff --git a/src/services/tables-db.ts b/src/services/tables-db.ts index 2aa9c974..3e351951 100644 --- a/src/services/tables-db.ts +++ b/src/services/tables-db.ts @@ -5257,12 +5257,11 @@ class TablesDBRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serve * @param {string} params.rowId - Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} params.data - Row data as JSON object. * @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {object[]} params.rows - Array of rows data as JSON objects. * @param {string} params.transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} */ - createRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId?: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], rows?: object[], transactionId?: string }): Promise<Row>; + createRow<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string }): Promise<Row>; /** * Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. * @@ -5271,21 +5270,20 @@ class TablesDBRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serve * @param {string} rowId - Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. * @param {Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>} data - Row data as JSON object. * @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). - * @param {object[]} rows - Array of rows data as JSON objects. * @param {string} transactionId - Transaction ID for staging the operation. * @throws {AppwriteException} * @returns {Promise<Row>} * @deprecated Use the object parameter style method for a better developer experience. */ - createRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId?: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], rows?: object[], transactionId?: string): Promise<Row>; + createRow<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string): Promise<Row>; createRow<Row extends Models.Row = Models.DefaultRow>( - paramsOrFirst: { databaseId: string, tableId: string, rowId?: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], rows?: object[], transactionId?: string } | string, - ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, (string[])?, (object[])?, (string)?] + paramsOrFirst: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string } | string, + ...rest: [(string)?, (string)?, (Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>)?, (string[])?, (string)?] ): Promise<Row> { - let params: { databaseId: string, tableId: string, rowId?: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], rows?: object[], transactionId?: string }; + let params: { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string }; if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { - params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId?: string, data?: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], rows?: object[], transactionId?: string }; + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rowId: string, data: Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions?: string[], transactionId?: string }; } else { params = { databaseId: paramsOrFirst as string, @@ -5293,8 +5291,7 @@ class TablesDBRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serve rowId: rest[1] as string, data: rest[2] as Row extends Models.DefaultRow ? Partial<Models.Row> & Record<string, any> : Partial<Models.Row> & Omit<Row, keyof Models.Row>, permissions: rest[3] as string[], - rows: rest[4] as object[], - transactionId: rest[5] as string + transactionId: rest[4] as string }; } @@ -5303,7 +5300,6 @@ class TablesDBRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serve const rowId = params.rowId; const data = params.data; const permissions = params.permissions; - const rows = params.rows; const transactionId = params.transactionId; if (typeof databaseId === 'undefined') { @@ -5312,6 +5308,12 @@ class TablesDBRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serve if (typeof tableId === 'undefined') { throw new AppwriteException('Missing required parameter: "tableId"'); } + if (typeof rowId === 'undefined') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + if (typeof data === 'undefined') { + throw new AppwriteException('Missing required parameter: "data"'); + } const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); const payload: Payload = {}; @@ -5324,6 +5326,80 @@ class TablesDBRuntime<TAuth extends ClientAuth | ServerAuth = ClientAuth | Serve if (typeof permissions !== 'undefined') { payload['permissions'] = permissions; } + if (typeof transactionId !== 'undefined') { + payload['transactionId'] = transactionId; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'post', + uri, + apiHeaders, + payload + ); + } + + /** + * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. + * + * @param {string} params.databaseId - Database ID. + * @param {string} params.tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. + * @param {object[]} params.rows - Array of rows data as JSON objects. + * @param {string} params.transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + */ + createRows<Row extends Models.Row = Models.DefaultRow>(params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }): Promise<Models.RowList<Row>>; + /** + * Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable) API or directly from your database console. + * + * @param {string} databaseId - Database ID. + * @param {string} tableId - Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). Make sure to define columns before creating rows. + * @param {object[]} rows - Array of rows data as JSON objects. + * @param {string} transactionId - Transaction ID for staging the operation. + * @throws {AppwriteException} + * @returns {Promise<Models.RowList<Row>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createRows<Row extends Models.Row = Models.DefaultRow>(databaseId: string, tableId: string, rows: object[], transactionId?: string): Promise<Models.RowList<Row>>; + createRows<Row extends Models.Row = Models.DefaultRow>( + paramsOrFirst: { databaseId: string, tableId: string, rows: object[], transactionId?: string } | string, + ...rest: [(string)?, (object[])?, (string)?] + ): Promise<Models.RowList<Row>> { + let params: { databaseId: string, tableId: string, rows: object[], transactionId?: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { databaseId: string, tableId: string, rows: object[], transactionId?: string }; + } else { + params = { + databaseId: paramsOrFirst as string, + tableId: rest[0] as string, + rows: rest[1] as object[], + transactionId: rest[2] as string + }; + } + + const databaseId = params.databaseId; + const tableId = params.tableId; + const rows = params.rows; + const transactionId = params.transactionId; + + if (typeof databaseId === 'undefined') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + if (typeof tableId === 'undefined') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + if (typeof rows === 'undefined') { + throw new AppwriteException('Missing required parameter: "rows"'); + } + + const apiPath = '/tablesdb/{databaseId}/tables/{tableId}/rows'.replace('{databaseId}', databaseId).replace('{tableId}', tableId); + const payload: Payload = {}; if (typeof rows !== 'undefined') { payload['rows'] = rows; } diff --git a/src/services/users.ts b/src/services/users.ts index dc82ee16..46e89596 100644 --- a/src/services/users.ts +++ b/src/services/users.ts @@ -1518,6 +1518,69 @@ class UsersRuntime { ); } + /** + * Enable or disable MFA on a user account. + * + * @param {string} params.userId - User ID. + * @param {boolean} params.mfa - Enable or disable MFA. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + */ + updateMFA<Preferences extends Models.Preferences = Models.DefaultPreferences>(params: { userId: string, mfa: boolean }): Promise<Models.User<Preferences>>; + /** + * Enable or disable MFA on a user account. + * + * @param {string} userId - User ID. + * @param {boolean} mfa - Enable or disable MFA. + * @throws {AppwriteException} + * @returns {Promise<Models.User<Preferences>>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMFA<Preferences extends Models.Preferences = Models.DefaultPreferences>(userId: string, mfa: boolean): Promise<Models.User<Preferences>>; + updateMFA<Preferences extends Models.Preferences = Models.DefaultPreferences>( + paramsOrFirst: { userId: string, mfa: boolean } | string, + ...rest: [(boolean)?] + ): Promise<Models.User<Preferences>> { + let params: { userId: string, mfa: boolean }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, mfa: boolean }; + } else { + params = { + userId: paramsOrFirst as string, + mfa: rest[0] as boolean + }; + } + + const userId = params.userId; + const mfa = params.mfa; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof mfa === 'undefined') { + throw new AppwriteException('Missing required parameter: "mfa"'); + } + + const apiPath = '/users/{userId}/mfa'.replace('{userId}', userId); + const payload: Payload = {}; + if (typeof mfa !== 'undefined') { + payload['mfa'] = mfa; + } + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + /** * Delete an authenticator app. * @@ -1579,6 +1642,66 @@ class UsersRuntime { ); } + /** + * Delete an authenticator app. + * + * @param {string} params.userId - User ID. + * @param {AuthenticatorType} params.type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + */ + deleteMFAAuthenticator(params: { userId: string, type: AuthenticatorType }): Promise<{}>; + /** + * Delete an authenticator app. + * + * @param {string} userId - User ID. + * @param {AuthenticatorType} type - Type of authenticator. + * @throws {AppwriteException} + * @returns {Promise<{}>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + deleteMFAAuthenticator(userId: string, type: AuthenticatorType): Promise<{}>; + deleteMFAAuthenticator( + paramsOrFirst: { userId: string, type: AuthenticatorType } | string, + ...rest: [(AuthenticatorType)?] + ): Promise<{}> { + let params: { userId: string, type: AuthenticatorType }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string, type: AuthenticatorType }; + } else { + params = { + userId: paramsOrFirst as string, + type: rest[0] as AuthenticatorType + }; + } + + const userId = params.userId; + const type = params.type; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + if (typeof type === 'undefined') { + throw new AppwriteException('Missing required parameter: "type"'); + } + + const apiPath = '/users/{userId}/mfa/authenticators/{type}'.replace('{userId}', userId).replace('{type}', type); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'delete', + uri, + apiHeaders, + payload + ); + } + /** * List the factors available on the account to be used as a MFA challange. * @@ -1631,6 +1754,57 @@ class UsersRuntime { ); } + /** + * List the factors available on the account to be used as a MFA challange. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaFactors>} + */ + listMFAFactors(params: { userId: string }): Promise<Models.MfaFactors>; + /** + * List the factors available on the account to be used as a MFA challange. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaFactors>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + listMFAFactors(userId: string): Promise<Models.MfaFactors>; + listMFAFactors( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaFactors> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/factors'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + /** * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -1683,6 +1857,57 @@ class UsersRuntime { ); } + /** + * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + */ + getMFARecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + getMFARecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + getMFARecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + } + + return this.client.call( + 'get', + uri, + apiHeaders, + payload + ); + } + /** * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. * @@ -1736,6 +1961,58 @@ class UsersRuntime { ); } + /** + * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + */ + updateMFARecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + updateMFARecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + updateMFARecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'put', + uri, + apiHeaders, + payload + ); + } + /** * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. * @@ -1789,6 +2066,58 @@ class UsersRuntime { ); } + /** + * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. + * + * @param {string} params.userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + */ + createMFARecoveryCodes(params: { userId: string }): Promise<Models.MfaRecoveryCodes>; + /** + * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK. + * + * @param {string} userId - User ID. + * @throws {AppwriteException} + * @returns {Promise<Models.MfaRecoveryCodes>} + * @deprecated Use the object parameter style method for a better developer experience. + */ + createMFARecoveryCodes(userId: string): Promise<Models.MfaRecoveryCodes>; + createMFARecoveryCodes( + paramsOrFirst: { userId: string } | string + ): Promise<Models.MfaRecoveryCodes> { + let params: { userId: string }; + + if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { + params = (paramsOrFirst || {}) as { userId: string }; + } else { + params = { + userId: paramsOrFirst as string + }; + } + + const userId = params.userId; + + if (typeof userId === 'undefined') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + const apiPath = '/users/{userId}/mfa/recovery-codes'.replace('{userId}', userId); + const payload: Payload = {}; + const uri = new URL(this.client.config.endpoint + apiPath); + + const apiHeaders: { [header: string]: string } = { + 'content-type': 'application/json', + } + + return this.client.call( + 'patch', + uri, + apiHeaders, + payload + ); + } + /** * Update the user name by its unique ID. *