diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b98c445..e925de15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Change Log +## 29.4.0 + +* Added: `domains` service to register, transfer and manage domains, DNS records, email presets and zones +* Added: `waf` service with bypass, challenge, deny, rate-limit and redirect rules +* Added: `account.createEmailVerificationOTP`, `updateEmailVerificationOTP`, `createRecoveryOTP` and `updateRecoveryOTP` +* Added: `account.createIdTokenSession` and `Identity.providerIdToken` +* Added: `oauth2.introspect` +* Added: project environments with `project.createEnvironment`, `getEnvironment`, `listEnvironments`, `updateEnvironment` and `deleteEnvironment` +* Added: `organization.createEphemeralProjectKey`, `listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` +* Added: Kakao, TikTok and Webflow OAuth2 providers with `project.updateOAuth2Kakao`, `updateOAuth2TikTok` and `updateOAuth2Webflow` +* Added: optional `prompt` on the Auth0, Discord, GitHub, Microsoft, Okta, Salesforce and Zoho OAuth2 settings, and native client IDs on Apple and Google +* Added: `project.updatePasswordPwnedPolicy`, `project.updatePasswordRotationPolicy` and `User.passwordPwned` +* Added: `messaging.createAppwriteProvider` and `messaging.updateAppwriteProvider` +* Added: optional `replyToEmail` and `replyToName` on email messages, `channelId` on push messages, and `qos` and `expiry` on topics +* Added: `avatars.updatePhoto` and `avatars.deletePhoto` +* Added: optional `duration` on `account.createEmailPasswordSession`, `current` on `account.deleteSessions`, `membershipId` on `teams.createMembership` and `fingerprints` on Android platforms +* Added: optional `total` on the locale, transaction, runtime, specification and framework lists +* Added: `dart-3.13` and `flutter-3.47` runtimes, the `jaspr` framework, the `trigram` index type, `auto` image gravity, the `dedicatedDatabase` proxy rule resource type, OTP email templates and new key scopes +* Added: optional fields on `BillingPlan`, `DedicatedDatabase`, `DedicatedDatabaseSpecification`, `Project` and `Topic`, and `free` and `start` in `BillingPlanGroup` + ## 29.3.1 * Fixed: added `ProjectAuthMethodId.passkey`, so `project.updateAuthMethod` can enable passkeys diff --git a/README.md b/README.md index f0f1b661..b2bbc081 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file: ```yml dependencies: - dart_appwrite: ^29.3.1 + dart_appwrite: ^29.4.0 ``` You can install packages from the command line: diff --git a/docs/examples/account/create-email-password-session.md b/docs/examples/account/create-email-password-session.md index bac35a12..feefb53c 100644 --- a/docs/examples/account/create-email-password-session.md +++ b/docs/examples/account/create-email-password-session.md @@ -11,5 +11,6 @@ Account account = Account(client); Session result = await account.createEmailPasswordSession( email: 'email@example.com', password: 'password', + duration: 60, // (optional) ); ``` diff --git a/docs/examples/account/create-email-verification-otp.md b/docs/examples/account/create-email-verification-otp.md new file mode 100644 index 00000000..0e50ccb9 --- /dev/null +++ b/docs/examples/account/create-email-verification-otp.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +models.Token result = await account.createEmailVerificationOTP( + phrase: false, // (optional) +); +``` diff --git a/docs/examples/account/create-id-token-session.md b/docs/examples/account/create-id-token-session.md new file mode 100644 index 00000000..af36dbd8 --- /dev/null +++ b/docs/examples/account/create-id-token-session.md @@ -0,0 +1,21 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +models.Session result = await account.createIdTokenSession( + provider: enums.IdTokenProvider.apple, + idToken: '', + nonce: '', // (optional) + accessToken: '', // (optional) + accessTokenExpiry: 0, // (optional) + name: '', // (optional) +); +``` diff --git a/docs/examples/account/create-recovery-otp.md b/docs/examples/account/create-recovery-otp.md new file mode 100644 index 00000000..29fdb179 --- /dev/null +++ b/docs/examples/account/create-recovery-otp.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +models.Token result = await account.createRecoveryOTP( + email: 'email@example.com', + phrase: false, // (optional) +); +``` diff --git a/docs/examples/account/delete-sessions.md b/docs/examples/account/delete-sessions.md index 2b7f5b81..e1f611e3 100644 --- a/docs/examples/account/delete-sessions.md +++ b/docs/examples/account/delete-sessions.md @@ -8,5 +8,7 @@ Client client = Client() Account account = Account(client); -await account.deleteSessions(); +await account.deleteSessions( + current: false, // (optional) +); ``` diff --git a/docs/examples/account/list-sessions.md b/docs/examples/account/list-sessions.md index 53c0d220..d582ecba 100644 --- a/docs/examples/account/list-sessions.md +++ b/docs/examples/account/list-sessions.md @@ -8,5 +8,7 @@ Client client = Client() Account account = Account(client); -SessionList result = await account.listSessions(); +SessionList result = await account.listSessions( + total: false, // (optional) +); ``` diff --git a/docs/examples/account/update-email-verification-otp.md b/docs/examples/account/update-email-verification-otp.md new file mode 100644 index 00000000..47bf4ce4 --- /dev/null +++ b/docs/examples/account/update-email-verification-otp.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +models.Token result = await account.updateEmailVerificationOTP( + userId: '', + secret: '', +); +``` diff --git a/docs/examples/account/update-recovery-otp.md b/docs/examples/account/update-recovery-otp.md new file mode 100644 index 00000000..b2e04970 --- /dev/null +++ b/docs/examples/account/update-recovery-otp.md @@ -0,0 +1,17 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +Account account = Account(client); + +models.Token result = await account.updateRecoveryOTP( + userId: '', + secret: '', + password: 'password', +); +``` diff --git a/docs/examples/avatars/delete-photo.md b/docs/examples/avatars/delete-photo.md new file mode 100644 index 00000000..a3044382 --- /dev/null +++ b/docs/examples/avatars/delete-photo.md @@ -0,0 +1,12 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +Avatars avatars = Avatars(client); + +await avatars.deletePhoto(); +``` diff --git a/docs/examples/avatars/update-photo.md b/docs/examples/avatars/update-photo.md new file mode 100644 index 00000000..5220fd27 --- /dev/null +++ b/docs/examples/avatars/update-photo.md @@ -0,0 +1,16 @@ +```dart +import 'dart:io'; +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setSession(''); // The user session to authenticate with + +Avatars avatars = Avatars(client); + +models.Account result = await avatars.updatePhoto( + file: InputFile(path: './path-to-files/image.jpg', filename: 'image.jpg'), +); +``` diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md index 07a73e26..39b49d5e 100644 --- a/docs/examples/databases/list-transactions.md +++ b/docs/examples/databases/list-transactions.md @@ -10,5 +10,6 @@ Databases databases = Databases(client); TransactionList result = await databases.listTransactions( queries: [], // (optional) + total: false, // (optional) ); ``` diff --git a/docs/examples/documentsdb/list-transactions.md b/docs/examples/documentsdb/list-transactions.md index 066ebfe5..76c78ba5 100644 --- a/docs/examples/documentsdb/list-transactions.md +++ b/docs/examples/documentsdb/list-transactions.md @@ -10,5 +10,6 @@ DocumentsDB documentsDB = DocumentsDB(client); TransactionList result = await documentsDB.listTransactions( queries: [], // (optional) + total: false, // (optional) ); ``` diff --git a/docs/examples/domains/create-preset-google-workspace.md b/docs/examples/domains/create-preset-google-workspace.md new file mode 100644 index 00000000..bcac9000 --- /dev/null +++ b/docs/examples/domains/create-preset-google-workspace.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.createPresetGoogleWorkspace( + domainId: '', +); +``` diff --git a/docs/examples/domains/create-preset-i-cloud.md b/docs/examples/domains/create-preset-i-cloud.md new file mode 100644 index 00000000..901f90c0 --- /dev/null +++ b/docs/examples/domains/create-preset-i-cloud.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.createPresetICloud( + domainId: '', +); +``` diff --git a/docs/examples/domains/create-preset-mailgun.md b/docs/examples/domains/create-preset-mailgun.md new file mode 100644 index 00000000..79c08fee --- /dev/null +++ b/docs/examples/domains/create-preset-mailgun.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.createPresetMailgun( + domainId: '', +); +``` diff --git a/docs/examples/domains/create-preset-outlook.md b/docs/examples/domains/create-preset-outlook.md new file mode 100644 index 00000000..3fc51716 --- /dev/null +++ b/docs/examples/domains/create-preset-outlook.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.createPresetOutlook( + domainId: '', +); +``` diff --git a/docs/examples/domains/create-preset-proton-mail.md b/docs/examples/domains/create-preset-proton-mail.md new file mode 100644 index 00000000..313ce10f --- /dev/null +++ b/docs/examples/domains/create-preset-proton-mail.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.createPresetProtonMail( + domainId: '', +); +``` diff --git a/docs/examples/domains/create-preset-zoho.md b/docs/examples/domains/create-preset-zoho.md new file mode 100644 index 00000000..9e5630e3 --- /dev/null +++ b/docs/examples/domains/create-preset-zoho.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.createPresetZoho( + domainId: '', +); +``` diff --git a/docs/examples/domains/create-record-a.md b/docs/examples/domains/create-record-a.md new file mode 100644 index 00000000..38dc338e --- /dev/null +++ b/docs/examples/domains/create-record-a.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.createRecordA( + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/create-record-aaaa.md b/docs/examples/domains/create-record-aaaa.md new file mode 100644 index 00000000..cb03036f --- /dev/null +++ b/docs/examples/domains/create-record-aaaa.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.createRecordAAAA( + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/create-record-alias.md b/docs/examples/domains/create-record-alias.md new file mode 100644 index 00000000..50b4b168 --- /dev/null +++ b/docs/examples/domains/create-record-alias.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.createRecordAlias( + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/create-record-caa.md b/docs/examples/domains/create-record-caa.md new file mode 100644 index 00000000..5bf3429d --- /dev/null +++ b/docs/examples/domains/create-record-caa.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.createRecordCAA( + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/create-record-cname.md b/docs/examples/domains/create-record-cname.md new file mode 100644 index 00000000..7c8e5253 --- /dev/null +++ b/docs/examples/domains/create-record-cname.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.createRecordCNAME( + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/create-record-https.md b/docs/examples/domains/create-record-https.md new file mode 100644 index 00000000..d64bc918 --- /dev/null +++ b/docs/examples/domains/create-record-https.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.createRecordHTTPS( + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/create-record-mx.md b/docs/examples/domains/create-record-mx.md new file mode 100644 index 00000000..b01cceed --- /dev/null +++ b/docs/examples/domains/create-record-mx.md @@ -0,0 +1,20 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.createRecordMX( + domainId: '', + name: '', + value: '', + ttl: 1, + priority: 0, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/create-record-ns.md b/docs/examples/domains/create-record-ns.md new file mode 100644 index 00000000..b7bc8e08 --- /dev/null +++ b/docs/examples/domains/create-record-ns.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.createRecordNS( + domainId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/create-record-srv.md b/docs/examples/domains/create-record-srv.md new file mode 100644 index 00000000..2da7bdb6 --- /dev/null +++ b/docs/examples/domains/create-record-srv.md @@ -0,0 +1,22 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.createRecordSRV( + domainId: '', + name: '', + value: '', + ttl: 1, + priority: 0, + weight: 0, + port: 0, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/create-record-txt.md b/docs/examples/domains/create-record-txt.md new file mode 100644 index 00000000..4600f423 --- /dev/null +++ b/docs/examples/domains/create-record-txt.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.createRecordTXT( + domainId: '', + name: '', + ttl: 1, + value: '', // (optional) + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/create.md b/docs/examples/domains/create.md new file mode 100644 index 00000000..2fc56283 --- /dev/null +++ b/docs/examples/domains/create.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.Domain result = await domains.create( + teamId: '', + domain: 'example.com', +); +``` diff --git a/docs/examples/domains/delete-record.md b/docs/examples/domains/delete-record.md new file mode 100644 index 00000000..42cd807e --- /dev/null +++ b/docs/examples/domains/delete-record.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +await domains.deleteRecord( + domainId: '', + recordId: '', +); +``` diff --git a/docs/examples/domains/delete.md b/docs/examples/domains/delete.md new file mode 100644 index 00000000..cb464a89 --- /dev/null +++ b/docs/examples/domains/delete.md @@ -0,0 +1,14 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +await domains.delete( + domainId: '', +); +``` diff --git a/docs/examples/domains/get-preset-google-workspace.md b/docs/examples/domains/get-preset-google-workspace.md new file mode 100644 index 00000000..6f5798d0 --- /dev/null +++ b/docs/examples/domains/get-preset-google-workspace.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.getPresetGoogleWorkspace( + domainId: '', +); +``` diff --git a/docs/examples/domains/get-preset-i-cloud.md b/docs/examples/domains/get-preset-i-cloud.md new file mode 100644 index 00000000..d52412a3 --- /dev/null +++ b/docs/examples/domains/get-preset-i-cloud.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.getPresetICloud( + domainId: '', +); +``` diff --git a/docs/examples/domains/get-preset-mailgun.md b/docs/examples/domains/get-preset-mailgun.md new file mode 100644 index 00000000..36bb3900 --- /dev/null +++ b/docs/examples/domains/get-preset-mailgun.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.getPresetMailgun( + domainId: '', +); +``` diff --git a/docs/examples/domains/get-preset-outlook.md b/docs/examples/domains/get-preset-outlook.md new file mode 100644 index 00000000..46af4c13 --- /dev/null +++ b/docs/examples/domains/get-preset-outlook.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.getPresetOutlook( + domainId: '', +); +``` diff --git a/docs/examples/domains/get-preset-proton-mail.md b/docs/examples/domains/get-preset-proton-mail.md new file mode 100644 index 00000000..dbe33914 --- /dev/null +++ b/docs/examples/domains/get-preset-proton-mail.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.getPresetProtonMail( + domainId: '', +); +``` diff --git a/docs/examples/domains/get-preset-zoho.md b/docs/examples/domains/get-preset-zoho.md new file mode 100644 index 00000000..1dec97be --- /dev/null +++ b/docs/examples/domains/get-preset-zoho.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.getPresetZoho( + domainId: '', +); +``` diff --git a/docs/examples/domains/get-price.md b/docs/examples/domains/get-price.md new file mode 100644 index 00000000..66af0251 --- /dev/null +++ b/docs/examples/domains/get-price.md @@ -0,0 +1,18 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DomainPrice result = await domains.getPrice( + domain: 'example.com', + periodYears: 0, // (optional) + registrationType: enums.DomainRegistrationType.new, // (optional) +); +``` diff --git a/docs/examples/domains/get-record.md b/docs/examples/domains/get-record.md new file mode 100644 index 00000000..3908e0cc --- /dev/null +++ b/docs/examples/domains/get-record.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.getRecord( + domainId: '', + recordId: '', +); +``` diff --git a/docs/examples/domains/get-transfer-status.md b/docs/examples/domains/get-transfer-status.md new file mode 100644 index 00000000..5fd7cc0f --- /dev/null +++ b/docs/examples/domains/get-transfer-status.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DomainTransferStatus result = await domains.getTransferStatus( + domainId: '', +); +``` diff --git a/docs/examples/domains/get-zone.md b/docs/examples/domains/get-zone.md new file mode 100644 index 00000000..ff3bb6c9 --- /dev/null +++ b/docs/examples/domains/get-zone.md @@ -0,0 +1,14 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models. result = await domains.getZone( + domainId: '', +); +``` diff --git a/docs/examples/domains/get.md b/docs/examples/domains/get.md new file mode 100644 index 00000000..1d578e89 --- /dev/null +++ b/docs/examples/domains/get.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.Domain result = await domains.get( + domainId: '', +); +``` diff --git a/docs/examples/domains/list-prices.md b/docs/examples/domains/list-prices.md new file mode 100644 index 00000000..879768ff --- /dev/null +++ b/docs/examples/domains/list-prices.md @@ -0,0 +1,18 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DomainPricesList result = await domains.listPrices( + domains: [], + periodYears: 0, // (optional) + registrationType: enums.DomainRegistrationType.new, // (optional) +); +``` diff --git a/docs/examples/domains/list-records.md b/docs/examples/domains/list-records.md new file mode 100644 index 00000000..e15822cc --- /dev/null +++ b/docs/examples/domains/list-records.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecordsList result = await domains.listRecords( + domainId: '', + queries: [], // (optional) +); +``` diff --git a/docs/examples/domains/list.md b/docs/examples/domains/list.md new file mode 100644 index 00000000..d5722756 --- /dev/null +++ b/docs/examples/domains/list.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DomainsList result = await domains.list( + queries: [], // (optional) + search: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-nameservers.md b/docs/examples/domains/update-nameservers.md new file mode 100644 index 00000000..c0216722 --- /dev/null +++ b/docs/examples/domains/update-nameservers.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.Domain result = await domains.updateNameservers( + domainId: '', + nameservers: [], // (optional) +); +``` diff --git a/docs/examples/domains/update-record-a.md b/docs/examples/domains/update-record-a.md new file mode 100644 index 00000000..f02d93b7 --- /dev/null +++ b/docs/examples/domains/update-record-a.md @@ -0,0 +1,20 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.updateRecordA( + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-record-aaaa.md b/docs/examples/domains/update-record-aaaa.md new file mode 100644 index 00000000..8abf2a53 --- /dev/null +++ b/docs/examples/domains/update-record-aaaa.md @@ -0,0 +1,20 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.updateRecordAAAA( + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-record-alias.md b/docs/examples/domains/update-record-alias.md new file mode 100644 index 00000000..8320f3fb --- /dev/null +++ b/docs/examples/domains/update-record-alias.md @@ -0,0 +1,20 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.updateRecordAlias( + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-record-caa.md b/docs/examples/domains/update-record-caa.md new file mode 100644 index 00000000..8260888f --- /dev/null +++ b/docs/examples/domains/update-record-caa.md @@ -0,0 +1,20 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.updateRecordCAA( + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-record-cname.md b/docs/examples/domains/update-record-cname.md new file mode 100644 index 00000000..b2a9a52c --- /dev/null +++ b/docs/examples/domains/update-record-cname.md @@ -0,0 +1,20 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.updateRecordCNAME( + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-record-https.md b/docs/examples/domains/update-record-https.md new file mode 100644 index 00000000..6fa34a4b --- /dev/null +++ b/docs/examples/domains/update-record-https.md @@ -0,0 +1,20 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.updateRecordHTTPS( + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-record-mx.md b/docs/examples/domains/update-record-mx.md new file mode 100644 index 00000000..6a45c2b4 --- /dev/null +++ b/docs/examples/domains/update-record-mx.md @@ -0,0 +1,21 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.updateRecordMX( + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + priority: 0, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-record-ns.md b/docs/examples/domains/update-record-ns.md new file mode 100644 index 00000000..99fd0054 --- /dev/null +++ b/docs/examples/domains/update-record-ns.md @@ -0,0 +1,20 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.updateRecordNS( + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-record-srv.md b/docs/examples/domains/update-record-srv.md new file mode 100644 index 00000000..0bc500d9 --- /dev/null +++ b/docs/examples/domains/update-record-srv.md @@ -0,0 +1,23 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.updateRecordSRV( + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + priority: 0, + weight: 0, + port: 0, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-record-txt.md b/docs/examples/domains/update-record-txt.md new file mode 100644 index 00000000..58cf9cc3 --- /dev/null +++ b/docs/examples/domains/update-record-txt.md @@ -0,0 +1,20 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.DnsRecord result = await domains.updateRecordTXT( + domainId: '', + recordId: '', + name: '', + value: '', + ttl: 1, + comment: '', // (optional) +); +``` diff --git a/docs/examples/domains/update-team.md b/docs/examples/domains/update-team.md new file mode 100644 index 00000000..f08ab4c2 --- /dev/null +++ b/docs/examples/domains/update-team.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.Domain result = await domains.updateTeam( + domainId: '', + teamId: '', +); +``` diff --git a/docs/examples/domains/update-zone.md b/docs/examples/domains/update-zone.md new file mode 100644 index 00000000..6ff6711a --- /dev/null +++ b/docs/examples/domains/update-zone.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.Domain result = await domains.updateZone( + domainId: '', + content: '', +); +``` diff --git a/docs/examples/domains/verify-nameservers.md b/docs/examples/domains/verify-nameservers.md new file mode 100644 index 00000000..6609058d --- /dev/null +++ b/docs/examples/domains/verify-nameservers.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Domains domains = Domains(client); + +models.Domain result = await domains.verifyNameservers( + domainId: '', +); +``` diff --git a/docs/examples/functions/list-runtimes.md b/docs/examples/functions/list-runtimes.md index 6325f4e4..29b84b19 100644 --- a/docs/examples/functions/list-runtimes.md +++ b/docs/examples/functions/list-runtimes.md @@ -8,5 +8,7 @@ Client client = Client() Functions functions = Functions(client); -RuntimeList result = await functions.listRuntimes(); +RuntimeList result = await functions.listRuntimes( + total: false, // (optional) +); ``` diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index be35d601..07d82f31 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -10,5 +10,6 @@ Functions functions = Functions(client); SpecificationList result = await functions.listSpecifications( type: 'runtimes', // (optional) + total: false, // (optional) ); ``` diff --git a/docs/examples/locale/list-codes.md b/docs/examples/locale/list-codes.md index c8b2490d..7b753018 100644 --- a/docs/examples/locale/list-codes.md +++ b/docs/examples/locale/list-codes.md @@ -8,5 +8,7 @@ Client client = Client() Locale locale = Locale(client); -LocaleCodeList result = await locale.listCodes(); +LocaleCodeList result = await locale.listCodes( + total: false, // (optional) +); ``` diff --git a/docs/examples/locale/list-continents.md b/docs/examples/locale/list-continents.md index 5d96631b..09de6d83 100644 --- a/docs/examples/locale/list-continents.md +++ b/docs/examples/locale/list-continents.md @@ -8,5 +8,7 @@ Client client = Client() Locale locale = Locale(client); -ContinentList result = await locale.listContinents(); +ContinentList result = await locale.listContinents( + total: false, // (optional) +); ``` diff --git a/docs/examples/locale/list-countries-eu.md b/docs/examples/locale/list-countries-eu.md index 191be949..cd49b0bd 100644 --- a/docs/examples/locale/list-countries-eu.md +++ b/docs/examples/locale/list-countries-eu.md @@ -8,5 +8,7 @@ Client client = Client() Locale locale = Locale(client); -CountryList result = await locale.listCountriesEU(); +CountryList result = await locale.listCountriesEU( + total: false, // (optional) +); ``` diff --git a/docs/examples/locale/list-countries-phones.md b/docs/examples/locale/list-countries-phones.md index 00ec7810..771b6e5c 100644 --- a/docs/examples/locale/list-countries-phones.md +++ b/docs/examples/locale/list-countries-phones.md @@ -8,5 +8,7 @@ Client client = Client() Locale locale = Locale(client); -PhoneList result = await locale.listCountriesPhones(); +PhoneList result = await locale.listCountriesPhones( + total: false, // (optional) +); ``` diff --git a/docs/examples/locale/list-countries.md b/docs/examples/locale/list-countries.md index 62da933f..207732cd 100644 --- a/docs/examples/locale/list-countries.md +++ b/docs/examples/locale/list-countries.md @@ -8,5 +8,7 @@ Client client = Client() Locale locale = Locale(client); -CountryList result = await locale.listCountries(); +CountryList result = await locale.listCountries( + total: false, // (optional) +); ``` diff --git a/docs/examples/locale/list-currencies.md b/docs/examples/locale/list-currencies.md index c1029630..8bc09de2 100644 --- a/docs/examples/locale/list-currencies.md +++ b/docs/examples/locale/list-currencies.md @@ -8,5 +8,7 @@ Client client = Client() Locale locale = Locale(client); -CurrencyList result = await locale.listCurrencies(); +CurrencyList result = await locale.listCurrencies( + total: false, // (optional) +); ``` diff --git a/docs/examples/locale/list-languages.md b/docs/examples/locale/list-languages.md index 29712840..2142de0b 100644 --- a/docs/examples/locale/list-languages.md +++ b/docs/examples/locale/list-languages.md @@ -8,5 +8,7 @@ Client client = Client() Locale locale = Locale(client); -LanguageList result = await locale.listLanguages(); +LanguageList result = await locale.listLanguages( + total: false, // (optional) +); ``` diff --git a/docs/examples/messaging/create-appwrite-provider.md b/docs/examples/messaging/create-appwrite-provider.md new file mode 100644 index 00000000..def33da7 --- /dev/null +++ b/docs/examples/messaging/create-appwrite-provider.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Messaging messaging = Messaging(client); + +models.Provider result = await messaging.createAppwriteProvider( + providerId: '', + name: '', + enabled: false, // (optional) + qos: 0, // (optional) + expiry: 0, // (optional) +); +``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index f31414eb..c51fab0a 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -21,5 +21,7 @@ Message result = await messaging.createEmail( draft: false, // (optional) html: false, // (optional) scheduledAt: '2020-10-15T06:38:00.000+00:00', // (optional) + replyToEmail: 'email@example.com', // (optional) + replyToName: '', // (optional) ); ``` diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 0e28197b..0518f55f 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -29,5 +29,6 @@ Message result = await messaging.createPush( contentAvailable: false, // (optional) critical: false, // (optional) priority: enums.MessagePriority.normal, // (optional) + channelId: '', // (optional) ); ``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index 1414bd0c..6d8b62b3 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -12,5 +12,7 @@ Topic result = await messaging.createTopic( topicId: '', name: '', subscribe: ["any"], // (optional) + qos: 0, // (optional) + expiry: 0, // (optional) ); ``` diff --git a/docs/examples/messaging/update-appwrite-provider.md b/docs/examples/messaging/update-appwrite-provider.md new file mode 100644 index 00000000..0a4e4578 --- /dev/null +++ b/docs/examples/messaging/update-appwrite-provider.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Messaging messaging = Messaging(client); + +models.Provider result = await messaging.updateAppwriteProvider( + providerId: '', + name: '', // (optional) + enabled: false, // (optional) + qos: 0, // (optional) + expiry: 0, // (optional) +); +``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index c78a42fd..817f8a3f 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -21,5 +21,7 @@ Message result = await messaging.updateEmail( bcc: [], // (optional) scheduledAt: '2020-10-15T06:38:00.000+00:00', // (optional) attachments: [], // (optional) + replyToEmail: 'email@example.com', // (optional) + replyToName: '', // (optional) ); ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 17b347e4..b1f44f9e 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -29,5 +29,6 @@ Message result = await messaging.updatePush( contentAvailable: false, // (optional) critical: false, // (optional) priority: enums.MessagePriority.normal, // (optional) + channelId: '', // (optional) ); ``` diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index 44881272..2c6bbc7e 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -12,5 +12,7 @@ Topic result = await messaging.updateTopic( topicId: '', name: '', // (optional) subscribe: ["any"], // (optional) + qos: 0, // (optional) + expiry: 0, // (optional) ); ``` diff --git a/docs/examples/oauth2/introspect.md b/docs/examples/oauth2/introspect.md new file mode 100644 index 00000000..377797ba --- /dev/null +++ b/docs/examples/oauth2/introspect.md @@ -0,0 +1,18 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Oauth2 oauth2 = Oauth2(client); + +models.Oauth2Introspection result = await oauth2.introspect( + token: '', + tokenTypeHint: 'access_token', // (optional) + clientId: '', // (optional) + clientSecret: '', // (optional) +); +``` diff --git a/docs/examples/organization/create-ephemeral-project-key.md b/docs/examples/organization/create-ephemeral-project-key.md new file mode 100644 index 00000000..7ea4e7d9 --- /dev/null +++ b/docs/examples/organization/create-ephemeral-project-key.md @@ -0,0 +1,18 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Organization organization = Organization(client); + +models.EphemeralKey result = await organization.createEphemeralProjectKey( + projectId: '', + scopes: [enums.ProjectKeyScopes.usersRead], + duration: 600, +); +``` diff --git a/docs/examples/organization/delete-project-key.md b/docs/examples/organization/delete-project-key.md new file mode 100644 index 00000000..50ca64bc --- /dev/null +++ b/docs/examples/organization/delete-project-key.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Organization organization = Organization(client); + +await organization.deleteProjectKey( + projectId: '', + keyId: '', +); +``` diff --git a/docs/examples/organization/get-project-key.md b/docs/examples/organization/get-project-key.md new file mode 100644 index 00000000..6806f794 --- /dev/null +++ b/docs/examples/organization/get-project-key.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Organization organization = Organization(client); + +models.Key result = await organization.getProjectKey( + projectId: '', + keyId: '', +); +``` diff --git a/docs/examples/organization/list-project-keys.md b/docs/examples/organization/list-project-keys.md new file mode 100644 index 00000000..1cb2584c --- /dev/null +++ b/docs/examples/organization/list-project-keys.md @@ -0,0 +1,17 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Organization organization = Organization(client); + +models.KeyList result = await organization.listProjectKeys( + projectId: '', + queries: [], // (optional) + total: false, // (optional) +); +``` diff --git a/docs/examples/organization/update-project-key.md b/docs/examples/organization/update-project-key.md new file mode 100644 index 00000000..1db36db4 --- /dev/null +++ b/docs/examples/organization/update-project-key.md @@ -0,0 +1,20 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Organization organization = Organization(client); + +models.Key result = await organization.updateProjectKey( + projectId: '', + keyId: '', + name: '', + scopes: [enums.ProjectKeyScopes.usersRead], + expire: '2020-10-15T06:38:00.000+00:00', // (optional) +); +``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md index 47a5c14b..d8fb6af4 100644 --- a/docs/examples/project/create-android-platform.md +++ b/docs/examples/project/create-android-platform.md @@ -12,5 +12,6 @@ PlatformAndroid result = await project.createAndroidPlatform( platformId: '', name: '', applicationId: '', + fingerprints: [], // (optional) ); ``` diff --git a/docs/examples/project/create-environment.md b/docs/examples/project/create-environment.md new file mode 100644 index 00000000..adc7a098 --- /dev/null +++ b/docs/examples/project/create-environment.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Project project = Project(client); + +models.Project result = await project.createEnvironment( + environmentId: '', + name: '', +); +``` diff --git a/docs/examples/project/delete-environment.md b/docs/examples/project/delete-environment.md new file mode 100644 index 00000000..3de464f2 --- /dev/null +++ b/docs/examples/project/delete-environment.md @@ -0,0 +1,14 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Project project = Project(client); + +await project.deleteEnvironment( + environmentId: '', +); +``` diff --git a/docs/examples/project/get-environment.md b/docs/examples/project/get-environment.md new file mode 100644 index 00000000..64e4f12a --- /dev/null +++ b/docs/examples/project/get-environment.md @@ -0,0 +1,15 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Project project = Project(client); + +models.Project result = await project.getEnvironment( + environmentId: '', +); +``` diff --git a/docs/examples/project/list-environments.md b/docs/examples/project/list-environments.md new file mode 100644 index 00000000..1b47c9d5 --- /dev/null +++ b/docs/examples/project/list-environments.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Project project = Project(client); + +models.ProjectList result = await project.listEnvironments( + queries: [], // (optional) + total: false, // (optional) +); +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md index ee6eccf6..e1c6ba21 100644 --- a/docs/examples/project/update-android-platform.md +++ b/docs/examples/project/update-android-platform.md @@ -12,5 +12,6 @@ PlatformAndroid result = await project.updateAndroidPlatform( platformId: '', name: '', applicationId: '', + fingerprints: [], // (optional) ); ``` diff --git a/docs/examples/project/update-environment.md b/docs/examples/project/update-environment.md new file mode 100644 index 00000000..db105f06 --- /dev/null +++ b/docs/examples/project/update-environment.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Project project = Project(client); + +models.Project result = await project.updateEnvironment( + environmentId: '', + name: '', +); +``` diff --git a/docs/examples/project/update-o-auth-2-apple.md b/docs/examples/project/update-o-auth-2-apple.md index 06f506e5..fa95ab40 100644 --- a/docs/examples/project/update-o-auth-2-apple.md +++ b/docs/examples/project/update-o-auth-2-apple.md @@ -14,5 +14,7 @@ OAuth2Apple result = await project.updateOAuth2Apple( teamId: '', // (optional) p8File: '', // (optional) enabled: false, // (optional) + nativeClientIds: [], // (optional) + nativeEnabled: false, // (optional) ); ``` diff --git a/docs/examples/project/update-o-auth-2-auth-0.md b/docs/examples/project/update-o-auth-2-auth-0.md index e00a5976..743f9c7a 100644 --- a/docs/examples/project/update-o-auth-2-auth-0.md +++ b/docs/examples/project/update-o-auth-2-auth-0.md @@ -1,5 +1,6 @@ ```dart import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/enums.dart' as enums; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,5 +14,6 @@ OAuth2Auth0 result = await project.updateOAuth2Auth0( clientSecret: '', // (optional) endpoint: '', // (optional) enabled: false, // (optional) + prompt: [enums.ProjectOAuth2Auth0Prompt.none], // (optional) ); ``` diff --git a/docs/examples/project/update-o-auth-2-discord.md b/docs/examples/project/update-o-auth-2-discord.md index 7e06450d..1a49971b 100644 --- a/docs/examples/project/update-o-auth-2-discord.md +++ b/docs/examples/project/update-o-auth-2-discord.md @@ -1,5 +1,6 @@ ```dart import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/enums.dart' as enums; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,5 +13,6 @@ OAuth2Discord result = await project.updateOAuth2Discord( clientId: '', // (optional) clientSecret: '', // (optional) enabled: false, // (optional) + prompt: [enums.ProjectOAuth2DiscordPrompt.none], // (optional) ); ``` diff --git a/docs/examples/project/update-o-auth-2-git-hub.md b/docs/examples/project/update-o-auth-2-git-hub.md index e2830382..affb7f4c 100644 --- a/docs/examples/project/update-o-auth-2-git-hub.md +++ b/docs/examples/project/update-o-auth-2-git-hub.md @@ -1,5 +1,6 @@ ```dart import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/enums.dart' as enums; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,5 +13,6 @@ OAuth2Github result = await project.updateOAuth2GitHub( clientId: '', // (optional) clientSecret: '', // (optional) enabled: false, // (optional) + prompt: [enums.ProjectOAuth2GitHubPrompt.selectAccount], // (optional) ); ``` diff --git a/docs/examples/project/update-o-auth-2-google.md b/docs/examples/project/update-o-auth-2-google.md index 8c563f6b..037ead57 100644 --- a/docs/examples/project/update-o-auth-2-google.md +++ b/docs/examples/project/update-o-auth-2-google.md @@ -14,5 +14,7 @@ OAuth2Google result = await project.updateOAuth2Google( clientSecret: '', // (optional) prompt: [enums.ProjectOAuth2GooglePrompt.none], // (optional) enabled: false, // (optional) + nativeClientIds: [], // (optional) + nativeEnabled: false, // (optional) ); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md new file mode 100644 index 00000000..0737cddf --- /dev/null +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -0,0 +1,19 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Project project = Project(client); + +models.OAuth2Kakao result = await project.updateOAuth2Kakao( + clientId: '', // (optional) + clientSecret: '', // (optional) + prompt: [enums.ProjectOAuth2KakaoPrompt.none], // (optional) + enabled: false, // (optional) +); +``` diff --git a/docs/examples/project/update-o-auth-2-microsoft.md b/docs/examples/project/update-o-auth-2-microsoft.md index 7f1aa6ca..6c36e231 100644 --- a/docs/examples/project/update-o-auth-2-microsoft.md +++ b/docs/examples/project/update-o-auth-2-microsoft.md @@ -1,5 +1,6 @@ ```dart import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/enums.dart' as enums; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,5 +14,6 @@ OAuth2Microsoft result = await project.updateOAuth2Microsoft( applicationSecret: '', // (optional) tenant: '', // (optional) enabled: false, // (optional) + prompt: [enums.ProjectOAuth2MicrosoftPrompt.none], // (optional) ); ``` diff --git a/docs/examples/project/update-o-auth-2-okta.md b/docs/examples/project/update-o-auth-2-okta.md index cfd9f8ce..26d78189 100644 --- a/docs/examples/project/update-o-auth-2-okta.md +++ b/docs/examples/project/update-o-auth-2-okta.md @@ -1,5 +1,6 @@ ```dart import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/enums.dart' as enums; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -14,5 +15,6 @@ OAuth2Okta result = await project.updateOAuth2Okta( domain: 'example.com', // (optional) authorizationServerId: '', // (optional) enabled: false, // (optional) + prompt: [enums.ProjectOAuth2OktaPrompt.none], // (optional) ); ``` diff --git a/docs/examples/project/update-o-auth-2-salesforce.md b/docs/examples/project/update-o-auth-2-salesforce.md index 6be026b4..478bcbfd 100644 --- a/docs/examples/project/update-o-auth-2-salesforce.md +++ b/docs/examples/project/update-o-auth-2-salesforce.md @@ -1,5 +1,6 @@ ```dart import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/enums.dart' as enums; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,5 +13,6 @@ OAuth2Salesforce result = await project.updateOAuth2Salesforce( customerKey: '', // (optional) customerSecret: '', // (optional) enabled: false, // (optional) + prompt: [enums.ProjectOAuth2SalesforcePrompt.login], // (optional) ); ``` diff --git a/docs/examples/project/update-o-auth-2-tik-tok.md b/docs/examples/project/update-o-auth-2-tik-tok.md new file mode 100644 index 00000000..a05529eb --- /dev/null +++ b/docs/examples/project/update-o-auth-2-tik-tok.md @@ -0,0 +1,17 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Project project = Project(client); + +models.OAuth2TikTok result = await project.updateOAuth2TikTok( + clientId: '', // (optional) + clientSecret: '', // (optional) + enabled: false, // (optional) +); +``` diff --git a/docs/examples/project/update-o-auth-2-webflow.md b/docs/examples/project/update-o-auth-2-webflow.md new file mode 100644 index 00000000..b9855597 --- /dev/null +++ b/docs/examples/project/update-o-auth-2-webflow.md @@ -0,0 +1,17 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Project project = Project(client); + +models.OAuth2Webflow result = await project.updateOAuth2Webflow( + clientId: '', // (optional) + clientSecret: '', // (optional) + enabled: false, // (optional) +); +``` diff --git a/docs/examples/project/update-o-auth-2-zoho.md b/docs/examples/project/update-o-auth-2-zoho.md index 69d44d8a..1aca5b63 100644 --- a/docs/examples/project/update-o-auth-2-zoho.md +++ b/docs/examples/project/update-o-auth-2-zoho.md @@ -1,5 +1,6 @@ ```dart import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/enums.dart' as enums; Client client = Client() .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,5 +13,6 @@ OAuth2Zoho result = await project.updateOAuth2Zoho( clientId: '', // (optional) clientSecret: '', // (optional) enabled: false, // (optional) + prompt: [enums.ProjectOAuth2ZohoPrompt.consent], // (optional) ); ``` diff --git a/docs/examples/project/update-password-pwned-policy.md b/docs/examples/project/update-password-pwned-policy.md new file mode 100644 index 00000000..974d4ac7 --- /dev/null +++ b/docs/examples/project/update-password-pwned-policy.md @@ -0,0 +1,17 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Project project = Project(client); + +models.Project result = await project.updatePasswordPwnedPolicy( + enabled: false, // (optional) + sessions: false, // (optional) + users: false, // (optional) +); +``` diff --git a/docs/examples/project/update-password-rotation-policy.md b/docs/examples/project/update-password-rotation-policy.md new file mode 100644 index 00000000..32a8126b --- /dev/null +++ b/docs/examples/project/update-password-rotation-policy.md @@ -0,0 +1,16 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Project project = Project(client); + +models.Project result = await project.updatePasswordRotationPolicy( + enabled: false, // (optional) + maxAge: 86400, // (optional) +); +``` diff --git a/docs/examples/sites/list-frameworks.md b/docs/examples/sites/list-frameworks.md index b3e9bd8b..19475423 100644 --- a/docs/examples/sites/list-frameworks.md +++ b/docs/examples/sites/list-frameworks.md @@ -8,5 +8,7 @@ Client client = Client() Sites sites = Sites(client); -FrameworkList result = await sites.listFrameworks(); +FrameworkList result = await sites.listFrameworks( + total: false, // (optional) +); ``` diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index 7c80f2aa..3335fbd9 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -10,5 +10,6 @@ Sites sites = Sites(client); SpecificationList result = await sites.listSpecifications( type: 'runtimes', // (optional) + total: false, // (optional) ); ``` diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md index fa4782b5..ff0d673c 100644 --- a/docs/examples/tablesdb/list-transactions.md +++ b/docs/examples/tablesdb/list-transactions.md @@ -10,5 +10,6 @@ TablesDB tablesDB = TablesDB(client); TransactionList result = await tablesDB.listTransactions( queries: [], // (optional) + total: false, // (optional) ); ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 8f95362a..f13e287d 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -16,5 +16,6 @@ Membership result = await teams.createMembership( phone: '+12065550100', // (optional) url: 'https://example.com', // (optional) name: '', // (optional) + membershipId: '', // (optional) ); ``` diff --git a/docs/examples/vectorsdb/list-transactions.md b/docs/examples/vectorsdb/list-transactions.md index eb505875..e23b48ea 100644 --- a/docs/examples/vectorsdb/list-transactions.md +++ b/docs/examples/vectorsdb/list-transactions.md @@ -10,5 +10,6 @@ VectorsDB vectorsDB = VectorsDB(client); TransactionList result = await vectorsDB.listTransactions( queries: [], // (optional) + total: false, // (optional) ); ``` diff --git a/docs/examples/waf/create-bypass-rule.md b/docs/examples/waf/create-bypass-rule.md new file mode 100644 index 00000000..60e6c5c5 --- /dev/null +++ b/docs/examples/waf/create-bypass-rule.md @@ -0,0 +1,22 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleBypass result = await waf.createBypassRule( + ruleId: '', + resourceType: 'api', + name: '', + resourceId: '', // (optional) + description: '', // (optional) + priority: -100000, // (optional) + enabled: false, // (optional) + conditions: [], // (optional) +); +``` diff --git a/docs/examples/waf/create-challenge-rule.md b/docs/examples/waf/create-challenge-rule.md new file mode 100644 index 00000000..da5ef736 --- /dev/null +++ b/docs/examples/waf/create-challenge-rule.md @@ -0,0 +1,25 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleChallenge result = await waf.createChallengeRule( + ruleId: '', + resourceType: 'api', + name: '', + resourceId: '', // (optional) + description: '', // (optional) + challengeType: 'compute', // (optional) + priority: -100000, // (optional) + enabled: false, // (optional) + conditions: [], // (optional) + difficulty: 1, // (optional) + ttl: 900, // (optional) +); +``` diff --git a/docs/examples/waf/create-deny-rule.md b/docs/examples/waf/create-deny-rule.md new file mode 100644 index 00000000..c2807659 --- /dev/null +++ b/docs/examples/waf/create-deny-rule.md @@ -0,0 +1,22 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleDeny result = await waf.createDenyRule( + ruleId: '', + resourceType: 'api', + name: '', + resourceId: '', // (optional) + description: '', // (optional) + priority: -100000, // (optional) + enabled: false, // (optional) + conditions: [], // (optional) +); +``` diff --git a/docs/examples/waf/create-rate-limit-rule.md b/docs/examples/waf/create-rate-limit-rule.md new file mode 100644 index 00000000..96884daf --- /dev/null +++ b/docs/examples/waf/create-rate-limit-rule.md @@ -0,0 +1,27 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleRateLimit result = await waf.createRateLimitRule( + ruleId: '', + resourceType: 'api', + name: '', + limit: 1, + interval: 1, + resourceId: '', // (optional) + description: '', // (optional) + key: 'ip', // (optional) + strategy: 'fixedWindow', // (optional) + maxBucketSize: 1, // (optional) + priority: -100000, // (optional) + enabled: false, // (optional) + conditions: [], // (optional) +); +``` diff --git a/docs/examples/waf/create-redirect-rule.md b/docs/examples/waf/create-redirect-rule.md new file mode 100644 index 00000000..1b96203a --- /dev/null +++ b/docs/examples/waf/create-redirect-rule.md @@ -0,0 +1,24 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleRedirect result = await waf.createRedirectRule( + ruleId: '', + resourceType: 'api', + name: '', + location: '', + statusCode: 300, + resourceId: '', // (optional) + description: '', // (optional) + priority: -100000, // (optional) + enabled: false, // (optional) + conditions: [], // (optional) +); +``` diff --git a/docs/examples/waf/delete-rule.md b/docs/examples/waf/delete-rule.md new file mode 100644 index 00000000..bfc47176 --- /dev/null +++ b/docs/examples/waf/delete-rule.md @@ -0,0 +1,14 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +await waf.deleteRule( + ruleId: '', +); +``` diff --git a/docs/examples/waf/get-rule.md b/docs/examples/waf/get-rule.md new file mode 100644 index 00000000..85d028fd --- /dev/null +++ b/docs/examples/waf/get-rule.md @@ -0,0 +1,14 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +dynamic result = await waf.getRule( + ruleId: '', +); +``` diff --git a/docs/examples/waf/list-rules.md b/docs/examples/waf/list-rules.md new file mode 100644 index 00000000..8e37eca9 --- /dev/null +++ b/docs/examples/waf/list-rules.md @@ -0,0 +1,17 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleList result = await waf.listRules( + queries: [], // (optional) + search: '', // (optional) + total: false, // (optional) +); +``` diff --git a/docs/examples/waf/update-bypass-rule.md b/docs/examples/waf/update-bypass-rule.md new file mode 100644 index 00000000..65588cbf --- /dev/null +++ b/docs/examples/waf/update-bypass-rule.md @@ -0,0 +1,22 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleBypass result = await waf.updateBypassRule( + ruleId: '', + resourceType: 'api', // (optional) + resourceId: '', // (optional) + name: '', // (optional) + description: '', // (optional) + priority: -100000, // (optional) + enabled: false, // (optional) + conditions: [], // (optional) +); +``` diff --git a/docs/examples/waf/update-challenge-rule.md b/docs/examples/waf/update-challenge-rule.md new file mode 100644 index 00000000..1c3ea2a6 --- /dev/null +++ b/docs/examples/waf/update-challenge-rule.md @@ -0,0 +1,25 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleChallenge result = await waf.updateChallengeRule( + ruleId: '', + resourceType: 'api', // (optional) + resourceId: '', // (optional) + name: '', // (optional) + description: '', // (optional) + challengeType: 'compute', // (optional) + priority: -100000, // (optional) + enabled: false, // (optional) + conditions: [], // (optional) + difficulty: 1, // (optional) + ttl: 900, // (optional) +); +``` diff --git a/docs/examples/waf/update-deny-rule.md b/docs/examples/waf/update-deny-rule.md new file mode 100644 index 00000000..408aa8f5 --- /dev/null +++ b/docs/examples/waf/update-deny-rule.md @@ -0,0 +1,22 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleDeny result = await waf.updateDenyRule( + ruleId: '', + resourceType: 'api', // (optional) + resourceId: '', // (optional) + name: '', // (optional) + description: '', // (optional) + priority: -100000, // (optional) + enabled: false, // (optional) + conditions: [], // (optional) +); +``` diff --git a/docs/examples/waf/update-rate-limit-rule.md b/docs/examples/waf/update-rate-limit-rule.md new file mode 100644 index 00000000..6c46de45 --- /dev/null +++ b/docs/examples/waf/update-rate-limit-rule.md @@ -0,0 +1,26 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleRateLimit result = await waf.updateRateLimitRule( + ruleId: '', + resourceType: 'api', // (optional) + resourceId: '', // (optional) + name: '', // (optional) + description: '', // (optional) + limit: 1, // (optional) + interval: 1, // (optional) + key: 'ip', // (optional) + maxBucketSize: 1, // (optional) + priority: -100000, // (optional) + enabled: false, // (optional) + conditions: [], // (optional) +); +``` diff --git a/docs/examples/waf/update-redirect-rule.md b/docs/examples/waf/update-redirect-rule.md new file mode 100644 index 00000000..b00cf3b6 --- /dev/null +++ b/docs/examples/waf/update-redirect-rule.md @@ -0,0 +1,24 @@ +```dart +import 'package:dart_appwrite/dart_appwrite.dart'; +import 'package:dart_appwrite/models.dart' as models; + +Client client = Client() + .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + .setProject('') // Your project ID + .setKey(''); // Your secret API key + +Waf waf = Waf(client); + +models.WafRuleRedirect result = await waf.updateRedirectRule( + ruleId: '', + resourceType: 'api', // (optional) + resourceId: '', // (optional) + name: '', // (optional) + description: '', // (optional) + location: '', // (optional) + statusCode: 300, // (optional) + priority: -100000, // (optional) + enabled: false, // (optional) + conditions: [], // (optional) +); +``` diff --git a/lib/dart_appwrite.dart b/lib/dart_appwrite.dart index 1f505fa6..69dad8fb 100644 --- a/lib/dart_appwrite.dart +++ b/lib/dart_appwrite.dart @@ -38,6 +38,7 @@ part 'services/avatars.dart'; part 'services/backups.dart'; part 'services/databases.dart'; part 'services/documents_db.dart'; +part 'services/domains.dart'; part 'services/embeddings.dart'; part 'services/functions.dart'; part 'services/graphql.dart'; @@ -59,4 +60,5 @@ part 'services/teams.dart'; part 'services/tokens.dart'; part 'services/users.dart'; part 'services/vectors_db.dart'; +part 'services/waf.dart'; part 'services/webhooks.dart'; diff --git a/lib/enums.dart b/lib/enums.dart index 9d42c600..fbeff72b 100644 --- a/lib/enums.dart +++ b/lib/enums.dart @@ -3,6 +3,7 @@ library dart_appwrite.enums; part 'src/enums/authenticator_type.dart'; part 'src/enums/authentication_factor.dart'; +part 'src/enums/id_token_provider.dart'; part 'src/enums/o_auth_provider.dart'; part 'src/enums/browser.dart'; part 'src/enums/credit_card.dart'; @@ -17,6 +18,7 @@ part 'src/enums/relation_mutate.dart'; part 'src/enums/databases_index_type.dart'; part 'src/enums/order_by.dart'; part 'src/enums/documents_db_index_type.dart'; +part 'src/enums/domain_registration_type.dart'; part 'src/enums/embedding_model.dart'; part 'src/enums/runtime.dart'; part 'src/enums/project_key_scopes.dart'; @@ -29,8 +31,16 @@ part 'src/enums/smtp_encryption.dart'; part 'src/enums/organization_key_scopes.dart'; part 'src/enums/region.dart'; part 'src/enums/project_auth_method_id.dart'; +part 'src/enums/project_o_auth2_auth0_prompt.dart'; +part 'src/enums/project_o_auth2_discord_prompt.dart'; +part 'src/enums/project_o_auth2_git_hub_prompt.dart'; part 'src/enums/project_o_auth2_google_prompt.dart'; +part 'src/enums/project_o_auth2_kakao_prompt.dart'; +part 'src/enums/project_o_auth2_microsoft_prompt.dart'; part 'src/enums/project_o_auth2_oidc_prompt.dart'; +part 'src/enums/project_o_auth2_okta_prompt.dart'; +part 'src/enums/project_o_auth2_salesforce_prompt.dart'; +part 'src/enums/project_o_auth2_zoho_prompt.dart'; part 'src/enums/project_o_auth_provider_id.dart'; part 'src/enums/project_policy_id.dart'; part 'src/enums/project_protocol_id.dart'; @@ -59,10 +69,20 @@ part 'src/enums/deployment_status.dart'; part 'src/enums/execution_resource_type.dart'; part 'src/enums/execution_trigger.dart'; part 'src/enums/execution_status.dart'; +part 'src/enums/o_auth2_github_prompt.dart'; +part 'src/enums/o_auth2_discord_prompt.dart'; part 'src/enums/o_auth2_google_prompt.dart'; +part 'src/enums/o_auth2_zoho_prompt.dart'; +part 'src/enums/o_auth2_salesforce_prompt.dart'; +part 'src/enums/o_auth2_auth0_prompt.dart'; part 'src/enums/o_auth2_oidc_prompt.dart'; +part 'src/enums/o_auth2_okta_prompt.dart'; +part 'src/enums/o_auth2_microsoft_prompt.dart'; +part 'src/enums/o_auth2_kakao_prompt.dart'; part 'src/enums/platform_type.dart'; part 'src/enums/proxy_rule_deployment_resource_type.dart'; part 'src/enums/proxy_rule_status.dart'; part 'src/enums/message_status.dart'; part 'src/enums/billing_plan_group.dart'; +part 'src/enums/domain_transfer_status_enum.dart'; +part 'src/enums/waf_rule_action.dart'; diff --git a/lib/models.dart b/lib/models.dart index f0fd0323..7527ab80 100644 --- a/lib/models.dart +++ b/lib/models.dart @@ -111,6 +111,7 @@ part 'src/models/algo_bcrypt.dart'; part 'src/models/algo_scrypt.dart'; part 'src/models/algo_scrypt_modified.dart'; part 'src/models/algo_argon2.dart'; +part 'src/models/account.dart'; part 'src/models/preferences.dart'; part 'src/models/session.dart'; part 'src/models/identity.dart'; @@ -154,6 +155,7 @@ part 'src/models/o_auth2_zoho.dart'; part 'src/models/o_auth2_yandex.dart'; part 'src/models/o_auth2_x.dart'; part 'src/models/o_auth2_word_press.dart'; +part 'src/models/o_auth2_webflow.dart'; part 'src/models/o_auth2_twitch.dart'; part 'src/models/o_auth2_stripe.dart'; part 'src/models/o_auth2_spotify.dart'; @@ -183,11 +185,15 @@ part 'src/models/o_auth2_kick.dart'; part 'src/models/o_auth2_apple.dart'; part 'src/models/o_auth2_microsoft.dart'; part 'src/models/o_auth2_resend.dart'; +part 'src/models/o_auth2_tik_tok.dart'; +part 'src/models/o_auth2_kakao.dart'; part 'src/models/o_auth2_provider_list.dart'; part 'src/models/policy_password_dictionary.dart'; part 'src/models/policy_password_history.dart'; part 'src/models/policy_password_strength.dart'; part 'src/models/policy_password_personal_data.dart'; +part 'src/models/policy_password_pwned.dart'; +part 'src/models/policy_password_rotation.dart'; part 'src/models/policy_session_alert.dart'; part 'src/models/policy_session_duration.dart'; part 'src/models/policy_session_invalidation.dart'; @@ -252,6 +258,10 @@ part 'src/models/dedicated_database_execution.dart'; part 'src/models/dedicated_database_execution_column.dart'; part 'src/models/dedicated_database_restoration.dart'; part 'src/models/database_status.dart'; +part 'src/models/dns_record.dart'; +part 'src/models/domain.dart'; +part 'src/models/domain_price.dart'; +part 'src/models/domain_transfer_status.dart'; part 'src/models/dedicated_database_extensions.dart'; part 'src/models/dedicated_database_member.dart'; part 'src/models/dedicated_database_operation.dart'; @@ -290,8 +300,15 @@ part 'src/models/oauth2_grant.dart'; part 'src/models/oauth2_device_authorization.dart'; part 'src/models/oauth2_par.dart'; part 'src/models/oauth2_token.dart'; +part 'src/models/oauth2_introspection.dart'; part 'src/models/oauth2_consent.dart'; part 'src/models/oauth2_consent_token.dart'; +part 'src/models/waf_rule_bypass.dart'; +part 'src/models/waf_rule_deny.dart'; +part 'src/models/waf_rule_challenge.dart'; +part 'src/models/waf_rule_rate_limit.dart'; +part 'src/models/waf_rule_redirect.dart'; +part 'src/models/waf_rule_list.dart'; part 'src/models/oauth2_project.dart'; part 'src/models/oauth2_organization.dart'; part 'src/models/oauth2_project_list.dart'; @@ -304,6 +321,9 @@ part 'src/models/backup_policy_list.dart'; part 'src/models/backup_restoration_list.dart'; part 'src/models/database_migration_list.dart'; part 'src/models/dedicated_database_list.dart'; +part 'src/models/dns_records_list.dart'; +part 'src/models/domain_prices_list.dart'; +part 'src/models/domains_list.dart'; part 'src/models/apps_list.dart'; part 'src/models/app_secret_list.dart'; part 'src/models/app_scope_list.dart'; diff --git a/lib/services/account.dart b/lib/services/account.dart index b586d956..236814ab 100644 --- a/lib/services/account.dart +++ b/lib/services/account.dart @@ -1323,12 +1323,91 @@ class Account extends Service { return models.Token.fromMap(res.data); } + /// Use this endpoint to send a 6-digit password recovery code to the user's + /// email address. Unlike + /// [createRecovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery), + /// this method requires no redirect URL, which makes it suitable for mobile + /// and desktop apps that cannot host a recovery page. Learn more about how to + /// [complete the recovery + /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateRecoveryOTP). + /// The code sent to the user's email address is valid for 15 minutes. + /// + /// Enable the **phrase** parameter to include a randomly generated security + /// phrase in both the email and the response. Showing that phrase in your app + /// lets the user confirm the email genuinely came from your request, which + /// helps protect against phishing. + Future createRecoveryOTP({ + required String email, + bool? phrase, + }) async { + final String apiPath = '/account/recovery/otp'; + + final Map apiParams = { + 'email': email, + if (phrase != null) 'phrase': phrase, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Token.fromMap(res.data); + } + + /// Use this endpoint to complete the user password recovery process using the + /// 6-digit code that was emailed by + /// [createRecoveryOTP](https://appwrite.io/docs/references/cloud/client-web/account#createRecoveryOTP). + /// Pass the **userId** of the user along with the **secret** code from the + /// email and the new **password** to set. If confirmed, this route will return + /// a 200 status code, the code is consumed and the user's password is updated. + Future updateRecoveryOTP({ + required String userId, + required String secret, + required String password, + }) async { + final String apiPath = '/account/recovery/otp'; + + final Map apiParams = { + 'userId': userId, + 'secret': secret, + 'password': password, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Token.fromMap(res.data); + } + /// Get the list of active sessions across different devices for the currently /// logged in user. - Future listSessions() async { + Future listSessions({ + bool? total, + }) async { final String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + if (total != null) 'total': total, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1346,11 +1425,16 @@ class Account extends Service { } /// Delete all sessions from the user account and remove any sessions cookies - /// from the end client. - Future deleteSessions() async { + /// from the end client. Pass `current` as false to keep the session making the + /// request and sign out of every other session. + Future deleteSessions({ + bool? current, + }) async { final String apiPath = '/account/sessions'; - final Map apiParams = {}; + final Map apiParams = { + if (current != null) 'current': current, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -1404,12 +1488,90 @@ class Account extends Service { Future createEmailPasswordSession({ required String email, required String password, + int? duration, }) async { final String apiPath = '/account/sessions/email'; final Map apiParams = { 'email': email, 'password': password, + if (duration != null) 'duration': duration, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Session.fromMap(res.data); + } + + /// Allow the user to login to their account using an OpenID Connect ID token + /// obtained natively from the OAuth2 provider, for example via Google + /// Credential Manager on Android or Sign in with Apple on iOS. No browser or + /// redirect is involved: the ID token is verified against the provider's + /// published signing keys and a session is created in a single request. + /// + /// Native sign-in is switched on per provider with its nativeEnabled setting. + /// It is independent of the browser-based flow's enabled setting, which has no + /// effect on this endpoint. The token's audience must match the provider's + /// configured client ID or one of its native client IDs; tokens issued for any + /// other client ID are rejected. For Sign in with Apple, register your app's + /// bundle ID as a native client ID. For Google, the web client ID used by + /// Credential Manager is usually the configured client ID; add your Android + /// and iOS client IDs as native client IDs if your app requests tokens for + /// them. + /// + /// Pass the raw nonce used when requesting the ID token so it can be validated + /// against the token's nonce claim. When signing in with Apple, the nonce is + /// required: hash it with SHA-256 before passing it to the Apple SDK, and send + /// the raw value here - Apple tokens requested without a nonce are rejected. + /// For Google the nonce is optional: it is validated whenever the token + /// carries one, and ignored when the provider issued the token without one. + /// Apple only returns the user's name on the first authorization, and never + /// inside the ID token - capture it on the client and pass it via the name + /// parameter. + /// + /// If there is already an active session, the new session will be attached to + /// the logged-in account. If there are no active sessions, the server will + /// attempt to look for a user with the same email address as the verified + /// email received from the provider and attach the new session to the existing + /// user. If no matching user is found - the server will create a new user. + /// + /// This flow does not return provider refresh tokens. You may pass an access + /// token the provider handed your client, along with its lifetime, to store it + /// on the session - but Appwrite cannot renew it once it expires. If your app + /// needs long-lived access to provider APIs, use the browser-based OAuth2 flow + /// instead. + /// + /// A user is limited to 10 active sessions at a time by default. [Learn more + /// about session + /// limits](https://appwrite.io/docs/authentication-security#limits). + Future createIdTokenSession({ + required enums.IdTokenProvider provider, + required String idToken, + String? nonce, + String? accessToken, + int? accessTokenExpiry, + String? name, + }) async { + final String apiPath = '/account/sessions/id-token'; + + final Map apiParams = { + 'provider': provider.value, + 'idToken': idToken, + if (nonce != null) 'nonce': nonce, + if (accessToken != null) 'accessToken': accessToken, + if (accessTokenExpiry != null) 'accessTokenExpiry': accessTokenExpiry, + if (name != null) 'name': name, }; final Map apiHeaders = { @@ -2028,6 +2190,77 @@ class Account extends Service { return models.Token.fromMap(res.data); } + /// Use this endpoint to send a 6-digit verification code to the currently + /// logged in user's email address. Unlike + /// [createEmailVerification](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerification), + /// this method requires no redirect URL, which makes it suitable for mobile + /// and desktop apps that cannot host a verification page. Learn more about how + /// to [complete the verification + /// process](https://appwrite.io/docs/references/cloud/client-web/account#updateEmailVerificationOTP). + /// The code sent to the user's email address is valid for 15 minutes. + /// + /// Enable the **phrase** parameter to include a randomly generated security + /// phrase in both the email and the response. Showing that phrase in your app + /// lets the user confirm the email genuinely came from your request, which + /// helps protect against phishing. + Future createEmailVerificationOTP({ + bool? phrase, + }) async { + final String apiPath = '/account/verifications/email/otp'; + + final Map apiParams = { + if (phrase != null) 'phrase': phrase, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Token.fromMap(res.data); + } + + /// Use this endpoint to complete the user email verification process using the + /// 6-digit code that was emailed by + /// [createEmailVerificationOTP](https://appwrite.io/docs/references/cloud/client-web/account#createEmailVerificationOTP). + /// Pass the **userId** of the user being verified along with the **secret** + /// code from the email. If confirmed, this route will return a 200 status code + /// and the code is consumed. + Future updateEmailVerificationOTP({ + required String userId, + required String secret, + }) async { + final String apiPath = '/account/verifications/email/otp'; + + final Map apiParams = { + 'userId': userId, + 'secret': secret, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Token.fromMap(res.data); + } + /// 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 diff --git a/lib/services/avatars.dart b/lib/services/avatars.dart index 71529262..fba79a60 100644 --- a/lib/services/avatars.dart +++ b/lib/services/avatars.dart @@ -293,6 +293,68 @@ class Avatars extends Service { return res.data; } + /// Update the profile photo of the currently authenticated user. The uploaded + /// image takes priority over every other photo source, including OAuth2 + /// identity photos, Gravatar, and Libravatar. Updating an already customized + /// photo replaces it. The image must be at most 5MB and is sent in a single + /// request. + Future updatePhoto({ + required InputFile file, + Function(UploadProgress)? onProgress, + }) async { + final String apiPath = '/avatars/photo'; + + final Map apiParams = { + 'file': file, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'multipart/form-data', + 'accept': 'application/json', + }; + + String idParamName = ''; + final paramName = 'file'; + final res = await client.chunkedUpload( + path: apiPath, + params: apiParams, + paramName: paramName, + idParamName: idParamName, + headers: apiHeaders, + onProgress: onProgress, + method: HttpMethod.put, + ); + + return models.Account.fromMap(res.data); + } + + /// Delete the profile photo of the currently authenticated user and store the + /// built-in static placeholder in its place. The placeholder is the user's + /// photo from then on, so it takes priority over every other photo source — + /// OAuth2 identity photos, Gravatar, Libravatar, and initials — until a new + /// photo is uploaded with avatars.updatePhoto. + Future deletePhoto() async { + final String apiPath = '/avatars/photo'; + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; + } + /// Converts a given plain text to a QR code image. You can use the query /// parameters to change the size and style of the resulting image. Future getQR({ diff --git a/lib/services/databases.dart b/lib/services/databases.dart index 19c4602e..86f438a0 100644 --- a/lib/services/databases.dart +++ b/lib/services/databases.dart @@ -77,11 +77,13 @@ class Databases extends Service { ) Future listTransactions({ List? queries, + bool? total, }) async { final String apiPath = '/databases/transactions'; final Map apiParams = { if (queries != null) 'queries': queries, + if (total != null) 'total': total, }; final Map apiHeaders = { diff --git a/lib/services/documents_db.dart b/lib/services/documents_db.dart index 13d1996b..df5c9d79 100644 --- a/lib/services/documents_db.dart +++ b/lib/services/documents_db.dart @@ -93,11 +93,13 @@ class DocumentsDB extends Service { /// List transactions across all databases. Future listTransactions({ List? queries, + bool? total, }) async { final String apiPath = '/documentsdb/transactions'; final Map apiParams = { if (queries != null) 'queries': queries, + if (total != null) 'total': total, }; final Map apiHeaders = { diff --git a/lib/services/domains.dart b/lib/services/domains.dart new file mode 100644 index 00000000..e88cde0f --- /dev/null +++ b/lib/services/domains.dart @@ -0,0 +1,2021 @@ +part of '../dart_appwrite.dart'; + +class Domains extends Service { + Domains(super.client); + + /// List all domains registered for this project. This endpoint supports + /// pagination. + Future list({ + List? queries, + String? search, + }) async { + final String apiPath = '/domains'; + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DomainsList.fromMap(res.data); + } + + /// Create a new domain. Before creating a domain, you need to ensure that your + /// DNS provider is properly configured. After creating the domain, you can use + /// the verification endpoint to check if the domain is ready to be used. + Future create({ + required String teamId, + required String domain, + }) async { + final String apiPath = '/domains'; + + final Map apiParams = { + 'teamId': teamId, + 'domain': domain, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Domain.fromMap(res.data); + } + + /// Get the registration price for a domain name. + @Deprecated( + 'This API has been deprecated since 2.0.0. Please use `Domains.listPrices` instead.', + ) + Future getPrice({ + required String domain, + int? periodYears, + enums.DomainRegistrationType? registrationType, + }) async { + final String apiPath = '/domains/price'; + + final Map apiParams = { + 'domain': domain, + if (periodYears != null) 'periodYears': periodYears, + if (registrationType != null) 'registrationType': registrationType?.value, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DomainPrice.fromMap(res.data); + } + + /// Check availability and get the requested registration price for one or more + /// domain names. Availability is resolved for all domains in a single + /// registrar lookup. Unavailable domains have a null price for new + /// registrations, but can still be priced for renewal, transfer, or trade. + /// Every priced domain also carries its renewal price for the same period, so + /// a separate renewal lookup is not needed. A domain whose price could not be + /// resolved, for example because its TLD is not supported, is returned with a + /// null price. + Future listPrices({ + required List domains, + int? periodYears, + enums.DomainRegistrationType? registrationType, + }) async { + final String apiPath = '/domains/prices'; + + final Map apiParams = { + 'domains': domains, + if (periodYears != null) 'periodYears': periodYears, + if (registrationType != null) 'registrationType': registrationType?.value, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DomainPricesList.fromMap(res.data); + } + + /// Get a domain by its unique ID. + Future get({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Domain.fromMap(res.data); + } + + /// Delete a domain by its unique ID. This endpoint can be used to delete a + /// domain from your project. + /// Once deleted, the domain will no longer be available for use and all + /// associated resources will be removed. + Future delete({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; + } + + /// Update the registrar nameservers for the given domain. When nameservers are + /// not provided, + /// the domain will be updated to use Appwrite nameservers. + Future updateNameservers({ + required String domainId, + List? nameservers, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/nameservers'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + if (nameservers != null) 'nameservers': nameservers, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Domain.fromMap(res.data); + } + + /// Verify which NS records are used and update the domain accordingly. This + /// will check the domain's + /// nameservers and update the domain's status based on whether the nameservers + /// match the expected + /// Appwrite nameservers. + Future verifyNameservers({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = + '/domains/{domainId}/nameservers/verification'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Domain.fromMap(res.data); + } + + /// List Google Workspace DNS records. + Future getPresetGoogleWorkspace({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = + '/domains/{domainId}/presets/google-workspace'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// Add Google Workspace DNS records to the domain. This will create the + /// required MX records + /// for Google Workspace email hosting. + Future createPresetGoogleWorkspace({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = + '/domains/{domainId}/presets/google-workspace'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// List iCloud DNS records. + Future getPresetICloud({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/presets/icloud'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// Add iCloud DNS records to the domain. This will create the required MX and + /// SPF records + /// for using iCloud email services with your domain. + Future createPresetICloud({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/presets/icloud'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// List Mailgun DNS records. + Future getPresetMailgun({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/presets/mailgun'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// Add Mailgun DNS records to the domain. This endpoint will create the + /// required DNS records + /// for Mailgun in the specified domain. + Future createPresetMailgun({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/presets/mailgun'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// List Outlook DNS records. + Future getPresetOutlook({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/presets/outlook'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// Add Outlook DNS records to the domain. This will create the required MX + /// records + /// for setting up Outlook email hosting for your domain. + Future createPresetOutlook({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/presets/outlook'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// List ProtonMail DNS records. + Future getPresetProtonMail({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/presets/proton-mail'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// Add ProtonMail DNS records to the domain. This will create the required MX + /// records + /// for using ProtonMail with your custom domain. + Future createPresetProtonMail({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/presets/proton-mail'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// List Zoho DNS records. + Future getPresetZoho({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/presets/zoho'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// Add Zoho Mail DNS records to the domain. This will create the required MX + /// records + /// for setting up Zoho Mail on your domain. + Future createPresetZoho({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/presets/zoho'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// List DNS records for a given domain. You can use this endpoint to list all + /// the DNS records + /// associated with your domain. + Future listRecords({ + required String domainId, + List? queries, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + if (queries != null) 'queries': queries, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecordsList.fromMap(res.data); + } + + /// Create a new A record for the given domain. A records are used to point a + /// domain name + /// to an IPv4 address. The record value should be a valid IPv4 address. + Future createRecordA({ + required String domainId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/a'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Update an existing A record for the given domain. This endpoint allows you + /// to modify + /// the properties of an A record including its name (subdomain), IPv4 address, + /// TTL, + /// and optional comment. + Future updateRecordA({ + required String domainId, + required String recordId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/a/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Create a new AAAA record for the given domain. This endpoint allows you to + /// add a new IPv6 DNS record + /// to your domain. The record will be used to point a hostname to an IPv6 + /// address. + Future createRecordAAAA({ + required String domainId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/aaaa'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Update an existing AAAA record for the given domain. This endpoint allows + /// you to modify + /// the properties of an existing AAAA record, including its name (subdomain), + /// IPv6 address, + /// TTL, and optional comment. + Future updateRecordAAAA({ + required String domainId, + required String recordId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/aaaa/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Create a new ALIAS record for the given domain. This record type can be + /// used to point your domain + /// to another domain name that will serve as an alias. This is particularly + /// useful when you want to + /// map your domain to a target domain that may change its IP address. + Future createRecordAlias({ + required String domainId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/alias'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Update an existing ALIAS record for the specified domain. This endpoint + /// allows you to modify + /// the properties of an existing ALIAS record including its name, target + /// domain, TTL, and comment. + /// + /// The ALIAS record type is similar to a CNAME record but can be used at the + /// zone apex (root domain). + /// It provides a way to map one domain name to another. + Future updateRecordAlias({ + required String domainId, + required String recordId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/alias/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Create a new CAA record for the given domain. CAA records are used to + /// specify which + /// Certificate Authorities (CAs) are allowed to issue SSL/TLS certificates for + /// your domain. + Future createRecordCAA({ + required String domainId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/caa'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Update an existing CAA record for the given domain. A CAA (Certification + /// Authority Authorization) + /// record is used to specify which certificate authorities (CAs) are + /// authorized to issue certificates + /// for a domain. + Future updateRecordCAA({ + required String domainId, + required String recordId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/caa/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Create a new CNAME record for the given domain. + /// + /// A CNAME record maps a subdomain to another domain name, allowing you to + /// create aliases + /// for your domain. For example, you can create a CNAME record to point + /// 'blog.example.com' + /// to 'example.wordpress.com'. + Future createRecordCNAME({ + required String domainId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/cname'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Update an existing CNAME record for the given domain. + Future updateRecordCNAME({ + required String domainId, + required String recordId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/cname/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Create a new HTTPS record for the given domain. This record is used to + /// configure HTTPS + /// settings for your domain, enabling secure communication over SSL/TLS. + Future createRecordHTTPS({ + required String domainId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/https'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Update an existing HTTPS record for the given domain. This endpoint allows + /// you to modify + /// the properties of an HTTPS record associated with your domain, including + /// the name (subdomain), + /// target value, TTL, and optional comment. + Future updateRecordHTTPS({ + required String domainId, + required String recordId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/https/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Create a new MX record for the given domain. MX records are used to define + /// the mail servers responsible + /// for accepting email messages for the domain. Multiple MX records can be + /// created with different priorities. + /// The priority parameter determines the order in which mail servers are used, + /// with lower values indicating + /// higher priority. + Future createRecordMX({ + required String domainId, + required String name, + required String value, + required int ttl, + required int priority, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/mx'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + 'priority': priority, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Update an existing MX record for the given domain. + Future updateRecordMX({ + required String domainId, + required String recordId, + required String name, + required String value, + required int ttl, + required int priority, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/mx/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + 'priority': priority, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Create a new NS record for the given domain. NS records specify the + /// nameservers that are used + /// to resolve the domain name to IP addresses. Each domain can have multiple + /// NS records. + Future createRecordNS({ + required String domainId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/ns'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Update an existing NS record for the given domain. This endpoint allows you + /// to modify + /// the properties of an NS (nameserver) record associated with your domain. + /// You can update + /// the record name (subdomain), target nameserver value, TTL, and add or + /// modify comments + /// for better record management. + Future updateRecordNS({ + required String domainId, + required String recordId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/ns/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Create a new SRV record for the given domain. SRV records are used to + /// define the location + /// of servers for specific services. For example, they can be used to specify + /// which server + /// handles a specific service like SIP or XMPP for the domain. + Future createRecordSRV({ + required String domainId, + required String name, + required String value, + required int ttl, + required int priority, + required int weight, + required int port, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/srv'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + 'priority': priority, + 'weight': weight, + 'port': port, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Update an existing SRV record for the given domain. + /// + /// Required parameters: + /// - domainId: Domain unique ID + /// - recordId: DNS record unique ID + /// - name: Record name (service name) + /// - value: Target hostname for this SRV record + /// - ttl: Time to live, in seconds + /// - priority: Record priority + /// - weight: Record weight + /// - port: Port number for the service + /// + /// Optional parameters: + /// - comment: A comment for this record + Future updateRecordSRV({ + required String domainId, + required String recordId, + required String name, + required String value, + required int ttl, + required int priority, + required int weight, + required int port, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/srv/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + 'priority': priority, + 'weight': weight, + 'port': port, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Create a new TXT record for the given domain. TXT records can be used + /// to provide additional information about your domain, such as domain + /// verification records, SPF records, or DKIM records. + Future createRecordTXT({ + required String domainId, + required String name, + required int ttl, + String? value, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/txt'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'name': name, + if (value != null) 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Update an existing TXT record for the given domain. + /// + /// Update the TXT record details for a specific domain by providing the domain + /// ID, + /// record ID, and the new record configuration including name, value, TTL, and + /// an optional comment. + Future updateRecordTXT({ + required String domainId, + required String recordId, + required String name, + required String value, + required int ttl, + String? comment, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/txt/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = { + 'name': name, + 'value': value, + 'ttl': ttl, + if (comment != null) 'comment': comment, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Get a single DNS record for a given domain by record ID. + /// + /// This endpoint allows you to retrieve a specific DNS record associated with + /// a domain + /// using its unique identifier. The record contains information about the DNS + /// configuration + /// such as type, value, and TTL settings. + Future getRecord({ + required String domainId, + required String recordId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DnsRecord.fromMap(res.data); + } + + /// Delete a DNS record for the given domain. This endpoint allows you to + /// delete an existing DNS record + /// from a specific domain. + Future deleteRecord({ + required String domainId, + required String recordId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + if (recordId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "recordId"', + ); + } + + final String apiPath = '/domains/{domainId}/records/{recordId}' + .replaceAll( + '{domainId}', + domainId, + ) + .replaceAll( + '{recordId}', + recordId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; + } + + /// Update the team ID for a specific domain. The caller must administer the + /// current + /// team and be an owner of the destination team. + /// + /// Updating the team ID will transfer ownership and access control of the + /// domain + /// and all its DNS records to the new team. + Future updateTeam({ + required String domainId, + required String teamId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/team'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'teamId': teamId, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Domain.fromMap(res.data); + } + + /// Retrieve the current transfer status for a domain. Returns the status, an + /// optional reason, and a timestamp of the last status change. + Future getTransferStatus({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/transfers/status'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.DomainTransferStatus.fromMap(res.data); + } + + /// Retrieve the DNS zone file for the given domain. This endpoint will return + /// the DNS + /// zone file in a standardized format that can be used to configure DNS + /// servers. + Future getZone({ + required String domainId, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/zone'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'text/plain', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + responseType: ResponseType.plain, + ); + + return res.data; + } + + /// Update the DNS zone for the given domain using the provided zone file + /// content. + /// All parsed records are imported and then the main domain document is + /// returned. + Future updateZone({ + required String domainId, + required String content, + }) async { + if (domainId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "domainId"', + ); + } + + final String apiPath = '/domains/{domainId}/zone'.replaceAll( + '{domainId}', + domainId, + ); + + final Map apiParams = { + 'content': content, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Domain.fromMap(res.data); + } +} diff --git a/lib/services/functions.dart b/lib/services/functions.dart index e5849024..16b6d751 100644 --- a/lib/services/functions.dart +++ b/lib/services/functions.dart @@ -113,10 +113,14 @@ class Functions extends Service { } /// Get a list of all runtimes that are currently active on your instance. - Future listRuntimes() async { + Future listRuntimes({ + bool? total, + }) async { final String apiPath = '/functions/runtimes'; - final Map apiParams = {}; + final Map apiParams = { + if (total != null) 'total': total, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -136,11 +140,13 @@ class Functions extends Service { /// List allowed function specifications for this instance. Future listSpecifications({ String? type, + bool? total, }) async { final String apiPath = '/functions/specifications'; final Map apiParams = { if (type != null) 'type': type, + if (total != null) 'total': total, }; final Map apiHeaders = { diff --git a/lib/services/locale.dart b/lib/services/locale.dart index ba41f224..81292e45 100644 --- a/lib/services/locale.dart +++ b/lib/services/locale.dart @@ -33,10 +33,14 @@ class Locale extends Service { /// List of all locale codes in [ISO /// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). - Future listCodes() async { + Future listCodes({ + bool? total, + }) async { final String apiPath = '/locale/codes'; - final Map apiParams = {}; + final Map apiParams = { + if (total != null) 'total': total, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -55,10 +59,14 @@ class Locale extends Service { /// List of all continents. You can use the locale header to get the data in a /// supported language. - Future listContinents() async { + Future listContinents({ + bool? total, + }) async { final String apiPath = '/locale/continents'; - final Map apiParams = {}; + final Map apiParams = { + if (total != null) 'total': total, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -77,10 +85,14 @@ class Locale extends Service { /// List of all countries. You can use the locale header to get the data in a /// supported language. - Future listCountries() async { + Future listCountries({ + bool? total, + }) async { final String apiPath = '/locale/countries'; - final Map apiParams = {}; + final Map apiParams = { + if (total != null) 'total': total, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -99,10 +111,14 @@ class Locale extends Service { /// List of all countries that are currently members of the EU. You can use the /// locale header to get the data in a supported language. - Future listCountriesEU() async { + Future listCountriesEU({ + bool? total, + }) async { final String apiPath = '/locale/countries/eu'; - final Map apiParams = {}; + final Map apiParams = { + if (total != null) 'total': total, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -121,10 +137,14 @@ class Locale extends Service { /// List of all countries phone codes. You can use the locale header to get the /// data in a supported language. - Future listCountriesPhones() async { + Future listCountriesPhones({ + bool? total, + }) async { final String apiPath = '/locale/countries/phones'; - final Map apiParams = {}; + final Map apiParams = { + if (total != null) 'total': total, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -144,10 +164,14 @@ class Locale extends Service { /// List of all currencies, including currency symbol, name, plural, and /// decimal digits for all major and minor currencies. You can use the locale /// header to get the data in a supported language. - Future listCurrencies() async { + Future listCurrencies({ + bool? total, + }) async { final String apiPath = '/locale/currencies'; - final Map apiParams = {}; + final Map apiParams = { + if (total != null) 'total': total, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -166,10 +190,14 @@ class Locale extends Service { /// List of all languages classified by ISO 639-1 including 2-letter code, name /// in English, and name in the respective language. - Future listLanguages() async { + Future listLanguages({ + bool? total, + }) async { final String apiPath = '/locale/languages'; - final Map apiParams = {}; + final Map apiParams = { + if (total != null) 'total': total, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', diff --git a/lib/services/messaging.dart b/lib/services/messaging.dart index de2ed472..5c376fb7 100644 --- a/lib/services/messaging.dart +++ b/lib/services/messaging.dart @@ -48,6 +48,8 @@ class Messaging extends Service { bool? draft, bool? html, String? scheduledAt, + String? replyToEmail, + String? replyToName, }) async { final String apiPath = '/messaging/messages/email'; @@ -64,6 +66,8 @@ class Messaging extends Service { if (draft != null) 'draft': draft, if (html != null) 'html': html, if (scheduledAt != null) 'scheduledAt': scheduledAt, + if (replyToEmail != null) 'replyToEmail': replyToEmail, + if (replyToName != null) 'replyToName': replyToName, }; final Map apiHeaders = { @@ -98,6 +102,8 @@ class Messaging extends Service { List? bcc, String? scheduledAt, List? attachments, + String? replyToEmail, + String? replyToName, }) async { final String apiPath = '/messaging/messages/email/{messageId}'.replaceAll( '{messageId}', @@ -116,6 +122,8 @@ class Messaging extends Service { if (bcc != null) 'bcc': bcc, if (scheduledAt != null) 'scheduledAt': scheduledAt, if (attachments != null) 'attachments': attachments, + if (replyToEmail != null) 'replyToEmail': replyToEmail, + if (replyToName != null) 'replyToName': replyToName, }; final Map apiHeaders = { @@ -155,6 +163,7 @@ class Messaging extends Service { bool? contentAvailable, bool? critical, enums.MessagePriority? priority, + String? channelId, }) async { final String apiPath = '/messaging/messages/push'; @@ -178,6 +187,7 @@ class Messaging extends Service { if (contentAvailable != null) 'contentAvailable': contentAvailable, if (critical != null) 'critical': critical, if (priority != null) 'priority': priority?.value, + if (channelId != null) 'channelId': channelId, }; final Map apiHeaders = { @@ -219,6 +229,7 @@ class Messaging extends Service { bool? contentAvailable, bool? critical, enums.MessagePriority? priority, + String? channelId, }) async { final String apiPath = '/messaging/messages/push/{messageId}'.replaceAll( '{messageId}', @@ -244,6 +255,7 @@ class Messaging extends Service { if (contentAvailable != null) 'contentAvailable': contentAvailable, if (critical != null) 'critical': critical, if (priority != null) 'priority': priority?.value, + if (channelId != null) 'channelId': channelId, }; final Map apiHeaders = { @@ -711,6 +723,83 @@ class Messaging extends Service { return models.Provider.fromMap(res.data); } + /// Create a new Appwrite push provider. + Future createAppwriteProvider({ + required String providerId, + required String name, + bool? enabled, + int? qos, + int? expiry, + }) async { + final String apiPath = '/messaging/providers/appwrite'; + + final Map apiParams = { + 'providerId': providerId, + 'name': name, + if (enabled != null) 'enabled': enabled, + if (qos != null) 'qos': qos, + if (expiry != null) 'expiry': expiry, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Provider.fromMap(res.data); + } + + /// Update an Appwrite push provider by its unique ID. + Future updateAppwriteProvider({ + required String providerId, + String? name, + bool? enabled, + int? qos, + int? expiry, + }) async { + if (providerId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "providerId"', + ); + } + + final String apiPath = + '/messaging/providers/appwrite/{providerId}'.replaceAll( + '{providerId}', + providerId, + ); + + final Map apiParams = { + if (name != null) 'name': name, + if (enabled != null) 'enabled': enabled, + if (qos != null) 'qos': qos, + if (expiry != null) 'expiry': expiry, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Provider.fromMap(res.data); + } + /// Create a new Firebase Cloud Messaging provider. @Deprecated( 'This API has been deprecated since 1.8.0. Please use `Messaging.createFCMProvider` instead.', @@ -1874,6 +1963,8 @@ class Messaging extends Service { required String topicId, required String name, List? subscribe, + int? qos, + int? expiry, }) async { final String apiPath = '/messaging/topics'; @@ -1881,6 +1972,8 @@ class Messaging extends Service { 'topicId': topicId, 'name': name, if (subscribe != null) 'subscribe': subscribe, + if (qos != null) 'qos': qos, + if (expiry != null) 'expiry': expiry, }; final Map apiHeaders = { @@ -1930,6 +2023,8 @@ class Messaging extends Service { required String topicId, String? name, List? subscribe, + int? qos, + int? expiry, }) async { final String apiPath = '/messaging/topics/{topicId}'.replaceAll( '{topicId}', @@ -1939,6 +2034,8 @@ class Messaging extends Service { final Map apiParams = { if (name != null) 'name': name, if (subscribe != null) 'subscribe': subscribe, + if (qos != null) 'qos': qos, + if (expiry != null) 'expiry': expiry, }; final Map apiHeaders = { diff --git a/lib/services/oauth2.dart b/lib/services/oauth2.dart index cde5ba38..fba8879e 100644 --- a/lib/services/oauth2.dart +++ b/lib/services/oauth2.dart @@ -263,6 +263,43 @@ class Oauth2 extends Service { return models.Oauth2Grant.fromMap(res.data); } + /// Introspect an OAuth2 access token or refresh token. Authenticate with an + /// API key holding the `oauth2.introspect` scope to introspect any token in + /// the project, or with the client credentials of the app the token was issued + /// to. + Future introspect({ + required String token, + String? tokenTypeHint, + String? clientId, + String? clientSecret, + }) async { + final String apiPath = '/oauth2/{project_id}/introspect'.replaceAll( + '{project_id}', + client.config['project'] ?? '', + ); + + final Map apiParams = { + 'token': token, + if (tokenTypeHint != null) 'token_type_hint': tokenTypeHint, + if (clientId != null) 'client_id': clientId, + if (clientSecret != null) 'client_secret': clientSecret, + }; + + final Map apiHeaders = { + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Oauth2Introspection.fromMap(res.data); + } + /// List the organizations the OAuth2 access token can access. Resolves the /// token's `organization` authorization details, expanding the `*` wildcard /// into the concrete set of organizations the user can see. diff --git a/lib/services/organization.dart b/lib/services/organization.dart index c84a1137..0f5cec66 100644 --- a/lib/services/organization.dart +++ b/lib/services/organization.dart @@ -667,4 +667,228 @@ class Organization extends Service { return res.data; } + + /// Get a list of all API keys of a project in your organization. + Future listProjectKeys({ + required String projectId, + List? queries, + bool? total, + }) async { + if (projectId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + + final String apiPath = '/organization/projects/{projectId}/keys'.replaceAll( + '{projectId}', + projectId, + ); + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.KeyList.fromMap(res.data); + } + + /// Create a new ephemeral API key for a project in your organization. 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. + Future createEphemeralProjectKey({ + required String projectId, + required List scopes, + required int duration, + }) async { + if (projectId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + + final String apiPath = + '/organization/projects/{projectId}/keys/ephemeral'.replaceAll( + '{projectId}', + projectId, + ); + + final Map apiParams = { + 'scopes': scopes.map((e) => e.value).toList(), + 'duration': duration, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.EphemeralKey.fromMap(res.data); + } + + /// Get a project key by its unique ID. + Future getProjectKey({ + required String projectId, + required String keyId, + }) async { + if (projectId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + + if (keyId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "keyId"', + ); + } + + final String apiPath = '/organization/projects/{projectId}/keys/{keyId}' + .replaceAll( + '{projectId}', + projectId, + ) + .replaceAll( + '{keyId}', + keyId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Key.fromMap(res.data); + } + + /// Update a project key by its unique ID. Use this endpoint to update the + /// name, scopes, or expiration time of an API key. + Future updateProjectKey({ + required String projectId, + required String keyId, + required String name, + required List scopes, + String? expire, + }) async { + if (projectId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + + if (keyId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "keyId"', + ); + } + + final String apiPath = '/organization/projects/{projectId}/keys/{keyId}' + .replaceAll( + '{projectId}', + projectId, + ) + .replaceAll( + '{keyId}', + keyId, + ); + + final Map apiParams = { + 'name': name, + 'scopes': scopes.map((e) => e.value).toList(), + if (expire != null) 'expire': expire, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.put, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Key.fromMap(res.data); + } + + /// Delete a project key by its unique ID. Once deleted, the key can no longer + /// be used to authenticate API calls. + Future deleteProjectKey({ + required String projectId, + required String keyId, + }) async { + if (projectId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "projectId"', + ); + } + + if (keyId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "keyId"', + ); + } + + final String apiPath = '/organization/projects/{projectId}/keys/{keyId}' + .replaceAll( + '{projectId}', + projectId, + ) + .replaceAll( + '{keyId}', + keyId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; + } } diff --git a/lib/services/project.dart b/lib/services/project.dart index 87392261..c1589a21 100644 --- a/lib/services/project.dart +++ b/lib/services/project.dart @@ -77,6 +77,165 @@ class Project extends Service { return models.Project.fromMap(res.data); } + /// Get a list of all environments of the project. You can use the query params + /// to filter your results. + Future listEnvironments({ + List? queries, + bool? total, + }) async { + final String apiPath = '/project/environments'; + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.ProjectList.fromMap(res.data); + } + + /// Create a new environment of the project. An environment is a separate + /// project in the same organization and region, with its own resources and + /// users. Its usage is billed under the project it belongs to. + Future createEnvironment({ + required String environmentId, + required String name, + }) async { + final String apiPath = '/project/environments'; + + final Map apiParams = { + 'environmentId': environmentId, + 'name': name, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Project.fromMap(res.data); + } + + /// Get an environment of the project by its unique ID. + Future getEnvironment({ + required String environmentId, + }) async { + if (environmentId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + + final String apiPath = '/project/environments/{environmentId}'.replaceAll( + '{environmentId}', + environmentId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Project.fromMap(res.data); + } + + /// Update the name of an environment of the project. + Future updateEnvironment({ + required String environmentId, + required String name, + }) async { + if (environmentId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + + final String apiPath = '/project/environments/{environmentId}'.replaceAll( + '{environmentId}', + environmentId, + ); + + final Map apiParams = { + 'name': name, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Project.fromMap(res.data); + } + + /// Delete an environment of the project, with all of its resources and users. + Future deleteEnvironment({ + required String environmentId, + }) async { + if (environmentId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "environmentId"', + ); + } + + final String apiPath = '/project/environments/{environmentId}'.replaceAll( + '{environmentId}', + environmentId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; + } + /// Get a list of all API keys from the current project. Future listKeys({ List? queries, @@ -521,6 +680,8 @@ class Project extends Service { String? teamId, String? p8File, bool? enabled, + List? nativeClientIds, + bool? nativeEnabled, }) async { final String apiPath = '/project/oauth2/apple'; @@ -530,6 +691,8 @@ class Project extends Service { if (teamId != null) 'teamId': teamId, if (p8File != null) 'p8File': p8File, if (enabled != null) 'enabled': enabled, + if (nativeClientIds != null) 'nativeClientIds': nativeClientIds, + if (nativeEnabled != null) 'nativeEnabled': nativeEnabled, }; final Map apiHeaders = { @@ -584,6 +747,7 @@ class Project extends Service { String? clientSecret, String? endpoint, bool? enabled, + List? prompt, }) async { final String apiPath = '/project/oauth2/auth0'; @@ -592,6 +756,7 @@ class Project extends Service { if (clientSecret != null) 'clientSecret': clientSecret, if (endpoint != null) 'endpoint': endpoint, if (enabled != null) 'enabled': enabled, + if (prompt != null) 'prompt': prompt?.map((e) => e.value).toList(), }; final Map apiHeaders = { @@ -827,6 +992,7 @@ class Project extends Service { String? clientId, String? clientSecret, bool? enabled, + List? prompt, }) async { final String apiPath = '/project/oauth2/discord'; @@ -834,6 +1000,7 @@ class Project extends Service { if (clientId != null) 'clientId': clientId, if (clientSecret != null) 'clientSecret': clientSecret, if (enabled != null) 'enabled': enabled, + if (prompt != null) 'prompt': prompt?.map((e) => e.value).toList(), }; final Map apiHeaders = { @@ -1039,6 +1206,7 @@ class Project extends Service { String? clientId, String? clientSecret, bool? enabled, + List? prompt, }) async { final String apiPath = '/project/oauth2/github'; @@ -1046,6 +1214,7 @@ class Project extends Service { if (clientId != null) 'clientId': clientId, if (clientSecret != null) 'clientSecret': clientSecret, if (enabled != null) 'enabled': enabled, + if (prompt != null) 'prompt': prompt?.map((e) => e.value).toList(), }; final Map apiHeaders = { @@ -1102,6 +1271,8 @@ class Project extends Service { String? clientSecret, List? prompt, bool? enabled, + List? nativeClientIds, + bool? nativeEnabled, }) async { final String apiPath = '/project/oauth2/google'; @@ -1110,6 +1281,8 @@ class Project extends Service { if (clientSecret != null) 'clientSecret': clientSecret, if (prompt != null) 'prompt': prompt?.map((e) => e.value).toList(), if (enabled != null) 'enabled': enabled, + if (nativeClientIds != null) 'nativeClientIds': nativeClientIds, + if (nativeEnabled != null) 'nativeEnabled': nativeEnabled, }; final Map apiHeaders = { @@ -1158,6 +1331,38 @@ class Project extends Service { return models.OAuth2HuggingFace.fromMap(res.data); } + /// Update the project OAuth2 Kakao configuration. + Future updateOAuth2Kakao({ + String? clientId, + String? clientSecret, + List? prompt, + bool? enabled, + }) async { + final String apiPath = '/project/oauth2/kakao'; + + final Map apiParams = { + if (clientId != null) 'clientId': clientId, + if (clientSecret != null) 'clientSecret': clientSecret, + if (prompt != null) 'prompt': prompt?.map((e) => e.value).toList(), + if (enabled != null) 'enabled': enabled, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.OAuth2Kakao.fromMap(res.data); + } + /// Update the project OAuth2 Keycloak configuration. Future updateOAuth2Keycloak({ String? clientId, @@ -1259,6 +1464,7 @@ class Project extends Service { String? applicationSecret, String? tenant, bool? enabled, + List? prompt, }) async { final String apiPath = '/project/oauth2/microsoft'; @@ -1267,6 +1473,7 @@ class Project extends Service { if (applicationSecret != null) 'applicationSecret': applicationSecret, if (tenant != null) 'tenant': tenant, if (enabled != null) 'enabled': enabled, + if (prompt != null) 'prompt': prompt?.map((e) => e.value).toList(), }; final Map apiHeaders = { @@ -1364,6 +1571,7 @@ class Project extends Service { String? domain, String? authorizationServerId, bool? enabled, + List? prompt, }) async { final String apiPath = '/project/oauth2/okta'; @@ -1374,6 +1582,7 @@ class Project extends Service { if (authorizationServerId != null) 'authorizationServerId': authorizationServerId, if (enabled != null) 'enabled': enabled, + if (prompt != null) 'prompt': prompt?.map((e) => e.value).toList(), }; final Map apiHeaders = { @@ -1517,6 +1726,7 @@ class Project extends Service { String? customerKey, String? customerSecret, bool? enabled, + List? prompt, }) async { final String apiPath = '/project/oauth2/salesforce'; @@ -1524,6 +1734,7 @@ class Project extends Service { if (customerKey != null) 'customerKey': customerKey, if (customerSecret != null) 'customerSecret': customerSecret, if (enabled != null) 'enabled': enabled, + if (prompt != null) 'prompt': prompt?.map((e) => e.value).toList(), }; final Map apiHeaders = { @@ -1632,6 +1843,36 @@ class Project extends Service { return models.OAuth2Stripe.fromMap(res.data); } + /// Update the project OAuth2 TikTok configuration. + Future updateOAuth2TikTok({ + String? clientId, + String? clientSecret, + bool? enabled, + }) async { + final String apiPath = '/project/oauth2/tiktok'; + + final Map apiParams = { + if (clientId != null) 'clientId': clientId, + if (clientSecret != null) 'clientSecret': clientSecret, + if (enabled != null) 'enabled': enabled, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.OAuth2TikTok.fromMap(res.data); + } + /// Update the project OAuth2 Tradeshift configuration. Future updateOAuth2Tradeshift({ String? oauth2ClientId, @@ -1722,6 +1963,36 @@ class Project extends Service { return models.OAuth2Twitch.fromMap(res.data); } + /// Update the project OAuth2 Webflow configuration. + Future updateOAuth2Webflow({ + String? clientId, + String? clientSecret, + bool? enabled, + }) async { + final String apiPath = '/project/oauth2/webflow'; + + final Map apiParams = { + if (clientId != null) 'clientId': clientId, + if (clientSecret != null) 'clientSecret': clientSecret, + if (enabled != null) 'enabled': enabled, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.OAuth2Webflow.fromMap(res.data); + } + /// Update the project OAuth2 WordPress configuration. Future updateOAuth2WordPress({ String? clientId, @@ -1847,6 +2118,7 @@ class Project extends Service { String? clientId, String? clientSecret, bool? enabled, + List? prompt, }) async { final String apiPath = '/project/oauth2/zoho'; @@ -1854,6 +2126,7 @@ class Project extends Service { if (clientId != null) 'clientId': clientId, if (clientSecret != null) 'clientSecret': clientSecret, if (enabled != null) 'enabled': enabled, + if (prompt != null) 'prompt': prompt?.map((e) => e.value).toList(), }; final Map apiHeaders = { @@ -1979,6 +2252,9 @@ class Project extends Service { if (response['\$id'] == "wordpress") { return models.OAuth2WordPress.fromMap(response); } + if (response['\$id'] == "webflow") { + return models.OAuth2Webflow.fromMap(response); + } if (response['\$id'] == "twitch") { return models.OAuth2Twitch.fromMap(response); } @@ -2063,6 +2339,12 @@ class Project extends Service { if (response['\$id'] == "microsoft") { return models.OAuth2Microsoft.fromMap(response); } + if (response['\$id'] == "tiktok") { + return models.OAuth2TikTok.fromMap(response); + } + if (response['\$id'] == "kakao") { + return models.OAuth2Kakao.fromMap(response); + } throw StateError( 'Unable to match response to any expected response model.', @@ -2105,6 +2387,7 @@ class Project extends Service { required String platformId, required String name, required String applicationId, + List? fingerprints, }) async { final String apiPath = '/project/platforms/android'; @@ -2112,6 +2395,7 @@ class Project extends Service { 'platformId': platformId, 'name': name, 'applicationId': applicationId, + if (fingerprints != null) 'fingerprints': fingerprints, }; final Map apiHeaders = { @@ -2136,6 +2420,7 @@ class Project extends Service { required String platformId, required String name, required String applicationId, + List? fingerprints, }) async { final String apiPath = '/project/platforms/android/{platformId}'.replaceAll( '{platformId}', @@ -2145,6 +2430,7 @@ class Project extends Service { final Map apiParams = { 'name': name, 'applicationId': applicationId, + if (fingerprints != null) 'fingerprints': fingerprints, }; final Map apiHeaders = { @@ -2835,6 +3121,73 @@ class Project extends Service { return models.Project.fromMap(res.data); } + /// Updating this policy allows you to control if passwords are checked against + /// the Have I Been Pwned breach database. When enabled, every password a user + /// signs up, signs in or resets with is checked and the result is recorded on + /// the user as `passwordPwned`. On its own the policy only records. Enable + /// `users` to reject a breached password when a user signs up or sets a new + /// password, and `sessions` to refuse a sign-in with a breached password until + /// it is reset. Only the first five characters of the password hash are ever + /// shared with the service. Options left out keep their current value. + Future updatePasswordPwnedPolicy({ + bool? enabled, + bool? sessions, + bool? users, + }) async { + final String apiPath = '/project/policies/password-pwned'; + + final Map apiParams = { + if (enabled != null) 'enabled': enabled, + if (sessions != null) 'sessions': sessions, + if (users != null) 'users': users, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Project.fromMap(res.data); + } + + /// Require a password reset when an email/password sign-in uses a password + /// older than the configured maximum age. Options left out keep their current + /// value. + Future updatePasswordRotationPolicy({ + bool? enabled, + int? maxAge, + }) async { + final String apiPath = '/project/policies/password-rotation'; + + final Map apiParams = { + if (enabled != null) 'enabled': enabled, + if (maxAge != null) 'maxAge': maxAge, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.Project.fromMap(res.data); + } + /// Update the password strength requirements for users in the project. Future updatePasswordStrengthPolicy({ int? min, @@ -3053,6 +3406,12 @@ class Project extends Service { if (response['\$id'] == "password-personal-data") { return models.PolicyPasswordPersonalData.fromMap(response); } + if (response['\$id'] == "password-pwned") { + return models.PolicyPasswordPwned.fromMap(response); + } + if (response['\$id'] == "password-rotation") { + return models.PolicyPasswordRotation.fromMap(response); + } if (response['\$id'] == "session-alert") { return models.PolicySessionAlert.fromMap(response); } diff --git a/lib/services/sites.dart b/lib/services/sites.dart index 6f8e9bec..7c8e09ea 100644 --- a/lib/services/sites.dart +++ b/lib/services/sites.dart @@ -112,10 +112,14 @@ class Sites extends Service { /// Get a list of all frameworks that are currently available on the server /// instance. - Future listFrameworks() async { + Future listFrameworks({ + bool? total, + }) async { final String apiPath = '/sites/frameworks'; - final Map apiParams = {}; + final Map apiParams = { + if (total != null) 'total': total, + }; final Map apiHeaders = { 'X-Appwrite-Project': client.config['project'] ?? '', @@ -135,11 +139,13 @@ class Sites extends Service { /// List allowed site specifications for this instance. Future listSpecifications({ String? type, + bool? total, }) async { final String apiPath = '/sites/specifications'; final Map apiParams = { if (type != null) 'type': type, + if (total != null) 'total': total, }; final Map apiHeaders = { diff --git a/lib/services/tables_db.dart b/lib/services/tables_db.dart index 08933432..d0a762c3 100644 --- a/lib/services/tables_db.dart +++ b/lib/services/tables_db.dart @@ -97,11 +97,13 @@ class TablesDB extends Service { /// List transactions across all databases. Future listTransactions({ List? queries, + bool? total, }) async { final String apiPath = '/tablesdb/transactions'; final Map apiParams = { if (queries != null) 'queries': queries, + if (total != null) 'total': total, }; final Map apiHeaders = { diff --git a/lib/services/teams.dart b/lib/services/teams.dart index b30b0558..fe1c87be 100644 --- a/lib/services/teams.dart +++ b/lib/services/teams.dart @@ -388,6 +388,7 @@ class Teams extends Service { String? phone, String? url, String? name, + String? membershipId, }) async { final String apiPath = '/teams/{teamId}/memberships'.replaceAll( '{teamId}', @@ -401,6 +402,7 @@ class Teams extends Service { 'roles': roles, if (url != null) 'url': url, if (name != null) 'name': name, + if (membershipId != null) 'membershipId': membershipId, }; final Map apiHeaders = { diff --git a/lib/services/vectors_db.dart b/lib/services/vectors_db.dart index 80b130d3..ae9ba9f8 100644 --- a/lib/services/vectors_db.dart +++ b/lib/services/vectors_db.dart @@ -93,11 +93,13 @@ class VectorsDB extends Service { /// List transactions across all databases. Future listTransactions({ List? queries, + bool? total, }) async { final String apiPath = '/vectorsdb/transactions'; final Map apiParams = { if (queries != null) 'queries': queries, + if (total != null) 'total': total, }; final Map apiHeaders = { diff --git a/lib/services/waf.dart b/lib/services/waf.dart new file mode 100644 index 00000000..4677bde2 --- /dev/null +++ b/lib/services/waf.dart @@ -0,0 +1,662 @@ +part of '../dart_appwrite.dart'; + +class Waf extends Service { + Waf(super.client); + + /// List WAF rules for the current project. + Future listRules({ + List? queries, + String? search, + bool? total, + }) async { + final String apiPath = '/waf/rules'; + + final Map apiParams = { + if (queries != null) 'queries': queries, + if (search != null) 'search': search, + if (total != null) 'total': total, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleList.fromMap(res.data); + } + + /// Create a bypass WAF rule. Conditions can match request attributes including + /// `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + /// `host`, `country`, `continent`, `headers.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + Future createBypassRule({ + required String ruleId, + required String resourceType, + required String name, + String? resourceId, + String? description, + int? priority, + bool? enabled, + List? conditions, + }) async { + final String apiPath = '/waf/rules/bypass'; + + final Map apiParams = { + 'ruleId': ruleId, + 'resourceType': resourceType, + if (resourceId != null) 'resourceId': resourceId, + 'name': name, + if (description != null) 'description': description, + if (priority != null) 'priority': priority, + if (enabled != null) 'enabled': enabled, + if (conditions != null) 'conditions': conditions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleBypass.fromMap(res.data); + } + + /// Update a bypass WAF rule. Conditions can match request attributes including + /// `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + /// `host`, `country`, `continent`, `headers.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + Future updateBypassRule({ + required String ruleId, + String? resourceType, + String? resourceId, + String? name, + String? description, + int? priority, + bool? enabled, + List? conditions, + }) async { + if (ruleId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "ruleId"', + ); + } + + final String apiPath = '/waf/rules/bypass/{ruleId}'.replaceAll( + '{ruleId}', + ruleId, + ); + + final Map apiParams = { + if (resourceType != null) 'resourceType': resourceType, + if (resourceId != null) 'resourceId': resourceId, + if (name != null) 'name': name, + if (description != null) 'description': description, + if (priority != null) 'priority': priority, + if (enabled != null) 'enabled': enabled, + if (conditions != null) 'conditions': conditions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleBypass.fromMap(res.data); + } + + /// Create a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to + /// tune the client-side proof-of-work cost, and `ttl` to control how long, in + /// seconds, a visitor stays cleared after passing the challenge before being + /// challenged again. Conditions can match request attributes including `ip` + /// (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, + /// `country`, `continent`, `headers.`, `query.`, `queryKeys`, + /// `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions + /// on `city` and `state` require the premium Geo DB addon. + Future createChallengeRule({ + required String ruleId, + required String resourceType, + required String name, + String? resourceId, + String? description, + String? challengeType, + int? priority, + bool? enabled, + List? conditions, + int? difficulty, + int? ttl, + }) async { + final String apiPath = '/waf/rules/challenge'; + + final Map apiParams = { + 'ruleId': ruleId, + 'resourceType': resourceType, + if (resourceId != null) 'resourceId': resourceId, + 'name': name, + if (description != null) 'description': description, + if (challengeType != null) 'challengeType': challengeType, + if (priority != null) 'priority': priority, + if (enabled != null) 'enabled': enabled, + if (conditions != null) 'conditions': conditions, + if (difficulty != null) 'difficulty': difficulty, + if (ttl != null) 'ttl': ttl, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleChallenge.fromMap(res.data); + } + + /// Update a challenge WAF rule. Use `difficulty` (1 easiest to 5 hardest) to + /// tune the client-side proof-of-work cost, and `ttl` to control how long, in + /// seconds, a visitor stays cleared after passing the challenge before being + /// challenged again. Conditions can match request attributes including `ip` + /// (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, `host`, + /// `country`, `continent`, `headers.`, `query.`, `queryKeys`, + /// `userAgent`, `os`, `osVersion`, `browser`, and `browserVersion`. Conditions + /// on `city` and `state` require the premium Geo DB addon. + Future updateChallengeRule({ + required String ruleId, + String? resourceType, + String? resourceId, + String? name, + String? description, + String? challengeType, + int? priority, + bool? enabled, + List? conditions, + int? difficulty, + int? ttl, + }) async { + if (ruleId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "ruleId"', + ); + } + + final String apiPath = '/waf/rules/challenge/{ruleId}'.replaceAll( + '{ruleId}', + ruleId, + ); + + final Map apiParams = { + if (resourceType != null) 'resourceType': resourceType, + if (resourceId != null) 'resourceId': resourceId, + if (name != null) 'name': name, + if (description != null) 'description': description, + if (challengeType != null) 'challengeType': challengeType, + if (priority != null) 'priority': priority, + if (enabled != null) 'enabled': enabled, + if (conditions != null) 'conditions': conditions, + if (difficulty != null) 'difficulty': difficulty, + if (ttl != null) 'ttl': ttl, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleChallenge.fromMap(res.data); + } + + /// Create a deny WAF rule. Conditions can match request attributes including + /// `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + /// `host`, `country`, `continent`, `headers.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + Future createDenyRule({ + required String ruleId, + required String resourceType, + required String name, + String? resourceId, + String? description, + int? priority, + bool? enabled, + List? conditions, + }) async { + final String apiPath = '/waf/rules/deny'; + + final Map apiParams = { + 'ruleId': ruleId, + 'resourceType': resourceType, + if (resourceId != null) 'resourceId': resourceId, + 'name': name, + if (description != null) 'description': description, + if (priority != null) 'priority': priority, + if (enabled != null) 'enabled': enabled, + if (conditions != null) 'conditions': conditions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleDeny.fromMap(res.data); + } + + /// Update a deny WAF rule. Conditions can match request attributes including + /// `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, `path`, + /// `host`, `country`, `continent`, `headers.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + Future updateDenyRule({ + required String ruleId, + String? resourceType, + String? resourceId, + String? name, + String? description, + int? priority, + bool? enabled, + List? conditions, + }) async { + if (ruleId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "ruleId"', + ); + } + + final String apiPath = '/waf/rules/deny/{ruleId}'.replaceAll( + '{ruleId}', + ruleId, + ); + + final Map apiParams = { + if (resourceType != null) 'resourceType': resourceType, + if (resourceId != null) 'resourceId': resourceId, + if (name != null) 'name': name, + if (description != null) 'description': description, + if (priority != null) 'priority': priority, + if (enabled != null) 'enabled': enabled, + if (conditions != null) 'conditions': conditions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleDeny.fromMap(res.data); + } + + /// Create a rate limit WAF rule. Use `key` to choose the counter: `ip` limits + /// per client IP, while `userId` limits per authenticated user (requests + /// without an authenticated user skip `userId` rules). Conditions can match + /// request attributes including `ip` (plain IPs or CIDR blocks like + /// `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, + /// `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, + /// `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and + /// `state` require the premium Geo DB addon. + Future createRateLimitRule({ + required String ruleId, + required String resourceType, + required String name, + required int limit, + required int interval, + String? resourceId, + String? description, + String? key, + String? strategy, + int? maxBucketSize, + int? priority, + bool? enabled, + List? conditions, + }) async { + final String apiPath = '/waf/rules/rate-limit'; + + final Map apiParams = { + 'ruleId': ruleId, + 'resourceType': resourceType, + if (resourceId != null) 'resourceId': resourceId, + 'name': name, + if (description != null) 'description': description, + 'limit': limit, + 'interval': interval, + if (key != null) 'key': key, + if (strategy != null) 'strategy': strategy, + if (maxBucketSize != null) 'maxBucketSize': maxBucketSize, + if (priority != null) 'priority': priority, + if (enabled != null) 'enabled': enabled, + if (conditions != null) 'conditions': conditions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleRateLimit.fromMap(res.data); + } + + /// Update a rate limit WAF rule. Use `key` to choose the counter: `ip` limits + /// per client IP, while `userId` limits per authenticated user (requests + /// without an authenticated user skip `userId` rules). Conditions can match + /// request attributes including `ip` (plain IPs or CIDR blocks like + /// `10.0.0.0/8`), `method`, `path`, `host`, `country`, `continent`, + /// `headers.`, `query.`, `queryKeys`, `userAgent`, `os`, + /// `osVersion`, `browser`, and `browserVersion`. Conditions on `city` and + /// `state` require the premium Geo DB addon. + Future updateRateLimitRule({ + required String ruleId, + String? resourceType, + String? resourceId, + String? name, + String? description, + int? limit, + int? interval, + String? key, + int? maxBucketSize, + int? priority, + bool? enabled, + List? conditions, + }) async { + if (ruleId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "ruleId"', + ); + } + + final String apiPath = '/waf/rules/rate-limit/{ruleId}'.replaceAll( + '{ruleId}', + ruleId, + ); + + final Map apiParams = { + if (resourceType != null) 'resourceType': resourceType, + if (resourceId != null) 'resourceId': resourceId, + if (name != null) 'name': name, + if (description != null) 'description': description, + if (limit != null) 'limit': limit, + if (interval != null) 'interval': interval, + if (key != null) 'key': key, + if (maxBucketSize != null) 'maxBucketSize': maxBucketSize, + if (priority != null) 'priority': priority, + if (enabled != null) 'enabled': enabled, + if (conditions != null) 'conditions': conditions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleRateLimit.fromMap(res.data); + } + + /// Create a redirect WAF rule. Conditions can match request attributes + /// including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, + /// `path`, `host`, `country`, `continent`, `headers.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + Future createRedirectRule({ + required String ruleId, + required String resourceType, + required String name, + required String location, + required int statusCode, + String? resourceId, + String? description, + int? priority, + bool? enabled, + List? conditions, + }) async { + final String apiPath = '/waf/rules/redirect'; + + final Map apiParams = { + 'ruleId': ruleId, + 'resourceType': resourceType, + if (resourceId != null) 'resourceId': resourceId, + 'name': name, + if (description != null) 'description': description, + 'location': location, + 'statusCode': statusCode, + if (priority != null) 'priority': priority, + if (enabled != null) 'enabled': enabled, + if (conditions != null) 'conditions': conditions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.post, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleRedirect.fromMap(res.data); + } + + /// Update a redirect WAF rule. Conditions can match request attributes + /// including `ip` (plain IPs or CIDR blocks like `10.0.0.0/8`), `method`, + /// `path`, `host`, `country`, `continent`, `headers.`, `query.`, + /// `queryKeys`, `userAgent`, `os`, `osVersion`, `browser`, and + /// `browserVersion`. Conditions on `city` and `state` require the premium Geo + /// DB addon. + Future updateRedirectRule({ + required String ruleId, + String? resourceType, + String? resourceId, + String? name, + String? description, + String? location, + int? statusCode, + int? priority, + bool? enabled, + List? conditions, + }) async { + if (ruleId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "ruleId"', + ); + } + + final String apiPath = '/waf/rules/redirect/{ruleId}'.replaceAll( + '{ruleId}', + ruleId, + ); + + final Map apiParams = { + if (resourceType != null) 'resourceType': resourceType, + if (resourceId != null) 'resourceId': resourceId, + if (name != null) 'name': name, + if (description != null) 'description': description, + if (location != null) 'location': location, + if (statusCode != null) 'statusCode': statusCode, + if (priority != null) 'priority': priority, + if (enabled != null) 'enabled': enabled, + if (conditions != null) 'conditions': conditions, + }; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.patch, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return models.WafRuleRedirect.fromMap(res.data); + } + + /// Get a WAF rule by its ID. + Future getRule({ + required String ruleId, + }) async { + if (ruleId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "ruleId"', + ); + } + + final String apiPath = '/waf/rules/{ruleId}'.replaceAll( + '{ruleId}', + ruleId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.get, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return () { + if (res.data is! Map) { + throw StateError( + 'Unable to match response to any expected response model.', + ); + } + + final response = res.data as Map; + if (response['action'] == "bypass") { + return models.WafRuleBypass.fromMap(response); + } + if (response['action'] == "deny") { + return models.WafRuleDeny.fromMap(response); + } + if (response['action'] == "challenge") { + return models.WafRuleChallenge.fromMap(response); + } + if (response['action'] == "rateLimit") { + return models.WafRuleRateLimit.fromMap(response); + } + if (response['action'] == "redirect") { + return models.WafRuleRedirect.fromMap(response); + } + + throw StateError( + 'Unable to match response to any expected response model.', + ); + }(); + } + + /// Delete a WAF rule. + Future deleteRule({ + required String ruleId, + }) async { + if (ruleId.isEmpty) { + throw AppwriteException( + 'Missing required parameter: "ruleId"', + ); + } + + final String apiPath = '/waf/rules/{ruleId}'.replaceAll( + '{ruleId}', + ruleId, + ); + + final Map apiParams = {}; + + final Map apiHeaders = { + 'X-Appwrite-Project': client.config['project'] ?? '', + 'content-type': 'application/json', + 'accept': 'application/json', + }; + + final res = await client.call( + HttpMethod.delete, + path: apiPath, + params: apiParams, + headers: apiHeaders, + ); + + return res.data; + } +} diff --git a/lib/src/client.dart b/lib/src/client.dart index 18cf0335..1f1cbf61 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -117,6 +117,7 @@ abstract class Client { required String idParamName, required Map headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }); /// Send the API request. diff --git a/lib/src/client_browser.dart b/lib/src/client_browser.dart index ba11c6f0..fa42b836 100644 --- a/lib/src/client_browser.dart +++ b/lib/src/client_browser.dart @@ -33,7 +33,7 @@ class ClientBrowser extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '29.3.1', + 'x-sdk-version': '29.4.0', 'X-Appwrite-Response-Format': '2.0.0', }; @@ -190,6 +190,7 @@ class ClientBrowser extends ClientBase with ClientMixin { required String idParamName, required Map headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { InputFile file = params[paramName]; if (file.bytes == null) { @@ -206,7 +207,7 @@ class ClientBrowser extends ClientBase with ClientMixin { filename: file.filename, ); return call( - HttpMethod.post, + method, path: path, params: params, headers: headers, @@ -257,7 +258,7 @@ class ClientBrowser extends ClientBase with ClientMixin { chunkHeaders['content-range'] = 'bytes $start-${end - 1}/$size'; return call( - HttpMethod.post, + method, path: path, headers: chunkHeaders, params: chunkParams, diff --git a/lib/src/client_io.dart b/lib/src/client_io.dart index 33949ac2..bbe9b787 100644 --- a/lib/src/client_io.dart +++ b/lib/src/client_io.dart @@ -42,9 +42,9 @@ class ClientIO extends ClientBase with ClientMixin { 'x-sdk-name': 'Dart', 'x-sdk-platform': 'server', 'x-sdk-language': 'dart', - 'x-sdk-version': '29.3.1', + 'x-sdk-version': '29.4.0', 'user-agent': - 'AppwriteDartSDK/29.3.1 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', + 'AppwriteDartSDK/29.4.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})', 'X-Appwrite-Response-Format': '2.0.0', }; @@ -195,6 +195,7 @@ class ClientIO extends ClientBase with ClientMixin { required String idParamName, required Map headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { InputFile file = params[paramName]; if (file.path == null && file.bytes == null) { @@ -224,7 +225,7 @@ class ClientIO extends ClientBase with ClientMixin { filename: file.filename); } return call( - HttpMethod.post, + method, path: path, params: params, headers: headers, @@ -286,7 +287,7 @@ class ClientIO extends ClientBase with ClientMixin { chunkHeaders['content-range'] = 'bytes $start-${end - 1}/$size'; return call( - HttpMethod.post, + method, path: path, headers: chunkHeaders, params: chunkParams, diff --git a/lib/src/enums/billing_plan_group.dart b/lib/src/enums/billing_plan_group.dart index ab5de5c5..8bb56dda 100644 --- a/lib/src/enums/billing_plan_group.dart +++ b/lib/src/enums/billing_plan_group.dart @@ -2,6 +2,8 @@ part of '../../enums.dart'; enum BillingPlanGroup { starter(value: "starter"), + free(value: "free"), + start(value: "start"), pro(value: "pro"), scale(value: "scale"); diff --git a/lib/src/enums/build_runtime.dart b/lib/src/enums/build_runtime.dart index dbcdab94..d5f3b427 100644 --- a/lib/src/enums/build_runtime.dart +++ b/lib/src/enums/build_runtime.dart @@ -52,6 +52,7 @@ enum BuildRuntime { dart310(value: "dart-3.10"), dart311(value: "dart-3.11"), dart312(value: "dart-3.12"), + dart313(value: "dart-3.13"), dotnet60(value: "dotnet-6.0"), dotnet70(value: "dotnet-7.0"), dotnet80(value: "dotnet-8.0"), @@ -93,7 +94,8 @@ enum BuildRuntime { flutter335(value: "flutter-3.35"), flutter338(value: "flutter-3.38"), flutter341(value: "flutter-3.41"), - flutter344(value: "flutter-3.44"); + flutter344(value: "flutter-3.44"), + flutter347(value: "flutter-3.47"); const BuildRuntime({required this.value}); diff --git a/lib/src/enums/databases_index_type.dart b/lib/src/enums/databases_index_type.dart index 49ddcad3..323c72c2 100644 --- a/lib/src/enums/databases_index_type.dart +++ b/lib/src/enums/databases_index_type.dart @@ -4,7 +4,8 @@ enum DatabasesIndexType { key(value: "key"), fulltext(value: "fulltext"), unique(value: "unique"), - spatial(value: "spatial"); + spatial(value: "spatial"), + trigram(value: "trigram"); const DatabasesIndexType({required this.value}); diff --git a/lib/src/enums/domain_registration_type.dart b/lib/src/enums/domain_registration_type.dart new file mode 100644 index 00000000..25708628 --- /dev/null +++ b/lib/src/enums/domain_registration_type.dart @@ -0,0 +1,14 @@ +part of '../../enums.dart'; + +enum DomainRegistrationType { + xnew(value: "new"), + transfer(value: "transfer"), + renewal(value: "renewal"), + trade(value: "trade"); + + const DomainRegistrationType({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/domain_transfer_status_enum.dart b/lib/src/enums/domain_transfer_status_enum.dart new file mode 100644 index 00000000..19d231d5 --- /dev/null +++ b/lib/src/enums/domain_transfer_status_enum.dart @@ -0,0 +1,18 @@ +part of '../../enums.dart'; + +enum DomainTransferStatusEnum { + transferrable(value: "transferrable"), + notTransferrable(value: "not_transferrable"), + pendingOwner(value: "pending_owner"), + pendingAdmin(value: "pending_admin"), + pendingRegistry(value: "pending_registry"), + completed(value: "completed"), + cancelled(value: "cancelled"), + serviceUnavailable(value: "service_unavailable"); + + const DomainTransferStatusEnum({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/framework.dart b/lib/src/enums/framework.dart index 7027bf89..1a4d71aa 100644 --- a/lib/src/enums/framework.dart +++ b/lib/src/enums/framework.dart @@ -13,6 +13,7 @@ enum Framework { remix(value: "remix"), lynx(value: "lynx"), flutter(value: "flutter"), + jaspr(value: "jaspr"), reactNative(value: "react-native"), vite(value: "vite"), other(value: "other"); diff --git a/lib/src/enums/id_token_provider.dart b/lib/src/enums/id_token_provider.dart new file mode 100644 index 00000000..4863e845 --- /dev/null +++ b/lib/src/enums/id_token_provider.dart @@ -0,0 +1,12 @@ +part of '../../enums.dart'; + +enum IdTokenProvider { + apple(value: "apple"), + google(value: "google"); + + const IdTokenProvider({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/image_gravity.dart b/lib/src/enums/image_gravity.dart index dbcef202..1a0de57b 100644 --- a/lib/src/enums/image_gravity.dart +++ b/lib/src/enums/image_gravity.dart @@ -1,6 +1,7 @@ part of '../../enums.dart'; enum ImageGravity { + auto(value: "auto"), center(value: "center"), topLeft(value: "top-left"), top(value: "top"), diff --git a/lib/src/enums/o_auth2_auth0_prompt.dart b/lib/src/enums/o_auth2_auth0_prompt.dart new file mode 100644 index 00000000..21494b85 --- /dev/null +++ b/lib/src/enums/o_auth2_auth0_prompt.dart @@ -0,0 +1,13 @@ +part of '../../enums.dart'; + +enum OAuth2Auth0Prompt { + none(value: "none"), + login(value: "login"), + consent(value: "consent"); + + const OAuth2Auth0Prompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/o_auth2_discord_prompt.dart b/lib/src/enums/o_auth2_discord_prompt.dart new file mode 100644 index 00000000..10d90f0e --- /dev/null +++ b/lib/src/enums/o_auth2_discord_prompt.dart @@ -0,0 +1,12 @@ +part of '../../enums.dart'; + +enum OAuth2DiscordPrompt { + none(value: "none"), + consent(value: "consent"); + + const OAuth2DiscordPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/o_auth2_github_prompt.dart b/lib/src/enums/o_auth2_github_prompt.dart new file mode 100644 index 00000000..45b5a930 --- /dev/null +++ b/lib/src/enums/o_auth2_github_prompt.dart @@ -0,0 +1,11 @@ +part of '../../enums.dart'; + +enum OAuth2GithubPrompt { + selectAccount(value: "select_account"); + + const OAuth2GithubPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/o_auth2_kakao_prompt.dart b/lib/src/enums/o_auth2_kakao_prompt.dart new file mode 100644 index 00000000..9618ef35 --- /dev/null +++ b/lib/src/enums/o_auth2_kakao_prompt.dart @@ -0,0 +1,14 @@ +part of '../../enums.dart'; + +enum OAuth2KakaoPrompt { + none(value: "none"), + login(value: "login"), + create(value: "create"), + selectAccount(value: "select_account"); + + const OAuth2KakaoPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/o_auth2_microsoft_prompt.dart b/lib/src/enums/o_auth2_microsoft_prompt.dart new file mode 100644 index 00000000..67790c73 --- /dev/null +++ b/lib/src/enums/o_auth2_microsoft_prompt.dart @@ -0,0 +1,14 @@ +part of '../../enums.dart'; + +enum OAuth2MicrosoftPrompt { + none(value: "none"), + login(value: "login"), + consent(value: "consent"), + selectAccount(value: "select_account"); + + const OAuth2MicrosoftPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/o_auth2_okta_prompt.dart b/lib/src/enums/o_auth2_okta_prompt.dart new file mode 100644 index 00000000..2da97842 --- /dev/null +++ b/lib/src/enums/o_auth2_okta_prompt.dart @@ -0,0 +1,13 @@ +part of '../../enums.dart'; + +enum OAuth2OktaPrompt { + none(value: "none"), + login(value: "login"), + consent(value: "consent"); + + const OAuth2OktaPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/o_auth2_salesforce_prompt.dart b/lib/src/enums/o_auth2_salesforce_prompt.dart new file mode 100644 index 00000000..c95f1bed --- /dev/null +++ b/lib/src/enums/o_auth2_salesforce_prompt.dart @@ -0,0 +1,12 @@ +part of '../../enums.dart'; + +enum OAuth2SalesforcePrompt { + login(value: "login"), + consent(value: "consent"); + + const OAuth2SalesforcePrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/o_auth2_zoho_prompt.dart b/lib/src/enums/o_auth2_zoho_prompt.dart new file mode 100644 index 00000000..3a620a53 --- /dev/null +++ b/lib/src/enums/o_auth2_zoho_prompt.dart @@ -0,0 +1,11 @@ +part of '../../enums.dart'; + +enum OAuth2ZohoPrompt { + consent(value: "consent"); + + const OAuth2ZohoPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/o_auth_provider.dart b/lib/src/enums/o_auth_provider.dart index 6626f3a0..ab1b5668 100644 --- a/lib/src/enums/o_auth_provider.dart +++ b/lib/src/enums/o_auth_provider.dart @@ -23,6 +23,7 @@ enum OAuthProvider { gitlab(value: "gitlab"), google(value: "google"), huggingface(value: "huggingface"), + kakao(value: "kakao"), keycloak(value: "keycloak"), kick(value: "kick"), linkedin(value: "linkedin"), @@ -38,9 +39,11 @@ enum OAuthProvider { slack(value: "slack"), spotify(value: "spotify"), stripe(value: "stripe"), + tiktok(value: "tiktok"), tradeshift(value: "tradeshift"), tradeshiftBox(value: "tradeshiftBox"), twitch(value: "twitch"), + webflow(value: "webflow"), wordpress(value: "wordpress"), x(value: "x"), yahoo(value: "yahoo"), diff --git a/lib/src/enums/project_email_template_id.dart b/lib/src/enums/project_email_template_id.dart index 6328c05b..83574dcb 100644 --- a/lib/src/enums/project_email_template_id.dart +++ b/lib/src/enums/project_email_template_id.dart @@ -7,7 +7,9 @@ enum ProjectEmailTemplateId { invitation(value: "invitation"), mfaChallenge(value: "mfaChallenge"), sessionAlert(value: "sessionAlert"), - otpSession(value: "otpSession"); + otpSession(value: "otpSession"), + otpVerification(value: "otpVerification"), + otpRecovery(value: "otpRecovery"); const ProjectEmailTemplateId({required this.value}); diff --git a/lib/src/enums/project_key_scopes.dart b/lib/src/enums/project_key_scopes.dart index b8fb10fe..86382083 100644 --- a/lib/src/enums/project_key_scopes.dart +++ b/lib/src/enums/project_key_scopes.dart @@ -91,6 +91,7 @@ enum ProjectKeyScopes { webhooksWrite(value: "webhooks.write"), localeRead(value: "locale.read"), avatarsRead(value: "avatars.read"), + avatarsWrite(value: "avatars.write"), healthRead(value: "health.read"), assistantRead(value: "assistant.read"), migrationsRead(value: "migrations.read"), @@ -105,6 +106,7 @@ enum ProjectKeyScopes { reportsWrite(value: "reports.write"), presencesRead(value: "presences.read"), presencesWrite(value: "presences.write"), + dedicatedDatabasesExecute(value: "dedicatedDatabases.execute"), backupsPoliciesRead(value: "backups.policies.read"), backupsPoliciesWrite(value: "backups.policies.write"), archivesRead(value: "archives.read"), @@ -121,7 +123,9 @@ enum ProjectKeyScopes { appsWrite(value: "apps.write"), oauth2Read(value: "oauth2.read"), oauth2Write(value: "oauth2.write"), - oauth2Introspect(value: "oauth2.introspect"); + oauth2Introspect(value: "oauth2.introspect"), + analyticsRead(value: "analytics.read"), + analyticsWrite(value: "analytics.write"); const ProjectKeyScopes({required this.value}); diff --git a/lib/src/enums/project_o_auth2_auth0_prompt.dart b/lib/src/enums/project_o_auth2_auth0_prompt.dart new file mode 100644 index 00000000..f85d52ec --- /dev/null +++ b/lib/src/enums/project_o_auth2_auth0_prompt.dart @@ -0,0 +1,13 @@ +part of '../../enums.dart'; + +enum ProjectOAuth2Auth0Prompt { + none(value: "none"), + login(value: "login"), + consent(value: "consent"); + + const ProjectOAuth2Auth0Prompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/project_o_auth2_discord_prompt.dart b/lib/src/enums/project_o_auth2_discord_prompt.dart new file mode 100644 index 00000000..220ced86 --- /dev/null +++ b/lib/src/enums/project_o_auth2_discord_prompt.dart @@ -0,0 +1,12 @@ +part of '../../enums.dart'; + +enum ProjectOAuth2DiscordPrompt { + none(value: "none"), + consent(value: "consent"); + + const ProjectOAuth2DiscordPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/project_o_auth2_git_hub_prompt.dart b/lib/src/enums/project_o_auth2_git_hub_prompt.dart new file mode 100644 index 00000000..35a186dc --- /dev/null +++ b/lib/src/enums/project_o_auth2_git_hub_prompt.dart @@ -0,0 +1,11 @@ +part of '../../enums.dart'; + +enum ProjectOAuth2GitHubPrompt { + selectAccount(value: "select_account"); + + const ProjectOAuth2GitHubPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/project_o_auth2_kakao_prompt.dart b/lib/src/enums/project_o_auth2_kakao_prompt.dart new file mode 100644 index 00000000..db8fe880 --- /dev/null +++ b/lib/src/enums/project_o_auth2_kakao_prompt.dart @@ -0,0 +1,14 @@ +part of '../../enums.dart'; + +enum ProjectOAuth2KakaoPrompt { + none(value: "none"), + login(value: "login"), + create(value: "create"), + selectAccount(value: "select_account"); + + const ProjectOAuth2KakaoPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/project_o_auth2_microsoft_prompt.dart b/lib/src/enums/project_o_auth2_microsoft_prompt.dart new file mode 100644 index 00000000..0bec05d8 --- /dev/null +++ b/lib/src/enums/project_o_auth2_microsoft_prompt.dart @@ -0,0 +1,14 @@ +part of '../../enums.dart'; + +enum ProjectOAuth2MicrosoftPrompt { + none(value: "none"), + login(value: "login"), + consent(value: "consent"), + selectAccount(value: "select_account"); + + const ProjectOAuth2MicrosoftPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/project_o_auth2_okta_prompt.dart b/lib/src/enums/project_o_auth2_okta_prompt.dart new file mode 100644 index 00000000..71cf665b --- /dev/null +++ b/lib/src/enums/project_o_auth2_okta_prompt.dart @@ -0,0 +1,13 @@ +part of '../../enums.dart'; + +enum ProjectOAuth2OktaPrompt { + none(value: "none"), + login(value: "login"), + consent(value: "consent"); + + const ProjectOAuth2OktaPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/project_o_auth2_salesforce_prompt.dart b/lib/src/enums/project_o_auth2_salesforce_prompt.dart new file mode 100644 index 00000000..e2819df6 --- /dev/null +++ b/lib/src/enums/project_o_auth2_salesforce_prompt.dart @@ -0,0 +1,12 @@ +part of '../../enums.dart'; + +enum ProjectOAuth2SalesforcePrompt { + login(value: "login"), + consent(value: "consent"); + + const ProjectOAuth2SalesforcePrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/project_o_auth2_zoho_prompt.dart b/lib/src/enums/project_o_auth2_zoho_prompt.dart new file mode 100644 index 00000000..469e407e --- /dev/null +++ b/lib/src/enums/project_o_auth2_zoho_prompt.dart @@ -0,0 +1,11 @@ +part of '../../enums.dart'; + +enum ProjectOAuth2ZohoPrompt { + consent(value: "consent"); + + const ProjectOAuth2ZohoPrompt({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/enums/project_o_auth_provider_id.dart b/lib/src/enums/project_o_auth_provider_id.dart index e31770e1..3217a02b 100644 --- a/lib/src/enums/project_o_auth_provider_id.dart +++ b/lib/src/enums/project_o_auth_provider_id.dart @@ -23,6 +23,7 @@ enum ProjectOAuthProviderId { gitlab(value: "gitlab"), google(value: "google"), huggingface(value: "huggingface"), + kakao(value: "kakao"), keycloak(value: "keycloak"), kick(value: "kick"), linkedin(value: "linkedin"), @@ -38,9 +39,11 @@ enum ProjectOAuthProviderId { slack(value: "slack"), spotify(value: "spotify"), stripe(value: "stripe"), + tiktok(value: "tiktok"), tradeshift(value: "tradeshift"), tradeshiftBox(value: "tradeshiftBox"), twitch(value: "twitch"), + webflow(value: "webflow"), wordpress(value: "wordpress"), x(value: "x"), yahoo(value: "yahoo"), diff --git a/lib/src/enums/project_policy_id.dart b/lib/src/enums/project_policy_id.dart index 4a27f62b..c4288263 100644 --- a/lib/src/enums/project_policy_id.dart +++ b/lib/src/enums/project_policy_id.dart @@ -5,6 +5,8 @@ enum ProjectPolicyId { passwordHistory(value: "password-history"), passwordStrength(value: "password-strength"), passwordPersonalData(value: "password-personal-data"), + passwordPwned(value: "password-pwned"), + passwordRotation(value: "password-rotation"), sessionAlert(value: "session-alert"), sessionDuration(value: "session-duration"), sessionInvalidation(value: "session-invalidation"), diff --git a/lib/src/enums/proxy_rule_deployment_resource_type.dart b/lib/src/enums/proxy_rule_deployment_resource_type.dart index 9e9d85b8..f05b1371 100644 --- a/lib/src/enums/proxy_rule_deployment_resource_type.dart +++ b/lib/src/enums/proxy_rule_deployment_resource_type.dart @@ -2,7 +2,8 @@ part of '../../enums.dart'; enum ProxyRuleDeploymentResourceType { function(value: "function"), - site(value: "site"); + site(value: "site"), + dedicatedDatabase(value: "dedicatedDatabase"); const ProxyRuleDeploymentResourceType({required this.value}); diff --git a/lib/src/enums/runtime.dart b/lib/src/enums/runtime.dart index 66f8af54..c1a1e1c6 100644 --- a/lib/src/enums/runtime.dart +++ b/lib/src/enums/runtime.dart @@ -52,6 +52,7 @@ enum Runtime { dart310(value: "dart-3.10"), dart311(value: "dart-3.11"), dart312(value: "dart-3.12"), + dart313(value: "dart-3.13"), dotnet60(value: "dotnet-6.0"), dotnet70(value: "dotnet-7.0"), dotnet80(value: "dotnet-8.0"), @@ -93,7 +94,8 @@ enum Runtime { flutter335(value: "flutter-3.35"), flutter338(value: "flutter-3.38"), flutter341(value: "flutter-3.41"), - flutter344(value: "flutter-3.44"); + flutter344(value: "flutter-3.44"), + flutter347(value: "flutter-3.47"); const Runtime({required this.value}); diff --git a/lib/src/enums/tables_db_index_type.dart b/lib/src/enums/tables_db_index_type.dart index c6e89bac..4872ffda 100644 --- a/lib/src/enums/tables_db_index_type.dart +++ b/lib/src/enums/tables_db_index_type.dart @@ -4,7 +4,8 @@ enum TablesDBIndexType { key(value: "key"), fulltext(value: "fulltext"), unique(value: "unique"), - spatial(value: "spatial"); + spatial(value: "spatial"), + trigram(value: "trigram"); const TablesDBIndexType({required this.value}); diff --git a/lib/src/enums/waf_rule_action.dart b/lib/src/enums/waf_rule_action.dart new file mode 100644 index 00000000..390d7b3d --- /dev/null +++ b/lib/src/enums/waf_rule_action.dart @@ -0,0 +1,15 @@ +part of '../../enums.dart'; + +enum WafRuleAction { + bypass(value: "bypass"), + deny(value: "deny"), + challenge(value: "challenge"), + rateLimit(value: "rateLimit"), + redirect(value: "redirect"); + + const WafRuleAction({required this.value}); + + final String value; + + String toJson() => value; +} diff --git a/lib/src/models/account.dart b/lib/src/models/account.dart new file mode 100644 index 00000000..7ddbf292 --- /dev/null +++ b/lib/src/models/account.dart @@ -0,0 +1,186 @@ +part of '../../models.dart'; + +/// Account +class Account implements Model { + /// User ID. + final String $id; + + /// User creation date in ISO 8601 format. + final String $createdAt; + + /// User update date in ISO 8601 format. + final String $updatedAt; + + /// User name. + final String name; + + /// User registration date in ISO 8601 format. + final String registration; + + /// User status. Pass `true` for enabled and `false` for disabled. + final bool status; + + /// Labels for the user. + final List labels; + + /// Password update time in ISO 8601 format. + final String passwordUpdate; + + /// User email address. + final String email; + + /// User phone number in E.164 format. + final String phone; + + /// Email verification status. + final bool emailVerification; + + /// Canonical form of the user email address. + final String? emailCanonical; + + /// Whether the user email is from a free email provider. + final bool? emailIsFree; + + /// Whether the user email is from a disposable email provider. + final bool? emailIsDisposable; + + /// Whether the user email is from a corporate domain. + final bool? emailIsCorporate; + + /// Whether the user email is in its canonical form. + final bool? emailIsCanonical; + + /// Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. + final bool? passwordPwned; + + /// Phone verification status. + final bool phoneVerification; + + /// Multi factor authentication status. + final bool mfa; + + /// User preferences as a key-value object + final Preferences prefs; + + /// 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. + final List targets; + + /// Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours. + final String accessedAt; + + /// Whether the user can impersonate other users. + final bool? impersonator; + + /// 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. + final String? impersonatorUserId; + + Account({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.registration, + required this.status, + required this.labels, + required this.passwordUpdate, + required this.email, + required this.phone, + required this.emailVerification, + this.emailCanonical, + this.emailIsFree, + this.emailIsDisposable, + this.emailIsCorporate, + this.emailIsCanonical, + this.passwordPwned, + required this.phoneVerification, + required this.mfa, + required this.prefs, + required this.targets, + required this.accessedAt, + this.impersonator, + this.impersonatorUserId, + }); + factory Account.fromMap( + Map map, + ) { + map = { + '\$id': "", + '\$createdAt': "", + '\$updatedAt': "", + 'name': "", + 'registration': "", + 'status': true, + 'labels': [], + 'passwordUpdate': "", + 'email': "", + 'phone': "", + 'emailVerification': false, + 'phoneVerification': false, + 'mfa': false, + 'targets': [], + 'accessedAt': "", + ...map, + }; + + return Account( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + registration: map['registration'].toString(), + status: map['status'], + labels: List.from(map['labels'] ?? []), + passwordUpdate: map['passwordUpdate'].toString(), + email: map['email'].toString(), + phone: map['phone'].toString(), + emailVerification: map['emailVerification'], + emailCanonical: map['emailCanonical']?.toString(), + emailIsFree: map['emailIsFree'], + emailIsDisposable: map['emailIsDisposable'], + emailIsCorporate: map['emailIsCorporate'], + emailIsCanonical: map['emailIsCanonical'], + passwordPwned: map['passwordPwned'], + phoneVerification: map['phoneVerification'], + mfa: map['mfa'], + prefs: Preferences.fromMap( + map['prefs'], + ), + targets: List.from( + map['targets'].map((p) => Target.fromMap(p)), + ), + accessedAt: map['accessedAt'].toString(), + impersonator: map['impersonator'], + impersonatorUserId: map['impersonatorUserId']?.toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "registration": registration, + "status": status, + "labels": labels, + "passwordUpdate": passwordUpdate, + "email": email, + "phone": phone, + "emailVerification": emailVerification, + "emailCanonical": emailCanonical, + "emailIsFree": emailIsFree, + "emailIsDisposable": emailIsDisposable, + "emailIsCorporate": emailIsCorporate, + "emailIsCanonical": emailIsCanonical, + "passwordPwned": passwordPwned, + "phoneVerification": phoneVerification, + "mfa": mfa, + "prefs": prefs.toMap(), + "targets": targets.map((p) => p.toMap()).toList(), + "accessedAt": accessedAt, + "impersonator": impersonator, + "impersonatorUserId": impersonatorUserId, + }; + } +} diff --git a/lib/src/models/billing_plan.dart b/lib/src/models/billing_plan.dart index 53c4e9d6..77e81396 100644 --- a/lib/src/models/billing_plan.dart +++ b/lib/src/models/billing_plan.dart @@ -41,6 +41,9 @@ class BillingPlan implements Model { /// Maximum WAF rules per project final int wafRules; + /// Maximum environments per project. 0 when the plan does not offer environments. + final int? environments; + /// Projects final int projects; @@ -143,6 +146,9 @@ class BillingPlan implements Model { /// Does plan require billing address final bool requiresBillingAddress; + /// ISO country codes eligible for this regional plan. Empty means no restriction. + final List? eligibleCountries; + /// Is the billing plan available final bool isAvailable; @@ -235,6 +241,7 @@ class BillingPlan implements Model { this.members, required this.webhooks, required this.wafRules, + this.environments, required this.projects, required this.platforms, required this.users, @@ -269,6 +276,7 @@ class BillingPlan implements Model { required this.emailBranding, required this.requiresPaymentMethod, required this.requiresBillingAddress, + this.eligibleCountries, required this.isAvailable, required this.selfService, required this.premiumSupport, @@ -313,6 +321,7 @@ class BillingPlan implements Model { members: map['members'], webhooks: map['webhooks'], wafRules: map['wafRules'], + environments: map['environments'], projects: map['projects'], platforms: map['platforms'], users: map['users'], @@ -352,6 +361,7 @@ class BillingPlan implements Model { emailBranding: map['emailBranding'], requiresPaymentMethod: map['requiresPaymentMethod'], requiresBillingAddress: map['requiresBillingAddress'], + eligibleCountries: List.from(map['eligibleCountries'] ?? []), isAvailable: map['isAvailable'], selfService: map['selfService'], premiumSupport: map['premiumSupport'], @@ -414,6 +424,7 @@ class BillingPlan implements Model { "members": members, "webhooks": webhooks, "wafRules": wafRules, + "environments": environments, "projects": projects, "platforms": platforms, "users": users, @@ -448,6 +459,7 @@ class BillingPlan implements Model { "emailBranding": emailBranding, "requiresPaymentMethod": requiresPaymentMethod, "requiresBillingAddress": requiresBillingAddress, + "eligibleCountries": eligibleCountries, "isAvailable": isAvailable, "selfService": selfService, "premiumSupport": premiumSupport, diff --git a/lib/src/models/dedicated_database.dart b/lib/src/models/dedicated_database.dart index 4c574438..8bd79de9 100644 --- a/lib/src/models/dedicated_database.dart +++ b/lib/src/models/dedicated_database.dart @@ -80,6 +80,15 @@ class DedicatedDatabase implements Model { /// Storage allocated in GB. final int storage; + /// Storage resize status. Possible values: idle (no resize in flight), resizing (the volume is growing towards storageTargetGb). + final String? storageStatus; + + /// Size in GB the volume is growing towards while storageStatus is resizing. 0 when no resize is in flight. + final int? storageTargetGb; + + /// Time the in-flight storage resize started, in ISO 8601 format. + final String? storageResizeStartedAt; + /// Storage class. Currently always 'ssd'; DigitalOcean exposes a single block-storage class. final String storageClass; @@ -176,6 +185,9 @@ class DedicatedDatabase implements Model { required this.cpu, required this.memory, required this.storage, + this.storageStatus, + this.storageTargetGb, + this.storageResizeStartedAt, required this.storageClass, required this.storageMaxGb, required this.nodePool, @@ -230,6 +242,9 @@ class DedicatedDatabase implements Model { cpu: map['cpu'], memory: map['memory'], storage: map['storage'], + storageStatus: map['storageStatus']?.toString(), + storageTargetGb: map['storageTargetGb'], + storageResizeStartedAt: map['storageResizeStartedAt']?.toString(), storageClass: map['storageClass'].toString(), storageMaxGb: map['storageMaxGb'], nodePool: map['nodePool'].toString(), @@ -286,6 +301,9 @@ class DedicatedDatabase implements Model { "cpu": cpu, "memory": memory, "storage": storage, + "storageStatus": storageStatus, + "storageTargetGb": storageTargetGb, + "storageResizeStartedAt": storageResizeStartedAt, "storageClass": storageClass, "storageMaxGb": storageMaxGb, "nodePool": nodePool, diff --git a/lib/src/models/dedicated_database_specification.dart b/lib/src/models/dedicated_database_specification.dart index 4b73e233..196eb4a2 100644 --- a/lib/src/models/dedicated_database_specification.dart +++ b/lib/src/models/dedicated_database_specification.dart @@ -11,6 +11,18 @@ class DedicatedDatabaseSpecification implements Model { /// Monthly price of the specification in USD. final double price; + /// Price per GB of storage above the included amount, per month, in USD. + final double? storageOverageRate; + + /// Price per GB of bandwidth above the included amount, per month, in USD. + final double? bandwidthOverageRate; + + /// High availability replica price as a fraction of the specification price. + final double? replicaRate; + + /// Point-in-time recovery price as a fraction of the specification price. + final double? pitrRate; + /// Allocated CPU in millicores. final int cpu; @@ -33,6 +45,10 @@ class DedicatedDatabaseSpecification implements Model { required this.slug, required this.name, required this.price, + this.storageOverageRate, + this.bandwidthOverageRate, + this.replicaRate, + this.pitrRate, required this.cpu, required this.memory, required this.maxConnections, @@ -47,6 +63,10 @@ class DedicatedDatabaseSpecification implements Model { slug: map['slug'].toString(), name: map['name'].toString(), price: map['price'].toDouble(), + storageOverageRate: map['storageOverageRate']?.toDouble(), + bandwidthOverageRate: map['bandwidthOverageRate']?.toDouble(), + replicaRate: map['replicaRate']?.toDouble(), + pitrRate: map['pitrRate']?.toDouble(), cpu: map['cpu'], memory: map['memory'], maxConnections: map['maxConnections'], @@ -62,6 +82,10 @@ class DedicatedDatabaseSpecification implements Model { "slug": slug, "name": name, "price": price, + "storageOverageRate": storageOverageRate, + "bandwidthOverageRate": bandwidthOverageRate, + "replicaRate": replicaRate, + "pitrRate": pitrRate, "cpu": cpu, "memory": memory, "maxConnections": maxConnections, diff --git a/lib/src/models/dns_record.dart b/lib/src/models/dns_record.dart new file mode 100644 index 00000000..c83380f9 --- /dev/null +++ b/lib/src/models/dns_record.dart @@ -0,0 +1,107 @@ +part of '../../models.dart'; + +/// DNSRecord +class DnsRecord implements Model { + /// DNS Record ID. + final String $id; + + /// DNS Record creation time in ISO 8601 format. + final String $createdAt; + + /// DNS Record update date in ISO 8601 format. + final String $updatedAt; + + /// DNS record type (e.g. A, CNAME, MX). + final String type; + + /// Record name or subdomain. + final String name; + + /// Value of the record (IP address, domain, etc.). + final String value; + + /// Time to live (in seconds). + final int ttl; + + /// Record priority (commonly used for MX). + final int priority; + + /// Whether this record is locked (read-only). + final bool lock; + + /// Record weight (used for SRV records). + final int weight; + + /// Target port (used for SRV records). + final int port; + + /// Comment for the DNS record. + final String comment; + + DnsRecord({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.type, + required this.name, + required this.value, + required this.ttl, + required this.priority, + required this.lock, + required this.weight, + required this.port, + required this.comment, + }); + factory DnsRecord.fromMap( + Map map, + ) { + map = { + '\$id': "", + '\$createdAt': "", + '\$updatedAt': "", + 'type': "", + 'name': "", + 'value': "", + 'ttl': 3600, + 'priority': 0, + 'lock': false, + 'weight': 0, + 'port': 0, + 'comment': "", + ...map, + }; + + return DnsRecord( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + type: map['type'].toString(), + name: map['name'].toString(), + value: map['value'].toString(), + ttl: map['ttl'], + priority: map['priority'], + lock: map['lock'], + weight: map['weight'], + port: map['port'], + comment: map['comment'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "type": type, + "name": name, + "value": value, + "ttl": ttl, + "priority": priority, + "lock": lock, + "weight": weight, + "port": port, + "comment": comment, + }; + } +} diff --git a/lib/src/models/dns_records_list.dart b/lib/src/models/dns_records_list.dart new file mode 100644 index 00000000..4c8b5a00 --- /dev/null +++ b/lib/src/models/dns_records_list.dart @@ -0,0 +1,39 @@ +part of '../../models.dart'; + +/// DNS records list +class DnsRecordsList implements Model { + /// Total number of dnsRecords that matched your query. + final int total; + + /// List of dnsRecords. + final List dnsRecords; + + DnsRecordsList({ + required this.total, + required this.dnsRecords, + }); + factory DnsRecordsList.fromMap( + Map map, + ) { + map = { + 'total': 0, + 'dnsRecords': [], + ...map, + }; + + return DnsRecordsList( + total: map['total'], + dnsRecords: List.from( + map['dnsRecords'].map((p) => DnsRecord.fromMap(p)), + ), + ); + } + + @override + Map toMap() { + return { + "total": total, + "dnsRecords": dnsRecords.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/domain.dart b/lib/src/models/domain.dart new file mode 100644 index 00000000..8e65395e --- /dev/null +++ b/lib/src/models/domain.dart @@ -0,0 +1,119 @@ +part of '../../models.dart'; + +/// Domain +class Domain implements Model { + /// Domain ID. + final String $id; + + /// Domain creation time in ISO 8601 format. + final String $createdAt; + + /// Domain update date in ISO 8601 format. + final String $updatedAt; + + /// Domain name. + final String domain; + + /// Domain registrar (e.g. "appwrite" or "third_party"). + final String registrar; + + /// Nameservers setting. "Appwrite" or empty string. + final String nameservers; + + /// Domain expiry date in ISO 8601 format. + final String expire; + + /// Domain renewal date in ISO 8601 format. + final String renewal; + + /// If set to true, the domain will automatically renew. + final bool autoRenewal; + + /// Renewal price (in cents). + final int renewalPrice; + + /// Transfer status for domains being transferred in. Null when the domain is not being transferred. + final enums.DomainTransferStatusEnum? transferStatus; + + /// Team ID. + final String teamId; + + /// Dns records + final List dnsRecords; + + Domain({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.domain, + required this.registrar, + required this.nameservers, + required this.expire, + required this.renewal, + required this.autoRenewal, + required this.renewalPrice, + this.transferStatus, + required this.teamId, + required this.dnsRecords, + }); + factory Domain.fromMap( + Map map, + ) { + map = { + '\$id': "", + '\$createdAt': "", + '\$updatedAt': "", + 'domain': "", + 'registrar': "", + 'nameservers': "", + 'expire': "", + 'renewal': "", + 'autoRenewal': false, + 'renewalPrice': 0, + 'teamId': "", + 'dnsRecords': [], + ...map, + }; + + return Domain( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + domain: map['domain'].toString(), + registrar: map['registrar'].toString(), + nameservers: map['nameservers'].toString(), + expire: map['expire'].toString(), + renewal: map['renewal'].toString(), + autoRenewal: map['autoRenewal'], + renewalPrice: map['renewalPrice'], + transferStatus: map['transferStatus'] != null + ? enums.DomainTransferStatusEnum.values.firstWhere( + (e) => e.value == map['transferStatus'], + ) + : null, + teamId: map['teamId'].toString(), + dnsRecords: List.from( + map['dnsRecords'].map((p) => DnsRecord.fromMap(p)), + ), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "domain": domain, + "registrar": registrar, + "nameservers": nameservers, + "expire": expire, + "renewal": renewal, + "autoRenewal": autoRenewal, + "renewalPrice": renewalPrice, + "transferStatus": transferStatus?.value, + "teamId": teamId, + "dnsRecords": dnsRecords.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/domain_price.dart b/lib/src/models/domain_price.dart new file mode 100644 index 00000000..366d0590 --- /dev/null +++ b/lib/src/models/domain_price.dart @@ -0,0 +1,77 @@ +part of '../../models.dart'; + +/// DomainPrice +class DomainPrice implements Model { + /// Domain name. + final String domain; + + /// Top-level domain for the requested domain. + final String tld; + + /// Whether the domain is currently available for registration. + final bool available; + + /// Domain registration price. Null when the price could not be resolved, for example for an unsupported TLD. + final double? price; + + /// Price period in years. + final int periodYears; + + /// Whether the domain is a premium domain. + final bool premium; + + /// Domain renewal price for the same period. Null when the domain was not priced or the registrar has no renewal price for it. + final double? renewalPrice; + + /// Renewal price period in years. + final int renewalPeriodYears; + + DomainPrice({ + required this.domain, + required this.tld, + required this.available, + this.price, + required this.periodYears, + required this.premium, + this.renewalPrice, + required this.renewalPeriodYears, + }); + factory DomainPrice.fromMap( + Map map, + ) { + map = { + 'domain': "", + 'tld': "", + 'available': false, + 'periodYears': 1, + 'premium': false, + 'renewalPeriodYears': 1, + ...map, + }; + + return DomainPrice( + domain: map['domain'].toString(), + tld: map['tld'].toString(), + available: map['available'], + price: map['price']?.toDouble(), + periodYears: map['periodYears'], + premium: map['premium'], + renewalPrice: map['renewalPrice']?.toDouble(), + renewalPeriodYears: map['renewalPeriodYears'], + ); + } + + @override + Map toMap() { + return { + "domain": domain, + "tld": tld, + "available": available, + "price": price, + "periodYears": periodYears, + "premium": premium, + "renewalPrice": renewalPrice, + "renewalPeriodYears": renewalPeriodYears, + }; + } +} diff --git a/lib/src/models/domain_prices_list.dart b/lib/src/models/domain_prices_list.dart new file mode 100644 index 00000000..a0c34220 --- /dev/null +++ b/lib/src/models/domain_prices_list.dart @@ -0,0 +1,39 @@ +part of '../../models.dart'; + +/// Domain prices list +class DomainPricesList implements Model { + /// Total number of prices that matched your query. + final int total; + + /// List of prices. + final List prices; + + DomainPricesList({ + required this.total, + required this.prices, + }); + factory DomainPricesList.fromMap( + Map map, + ) { + map = { + 'total': 0, + 'prices': [], + ...map, + }; + + return DomainPricesList( + total: map['total'], + prices: List.from( + map['prices'].map((p) => DomainPrice.fromMap(p)), + ), + ); + } + + @override + Map toMap() { + return { + "total": total, + "prices": prices.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/domain_transfer_status.dart b/lib/src/models/domain_transfer_status.dart new file mode 100644 index 00000000..f846ddbb --- /dev/null +++ b/lib/src/models/domain_transfer_status.dart @@ -0,0 +1,46 @@ +part of '../../models.dart'; + +/// domainTransferStatus +class DomainTransferStatus implements Model { + /// Transfer status. + final enums.DomainTransferStatusEnum status; + + /// Additional transfer status information. + final String reason; + + /// Transfer status timestamp in ISO 8601 format. + final String timestamp; + + DomainTransferStatus({ + required this.status, + required this.reason, + required this.timestamp, + }); + factory DomainTransferStatus.fromMap( + Map map, + ) { + map = { + 'status': "pending_registry", + 'reason': "", + 'timestamp': "", + ...map, + }; + + return DomainTransferStatus( + status: enums.DomainTransferStatusEnum.values.firstWhere( + (e) => e.value == map['status'], + ), + reason: map['reason'].toString(), + timestamp: map['timestamp'].toString(), + ); + } + + @override + Map toMap() { + return { + "status": status.value, + "reason": reason, + "timestamp": timestamp, + }; + } +} diff --git a/lib/src/models/domains_list.dart b/lib/src/models/domains_list.dart new file mode 100644 index 00000000..ae3e0f85 --- /dev/null +++ b/lib/src/models/domains_list.dart @@ -0,0 +1,39 @@ +part of '../../models.dart'; + +/// Domains list +class DomainsList implements Model { + /// Total number of domains that matched your query. + final int total; + + /// List of domains. + final List domains; + + DomainsList({ + required this.total, + required this.domains, + }); + factory DomainsList.fromMap( + Map map, + ) { + map = { + 'total': 0, + 'domains': [], + ...map, + }; + + return DomainsList( + total: map['total'], + domains: List.from( + map['domains'].map((p) => Domain.fromMap(p)), + ), + ); + } + + @override + Map toMap() { + return { + "total": total, + "domains": domains.map((p) => p.toMap()).toList(), + }; + } +} diff --git a/lib/src/models/identity.dart b/lib/src/models/identity.dart index 2f32c7f9..0d610894 100644 --- a/lib/src/models/identity.dart +++ b/lib/src/models/identity.dart @@ -32,6 +32,9 @@ class Identity implements Model { /// Identity Provider Refresh Token. final String providerRefreshToken; + /// Identity Provider ID token (JWT) from the most recent native sign-in. Empty for identities created through the browser OAuth2 flow. + final String? providerIdToken; + Identity({ required this.$id, required this.$createdAt, @@ -43,6 +46,7 @@ class Identity implements Model { required this.providerAccessToken, required this.providerAccessTokenExpiry, required this.providerRefreshToken, + this.providerIdToken, }); factory Identity.fromMap( Map map, @@ -58,6 +62,7 @@ class Identity implements Model { providerAccessToken: map['providerAccessToken'].toString(), providerAccessTokenExpiry: map['providerAccessTokenExpiry'].toString(), providerRefreshToken: map['providerRefreshToken'].toString(), + providerIdToken: map['providerIdToken']?.toString(), ); } @@ -74,6 +79,7 @@ class Identity implements Model { "providerAccessToken": providerAccessToken, "providerAccessTokenExpiry": providerAccessTokenExpiry, "providerRefreshToken": providerRefreshToken, + "providerIdToken": providerIdToken, }; } } diff --git a/lib/src/models/o_auth2_apple.dart b/lib/src/models/o_auth2_apple.dart index 4eb7054a..f36f3d63 100644 --- a/lib/src/models/o_auth2_apple.dart +++ b/lib/src/models/o_auth2_apple.dart @@ -20,6 +20,12 @@ class OAuth2Apple implements Model { /// Apple OAuth2 .p8 private key file contents. The secret key wrapped by the PEM markers is 200 characters long. final String p8File; + /// Native Sign in with Apple is active and can be used to create sessions from an ID token. Independent of enabled, which only controls the browser-based flow. + final bool? nativeEnabled; + + /// App bundle IDs accepted as ID token audiences for native Sign in with Apple, next to the Services ID. + final List? nativeClientIds; + OAuth2Apple({ required this.$id, required this.enabled, @@ -27,6 +33,8 @@ class OAuth2Apple implements Model { required this.keyId, required this.teamId, required this.p8File, + this.nativeEnabled, + this.nativeClientIds, }); factory OAuth2Apple.fromMap( Map map, @@ -38,6 +46,8 @@ class OAuth2Apple implements Model { keyId: map['keyId'].toString(), teamId: map['teamId'].toString(), p8File: map['p8File'].toString(), + nativeEnabled: map['nativeEnabled'], + nativeClientIds: List.from(map['nativeClientIds'] ?? []), ); } @@ -50,6 +60,8 @@ class OAuth2Apple implements Model { "keyId": keyId, "teamId": teamId, "p8File": p8File, + "nativeEnabled": nativeEnabled, + "nativeClientIds": nativeClientIds, }; } } diff --git a/lib/src/models/o_auth2_auth0.dart b/lib/src/models/o_auth2_auth0.dart index e79096f2..3b94d373 100644 --- a/lib/src/models/o_auth2_auth0.dart +++ b/lib/src/models/o_auth2_auth0.dart @@ -14,6 +14,9 @@ class OAuth2Auth0 implements Model { /// Auth0 OAuth2 client secret. final String clientSecret; + /// Auth0 OAuth2 prompt values. + final List? prompt; + /// Auth0 OAuth2 endpoint domain. final String endpoint; @@ -22,6 +25,7 @@ class OAuth2Auth0 implements Model { required this.enabled, required this.clientId, required this.clientSecret, + this.prompt, required this.endpoint, }); factory OAuth2Auth0.fromMap( @@ -32,6 +36,14 @@ class OAuth2Auth0 implements Model { enabled: map['enabled'], clientId: map['clientId'].toString(), clientSecret: map['clientSecret'].toString(), + prompt: map['prompt'] != null + ? List.from( + map['prompt'].map( + (p) => + enums.OAuth2Auth0Prompt.values.firstWhere((e) => e.value == p), + ), + ) + : null, endpoint: map['endpoint'].toString(), ); } @@ -43,6 +55,7 @@ class OAuth2Auth0 implements Model { "enabled": enabled, "clientId": clientId, "clientSecret": clientSecret, + "prompt": prompt?.map((p) => p.value).toList(), "endpoint": endpoint, }; } diff --git a/lib/src/models/o_auth2_discord.dart b/lib/src/models/o_auth2_discord.dart index e91a9037..f0ef7cb0 100644 --- a/lib/src/models/o_auth2_discord.dart +++ b/lib/src/models/o_auth2_discord.dart @@ -14,11 +14,15 @@ class OAuth2Discord implements Model { /// Discord OAuth2 client secret. final String clientSecret; + /// Discord OAuth2 prompt values. + final List? prompt; + OAuth2Discord({ required this.$id, required this.enabled, required this.clientId, required this.clientSecret, + this.prompt, }); factory OAuth2Discord.fromMap( Map map, @@ -28,6 +32,14 @@ class OAuth2Discord implements Model { enabled: map['enabled'], clientId: map['clientId'].toString(), clientSecret: map['clientSecret'].toString(), + prompt: map['prompt'] != null + ? List.from( + map['prompt'].map( + (p) => + enums.OAuth2DiscordPrompt.values.firstWhere((e) => e.value == p), + ), + ) + : null, ); } @@ -38,6 +50,7 @@ class OAuth2Discord implements Model { "enabled": enabled, "clientId": clientId, "clientSecret": clientSecret, + "prompt": prompt?.map((p) => p.value).toList(), }; } } diff --git a/lib/src/models/o_auth2_github.dart b/lib/src/models/o_auth2_github.dart index 02e8800d..09ee1112 100644 --- a/lib/src/models/o_auth2_github.dart +++ b/lib/src/models/o_auth2_github.dart @@ -14,11 +14,15 @@ class OAuth2Github implements Model { /// GitHub OAuth2 client secret. final String clientSecret; + /// GitHub OAuth2 prompt values. + final List? prompt; + OAuth2Github({ required this.$id, required this.enabled, required this.clientId, required this.clientSecret, + this.prompt, }); factory OAuth2Github.fromMap( Map map, @@ -28,6 +32,14 @@ class OAuth2Github implements Model { enabled: map['enabled'], clientId: map['clientId'].toString(), clientSecret: map['clientSecret'].toString(), + prompt: map['prompt'] != null + ? List.from( + map['prompt'].map( + (p) => + enums.OAuth2GithubPrompt.values.firstWhere((e) => e.value == p), + ), + ) + : null, ); } @@ -38,6 +50,7 @@ class OAuth2Github implements Model { "enabled": enabled, "clientId": clientId, "clientSecret": clientSecret, + "prompt": prompt?.map((p) => p.value).toList(), }; } } diff --git a/lib/src/models/o_auth2_google.dart b/lib/src/models/o_auth2_google.dart index f5e836a3..4a9b4d59 100644 --- a/lib/src/models/o_auth2_google.dart +++ b/lib/src/models/o_auth2_google.dart @@ -17,12 +17,20 @@ class OAuth2Google implements Model { /// Google OAuth2 prompt values. final List prompt; + /// Native Google sign-in is active and can be used to create sessions from an ID token. Independent of enabled, which only controls the browser-based flow. + final bool? nativeEnabled; + + /// Additional OAuth2 client IDs accepted as ID token audiences for native sign-in, next to the client ID. + final List? nativeClientIds; + OAuth2Google({ required this.$id, required this.enabled, required this.clientId, required this.clientSecret, required this.prompt, + this.nativeEnabled, + this.nativeClientIds, }); factory OAuth2Google.fromMap( Map map, @@ -38,6 +46,8 @@ class OAuth2Google implements Model { enums.OAuth2GooglePrompt.values.firstWhere((e) => e.value == p), ), ), + nativeEnabled: map['nativeEnabled'], + nativeClientIds: List.from(map['nativeClientIds'] ?? []), ); } @@ -49,6 +59,8 @@ class OAuth2Google implements Model { "clientId": clientId, "clientSecret": clientSecret, "prompt": prompt.map((p) => p.value).toList(), + "nativeEnabled": nativeEnabled, + "nativeClientIds": nativeClientIds, }; } } diff --git a/lib/src/models/o_auth2_kakao.dart b/lib/src/models/o_auth2_kakao.dart new file mode 100644 index 00000000..61577787 --- /dev/null +++ b/lib/src/models/o_auth2_kakao.dart @@ -0,0 +1,63 @@ +part of '../../models.dart'; + +/// OAuth2Kakao +class OAuth2Kakao implements Model { + /// OAuth2 provider ID. + final String $id; + + /// OAuth2 provider is active and can be used to create sessions. + final bool enabled; + + /// Kakao OAuth2 REST API key. + final String clientId; + + /// Kakao OAuth2 client secret. + final String clientSecret; + + /// Kakao OAuth2 prompt values. + final List prompt; + + OAuth2Kakao({ + required this.$id, + required this.enabled, + required this.clientId, + required this.clientSecret, + required this.prompt, + }); + factory OAuth2Kakao.fromMap( + Map map, + ) { + map = { + '\$id': "", + 'enabled': false, + 'clientId': "", + 'clientSecret': "", + 'prompt': [], + ...map, + }; + + return OAuth2Kakao( + $id: map['\$id'].toString(), + enabled: map['enabled'], + clientId: map['clientId'].toString(), + clientSecret: map['clientSecret'].toString(), + prompt: List.from( + map['prompt'].map( + (p) => + enums.OAuth2KakaoPrompt.values.firstWhere((e) => e.value == p), + ), + ), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "enabled": enabled, + "clientId": clientId, + "clientSecret": clientSecret, + "prompt": prompt.map((p) => p.value).toList(), + }; + } +} diff --git a/lib/src/models/o_auth2_microsoft.dart b/lib/src/models/o_auth2_microsoft.dart index a8bb36df..d08b786d 100644 --- a/lib/src/models/o_auth2_microsoft.dart +++ b/lib/src/models/o_auth2_microsoft.dart @@ -14,6 +14,9 @@ class OAuth2Microsoft implements Model { /// Microsoft OAuth2 application secret. final String applicationSecret; + /// Microsoft OAuth2 prompt values. + final List? prompt; + /// Microsoft Entra ID tenant identifier. Use 'common', 'organizations', 'consumers' or a specific tenant ID. final String tenant; @@ -22,6 +25,7 @@ class OAuth2Microsoft implements Model { required this.enabled, required this.applicationId, required this.applicationSecret, + this.prompt, required this.tenant, }); factory OAuth2Microsoft.fromMap( @@ -32,6 +36,14 @@ class OAuth2Microsoft implements Model { enabled: map['enabled'], applicationId: map['applicationId'].toString(), applicationSecret: map['applicationSecret'].toString(), + prompt: map['prompt'] != null + ? List.from( + map['prompt'].map( + (p) => + enums.OAuth2MicrosoftPrompt.values.firstWhere((e) => e.value == p), + ), + ) + : null, tenant: map['tenant'].toString(), ); } @@ -43,6 +55,7 @@ class OAuth2Microsoft implements Model { "enabled": enabled, "applicationId": applicationId, "applicationSecret": applicationSecret, + "prompt": prompt?.map((p) => p.value).toList(), "tenant": tenant, }; } diff --git a/lib/src/models/o_auth2_okta.dart b/lib/src/models/o_auth2_okta.dart index 1bf02349..5571667c 100644 --- a/lib/src/models/o_auth2_okta.dart +++ b/lib/src/models/o_auth2_okta.dart @@ -14,6 +14,9 @@ class OAuth2Okta implements Model { /// Okta OAuth2 client secret. final String clientSecret; + /// Okta OAuth2 prompt values. + final List? prompt; + /// Okta OAuth2 domain. final String domain; @@ -25,6 +28,7 @@ class OAuth2Okta implements Model { required this.enabled, required this.clientId, required this.clientSecret, + this.prompt, required this.domain, required this.authorizationServerId, }); @@ -36,6 +40,13 @@ class OAuth2Okta implements Model { enabled: map['enabled'], clientId: map['clientId'].toString(), clientSecret: map['clientSecret'].toString(), + prompt: map['prompt'] != null + ? List.from( + map['prompt'].map( + (p) => enums.OAuth2OktaPrompt.values.firstWhere((e) => e.value == p), + ), + ) + : null, domain: map['domain'].toString(), authorizationServerId: map['authorizationServerId'].toString(), ); @@ -48,6 +59,7 @@ class OAuth2Okta implements Model { "enabled": enabled, "clientId": clientId, "clientSecret": clientSecret, + "prompt": prompt?.map((p) => p.value).toList(), "domain": domain, "authorizationServerId": authorizationServerId, }; diff --git a/lib/src/models/o_auth2_salesforce.dart b/lib/src/models/o_auth2_salesforce.dart index 450818aa..dfa363a9 100644 --- a/lib/src/models/o_auth2_salesforce.dart +++ b/lib/src/models/o_auth2_salesforce.dart @@ -14,11 +14,15 @@ class OAuth2Salesforce implements Model { /// Salesforce OAuth2 consumer secret. final String customerSecret; + /// Salesforce OAuth2 prompt values. + final List? prompt; + OAuth2Salesforce({ required this.$id, required this.enabled, required this.customerKey, required this.customerSecret, + this.prompt, }); factory OAuth2Salesforce.fromMap( Map map, @@ -28,6 +32,14 @@ class OAuth2Salesforce implements Model { enabled: map['enabled'], customerKey: map['customerKey'].toString(), customerSecret: map['customerSecret'].toString(), + prompt: map['prompt'] != null + ? List.from( + map['prompt'].map( + (p) => + enums.OAuth2SalesforcePrompt.values.firstWhere((e) => e.value == p), + ), + ) + : null, ); } @@ -38,6 +50,7 @@ class OAuth2Salesforce implements Model { "enabled": enabled, "customerKey": customerKey, "customerSecret": customerSecret, + "prompt": prompt?.map((p) => p.value).toList(), }; } } diff --git a/lib/src/models/o_auth2_tik_tok.dart b/lib/src/models/o_auth2_tik_tok.dart new file mode 100644 index 00000000..dca511aa --- /dev/null +++ b/lib/src/models/o_auth2_tik_tok.dart @@ -0,0 +1,51 @@ +part of '../../models.dart'; + +/// OAuth2TikTok +class OAuth2TikTok implements Model { + /// OAuth2 provider ID. + final String $id; + + /// OAuth2 provider is active and can be used to create sessions. + final bool enabled; + + /// TikTok OAuth2 client key. + final String clientId; + + /// TikTok OAuth2 client secret. + final String clientSecret; + + OAuth2TikTok({ + required this.$id, + required this.enabled, + required this.clientId, + required this.clientSecret, + }); + factory OAuth2TikTok.fromMap( + Map map, + ) { + map = { + '\$id': "", + 'enabled': false, + 'clientId': "", + 'clientSecret': "", + ...map, + }; + + return OAuth2TikTok( + $id: map['\$id'].toString(), + enabled: map['enabled'], + clientId: map['clientId'].toString(), + clientSecret: map['clientSecret'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "enabled": enabled, + "clientId": clientId, + "clientSecret": clientSecret, + }; + } +} diff --git a/lib/src/models/o_auth2_webflow.dart b/lib/src/models/o_auth2_webflow.dart new file mode 100644 index 00000000..df9ee6e1 --- /dev/null +++ b/lib/src/models/o_auth2_webflow.dart @@ -0,0 +1,51 @@ +part of '../../models.dart'; + +/// OAuth2Webflow +class OAuth2Webflow implements Model { + /// OAuth2 provider ID. + final String $id; + + /// OAuth2 provider is active and can be used to create sessions. + final bool enabled; + + /// Webflow OAuth2 client ID. + final String clientId; + + /// Webflow OAuth2 client secret. + final String clientSecret; + + OAuth2Webflow({ + required this.$id, + required this.enabled, + required this.clientId, + required this.clientSecret, + }); + factory OAuth2Webflow.fromMap( + Map map, + ) { + map = { + '\$id': "", + 'enabled': false, + 'clientId': "", + 'clientSecret': "", + ...map, + }; + + return OAuth2Webflow( + $id: map['\$id'].toString(), + enabled: map['enabled'], + clientId: map['clientId'].toString(), + clientSecret: map['clientSecret'].toString(), + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "enabled": enabled, + "clientId": clientId, + "clientSecret": clientSecret, + }; + } +} diff --git a/lib/src/models/o_auth2_zoho.dart b/lib/src/models/o_auth2_zoho.dart index e8b4382a..6cc55f0f 100644 --- a/lib/src/models/o_auth2_zoho.dart +++ b/lib/src/models/o_auth2_zoho.dart @@ -14,11 +14,15 @@ class OAuth2Zoho implements Model { /// Zoho OAuth2 client secret. final String clientSecret; + /// Zoho OAuth2 prompt values. + final List? prompt; + OAuth2Zoho({ required this.$id, required this.enabled, required this.clientId, required this.clientSecret, + this.prompt, }); factory OAuth2Zoho.fromMap( Map map, @@ -28,6 +32,13 @@ class OAuth2Zoho implements Model { enabled: map['enabled'], clientId: map['clientId'].toString(), clientSecret: map['clientSecret'].toString(), + prompt: map['prompt'] != null + ? List.from( + map['prompt'].map( + (p) => enums.OAuth2ZohoPrompt.values.firstWhere((e) => e.value == p), + ), + ) + : null, ); } @@ -38,6 +49,7 @@ class OAuth2Zoho implements Model { "enabled": enabled, "clientId": clientId, "clientSecret": clientSecret, + "prompt": prompt?.map((p) => p.value).toList(), }; } } diff --git a/lib/src/models/oauth2_introspection.dart b/lib/src/models/oauth2_introspection.dart new file mode 100644 index 00000000..d81f2553 --- /dev/null +++ b/lib/src/models/oauth2_introspection.dart @@ -0,0 +1,96 @@ +part of '../../models.dart'; + +/// OAuth2 Introspection +class Oauth2Introspection implements Model { + /// Whether the token is currently active. An inactive token carries no other claims (RFC 7662). + final bool active; + + /// Kind of token that was introspected. Can be one of: `access_token` or `refresh_token`. + final String? token_use; + + /// OAuth2 token type. + final String? token_type; + + /// Space-separated scopes granted to the token. + final String? scope; + + /// OAuth2 client ID the token was issued to. + final String? client_id; + + /// ID of the user who authorized the token. + final String? sub; + + /// Audiences the token is intended for. The first entry is the project API base URL; any further entries are the resource indicators requested at authorization time (RFC 8707). + final List? aud; + + /// Issuer URL of the token. + final String? iss; + + /// Expiration time as a Unix timestamp in seconds. + final int? exp; + + /// Issued-at time as a Unix timestamp in seconds. + final int? iat; + + /// Unique identifier of the token. + final String? jti; + + /// Granted RFC 9396 authorization details, restricted to what the user can currently access. + final List? authorization_details; + + Oauth2Introspection({ + required this.active, + this.token_use, + this.token_type, + this.scope, + this.client_id, + this.sub, + this.aud, + this.iss, + this.exp, + this.iat, + this.jti, + this.authorization_details, + }); + factory Oauth2Introspection.fromMap( + Map map, + ) { + map = { + 'active': false, + ...map, + }; + + return Oauth2Introspection( + active: map['active'], + token_use: map['token_use']?.toString(), + token_type: map['token_type']?.toString(), + scope: map['scope']?.toString(), + client_id: map['client_id']?.toString(), + sub: map['sub']?.toString(), + aud: List.from(map['aud'] ?? []), + iss: map['iss']?.toString(), + exp: map['exp'], + iat: map['iat'], + jti: map['jti']?.toString(), + authorization_details: List.from(map['authorization_details'] ?? []), + ); + } + + @override + Map toMap() { + return { + "active": active, + "token_use": token_use, + "token_type": token_type, + "scope": scope, + "client_id": client_id, + "sub": sub, + "aud": aud, + "iss": iss, + "exp": exp, + "iat": iat, + "jti": jti, + "authorization_details": authorization_details, + }; + } +} diff --git a/lib/src/models/platform_android.dart b/lib/src/models/platform_android.dart index 86975e68..53302889 100644 --- a/lib/src/models/platform_android.dart +++ b/lib/src/models/platform_android.dart @@ -20,6 +20,9 @@ class PlatformAndroid implements Model { /// Android application ID. final String applicationId; + /// SHA-256 fingerprints of the certificates the app is signed with. Passkeys created in the app are accepted when its signature matches one. + final List? fingerprints; + PlatformAndroid({ required this.$id, required this.$createdAt, @@ -27,6 +30,7 @@ class PlatformAndroid implements Model { required this.name, required this.type, required this.applicationId, + this.fingerprints, }); factory PlatformAndroid.fromMap( Map map, @@ -40,6 +44,7 @@ class PlatformAndroid implements Model { (e) => e.value == map['type'], ), applicationId: map['applicationId'].toString(), + fingerprints: List.from(map['fingerprints'] ?? []), ); } @@ -52,6 +57,7 @@ class PlatformAndroid implements Model { "name": name, "type": type.value, "applicationId": applicationId, + "fingerprints": fingerprints, }; } } diff --git a/lib/src/models/policy_password_pwned.dart b/lib/src/models/policy_password_pwned.dart new file mode 100644 index 00000000..e29a96e0 --- /dev/null +++ b/lib/src/models/policy_password_pwned.dart @@ -0,0 +1,51 @@ +part of '../../models.dart'; + +/// Policy Password Pwned +class PolicyPasswordPwned implements Model { + /// Policy ID. + final String $id; + + /// Whether passwords are checked against known data breaches and the result recorded on the user. + final bool enabled; + + /// Whether a sign-in with a breached password is refused until the password is reset. + final bool sessions; + + /// Whether a breached password is rejected when a user signs up or sets a new password. + final bool users; + + PolicyPasswordPwned({ + required this.$id, + required this.enabled, + required this.sessions, + required this.users, + }); + factory PolicyPasswordPwned.fromMap( + Map map, + ) { + map = { + '\$id': "", + 'enabled': true, + 'sessions': false, + 'users': false, + ...map, + }; + + return PolicyPasswordPwned( + $id: map['\$id'].toString(), + enabled: map['enabled'], + sessions: map['sessions'], + users: map['users'], + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "enabled": enabled, + "sessions": sessions, + "users": users, + }; + } +} diff --git a/lib/src/models/policy_password_rotation.dart b/lib/src/models/policy_password_rotation.dart new file mode 100644 index 00000000..f385ecbb --- /dev/null +++ b/lib/src/models/policy_password_rotation.dart @@ -0,0 +1,44 @@ +part of '../../models.dart'; + +/// Policy Password Rotation +class PolicyPasswordRotation implements Model { + /// Policy ID. + final String $id; + + /// Whether expired passwords require a reset before email/password sign-in. + final bool enabled; + + /// Maximum password age in seconds. + final int maxAge; + + PolicyPasswordRotation({ + required this.$id, + required this.enabled, + required this.maxAge, + }); + factory PolicyPasswordRotation.fromMap( + Map map, + ) { + map = { + '\$id': "", + 'enabled': false, + 'maxAge': 31536000, + ...map, + }; + + return PolicyPasswordRotation( + $id: map['\$id'].toString(), + enabled: map['enabled'], + maxAge: map['maxAge'], + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "enabled": enabled, + "maxAge": maxAge, + }; + } +} diff --git a/lib/src/models/project.dart b/lib/src/models/project.dart index 5f73fef7..8c5778d5 100644 --- a/lib/src/models/project.dart +++ b/lib/src/models/project.dart @@ -86,9 +86,18 @@ class Project implements Model { /// Whether WAF enforcement is enabled for the project. final bool? wafEnabled; + /// ID of the project this environment belongs to. Null when the project is not an environment. + final String? parentId; + /// Billing limits reached final BillingLimits? billingLimits; + /// First time the project received a non-console API request. Empty until the project is used. + final String? firstAccessedAt; + + /// Last time the project was accessed through the MCP server. Empty if it was never accessed via MCP. + final String? mcpAccessedAt; + /// OAuth2 server status final bool? oAuth2ServerEnabled; @@ -169,7 +178,10 @@ class Project implements Model { required this.blocks, required this.consoleAccessedAt, this.wafEnabled, + this.parentId, this.billingLimits, + this.firstAccessedAt, + this.mcpAccessedAt, this.oAuth2ServerEnabled, this.oAuth2ServerAuthorizationUrl, this.oAuth2ServerScopes, @@ -230,11 +242,14 @@ class Project implements Model { ), consoleAccessedAt: map['consoleAccessedAt'].toString(), wafEnabled: map['wafEnabled'], + parentId: map['parentId']?.toString(), billingLimits: map['billingLimits'] != null ? BillingLimits.fromMap( map['billingLimits'], ) : null, + firstAccessedAt: map['firstAccessedAt']?.toString(), + mcpAccessedAt: map['mcpAccessedAt']?.toString(), oAuth2ServerEnabled: map['oAuth2ServerEnabled'], oAuth2ServerAuthorizationUrl: map['oAuth2ServerAuthorizationUrl']?.toString(), @@ -294,7 +309,10 @@ class Project implements Model { "blocks": blocks.map((p) => p.toMap()).toList(), "consoleAccessedAt": consoleAccessedAt, "wafEnabled": wafEnabled, + "parentId": parentId, "billingLimits": billingLimits?.toMap(), + "firstAccessedAt": firstAccessedAt, + "mcpAccessedAt": mcpAccessedAt, "oAuth2ServerEnabled": oAuth2ServerEnabled, "oAuth2ServerAuthorizationUrl": oAuth2ServerAuthorizationUrl, "oAuth2ServerScopes": oAuth2ServerScopes, diff --git a/lib/src/models/topic.dart b/lib/src/models/topic.dart index d45c6666..3b656520 100644 --- a/lib/src/models/topic.dart +++ b/lib/src/models/topic.dart @@ -26,6 +26,12 @@ class Topic implements Model { /// Subscribe permissions. final List subscribe; + /// MQTT QoS for delivery on this topic. Null lets the subscriber choose their level. + final int? qos; + + /// Message retention in seconds for offline delivery. + final int? expiry; + Topic({ required this.$id, required this.$createdAt, @@ -35,6 +41,8 @@ class Topic implements Model { required this.smsTotal, required this.pushTotal, required this.subscribe, + this.qos, + this.expiry, }); factory Topic.fromMap( Map map, @@ -48,6 +56,8 @@ class Topic implements Model { smsTotal: map['smsTotal'], pushTotal: map['pushTotal'], subscribe: List.from(map['subscribe'] ?? []), + qos: map['qos'], + expiry: map['expiry'], ); } @@ -62,6 +72,8 @@ class Topic implements Model { "smsTotal": smsTotal, "pushTotal": pushTotal, "subscribe": subscribe, + "qos": qos, + "expiry": expiry, }; } } diff --git a/lib/src/models/user.dart b/lib/src/models/user.dart index 8650dfd5..7d58b908 100644 --- a/lib/src/models/user.dart +++ b/lib/src/models/user.dart @@ -59,6 +59,9 @@ class User implements Model { /// Whether the user email is in its canonical form. final bool? emailIsCanonical; + /// Whether the password was found in a known data breach the last time it was checked. Null when the password has never been checked. + final bool? passwordPwned; + /// Phone verification status. final bool phoneVerification; @@ -100,6 +103,7 @@ class User implements Model { this.emailIsDisposable, this.emailIsCorporate, this.emailIsCanonical, + this.passwordPwned, required this.phoneVerification, required this.mfa, required this.prefs, @@ -131,6 +135,7 @@ class User implements Model { emailIsDisposable: map['emailIsDisposable'], emailIsCorporate: map['emailIsCorporate'], emailIsCanonical: map['emailIsCanonical'], + passwordPwned: map['passwordPwned'], phoneVerification: map['phoneVerification'], mfa: map['mfa'], prefs: Preferences.fromMap( @@ -167,6 +172,7 @@ class User implements Model { "emailIsDisposable": emailIsDisposable, "emailIsCorporate": emailIsCorporate, "emailIsCanonical": emailIsCanonical, + "passwordPwned": passwordPwned, "phoneVerification": phoneVerification, "mfa": mfa, "prefs": prefs.toMap(), diff --git a/lib/src/models/waf_rule_bypass.dart b/lib/src/models/waf_rule_bypass.dart new file mode 100644 index 00000000..3ca01703 --- /dev/null +++ b/lib/src/models/waf_rule_bypass.dart @@ -0,0 +1,122 @@ +part of '../../models.dart'; + +/// WafRuleBypass +class WafRuleBypass implements Model { + /// Rule ID. + final String $id; + + /// WAF rule creation time in ISO 8601 format. + final String $createdAt; + + /// WAF rule last update time in ISO 8601 format. + final String $updatedAt; + + /// Human friendly rule name. + final String name; + + /// Optional description for the rule. + final String description; + + /// Team ID. + final String teamId; + + /// Project ID. + final String projectId; + + /// Resource type the rule is scoped to. + final String resourceType; + + /// Resource identifier. Empty for API-wide rules. + final String resourceId; + + /// Action performed when the rule matches. + final enums.WafRuleAction action; + + /// Evaluation priority. Lower values execute earlier. + final int priority; + + /// Whether the rule is active. + final bool enabled; + + /// List of conditions evaluated for this rule. + final List conditions; + + /// Action specific configuration. + final Map config; + + WafRuleBypass({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.description, + required this.teamId, + required this.projectId, + required this.resourceType, + required this.resourceId, + required this.action, + required this.priority, + required this.enabled, + required this.conditions, + required this.config, + }); + factory WafRuleBypass.fromMap( + Map map, + ) { + map = { + '\$id': "", + '\$createdAt': "", + '\$updatedAt': "", + 'name': "", + 'description': "", + 'teamId': "", + 'projectId': "", + 'resourceType': "api", + 'resourceId': "", + 'priority': 0, + 'enabled': true, + 'conditions': [], + 'config': {}, + ...map, + }; + + return WafRuleBypass( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + description: map['description'].toString(), + teamId: map['teamId'].toString(), + projectId: map['projectId'].toString(), + resourceType: map['resourceType'].toString(), + resourceId: map['resourceId'].toString(), + action: enums.WafRuleAction.values.firstWhere( + (e) => e.value == map['action'], + ), + priority: map['priority'], + enabled: map['enabled'], + conditions: List.from(map['conditions'] ?? []), + config: map['config'], + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "description": description, + "teamId": teamId, + "projectId": projectId, + "resourceType": resourceType, + "resourceId": resourceId, + "action": action.value, + "priority": priority, + "enabled": enabled, + "conditions": conditions, + "config": config, + }; + } +} diff --git a/lib/src/models/waf_rule_challenge.dart b/lib/src/models/waf_rule_challenge.dart new file mode 100644 index 00000000..6990c31d --- /dev/null +++ b/lib/src/models/waf_rule_challenge.dart @@ -0,0 +1,143 @@ +part of '../../models.dart'; + +/// WafRuleChallenge +class WafRuleChallenge implements Model { + /// Rule ID. + final String $id; + + /// WAF rule creation time in ISO 8601 format. + final String $createdAt; + + /// WAF rule last update time in ISO 8601 format. + final String $updatedAt; + + /// Human friendly rule name. + final String name; + + /// Optional description for the rule. + final String description; + + /// Team ID. + final String teamId; + + /// Project ID. + final String projectId; + + /// Resource type the rule is scoped to. + final String resourceType; + + /// Resource identifier. Empty for API-wide rules. + final String resourceId; + + /// Action performed when the rule matches. + final enums.WafRuleAction action; + + /// Evaluation priority. Lower values execute earlier. + final int priority; + + /// Whether the rule is active. + final bool enabled; + + /// List of conditions evaluated for this rule. + final List conditions; + + /// Action specific configuration. + final Map config; + + /// Challenge type enforced when the rule matches. + final String challengeType; + + /// Challenge difficulty from 1 (easiest) to 5 (hardest) enforced when the rule matches. + final int difficulty; + + /// Seconds a visitor stays cleared after passing the challenge before being challenged again. + final int ttl; + + WafRuleChallenge({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.description, + required this.teamId, + required this.projectId, + required this.resourceType, + required this.resourceId, + required this.action, + required this.priority, + required this.enabled, + required this.conditions, + required this.config, + required this.challengeType, + required this.difficulty, + required this.ttl, + }); + factory WafRuleChallenge.fromMap( + Map map, + ) { + map = { + '\$id': "", + '\$createdAt': "", + '\$updatedAt': "", + 'name': "", + 'description': "", + 'teamId': "", + 'projectId': "", + 'resourceType': "api", + 'resourceId': "", + 'priority': 0, + 'enabled': true, + 'conditions': [], + 'config': {}, + 'challengeType': "compute", + 'difficulty': 3, + 'ttl': 1800, + ...map, + }; + + return WafRuleChallenge( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + description: map['description'].toString(), + teamId: map['teamId'].toString(), + projectId: map['projectId'].toString(), + resourceType: map['resourceType'].toString(), + resourceId: map['resourceId'].toString(), + action: enums.WafRuleAction.values.firstWhere( + (e) => e.value == map['action'], + ), + priority: map['priority'], + enabled: map['enabled'], + conditions: List.from(map['conditions'] ?? []), + config: map['config'], + challengeType: map['challengeType'].toString(), + difficulty: map['difficulty'], + ttl: map['ttl'], + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "description": description, + "teamId": teamId, + "projectId": projectId, + "resourceType": resourceType, + "resourceId": resourceId, + "action": action.value, + "priority": priority, + "enabled": enabled, + "conditions": conditions, + "config": config, + "challengeType": challengeType, + "difficulty": difficulty, + "ttl": ttl, + }; + } +} diff --git a/lib/src/models/waf_rule_deny.dart b/lib/src/models/waf_rule_deny.dart new file mode 100644 index 00000000..d37a0c1e --- /dev/null +++ b/lib/src/models/waf_rule_deny.dart @@ -0,0 +1,122 @@ +part of '../../models.dart'; + +/// WafRuleDeny +class WafRuleDeny implements Model { + /// Rule ID. + final String $id; + + /// WAF rule creation time in ISO 8601 format. + final String $createdAt; + + /// WAF rule last update time in ISO 8601 format. + final String $updatedAt; + + /// Human friendly rule name. + final String name; + + /// Optional description for the rule. + final String description; + + /// Team ID. + final String teamId; + + /// Project ID. + final String projectId; + + /// Resource type the rule is scoped to. + final String resourceType; + + /// Resource identifier. Empty for API-wide rules. + final String resourceId; + + /// Action performed when the rule matches. + final enums.WafRuleAction action; + + /// Evaluation priority. Lower values execute earlier. + final int priority; + + /// Whether the rule is active. + final bool enabled; + + /// List of conditions evaluated for this rule. + final List conditions; + + /// Action specific configuration. + final Map config; + + WafRuleDeny({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.description, + required this.teamId, + required this.projectId, + required this.resourceType, + required this.resourceId, + required this.action, + required this.priority, + required this.enabled, + required this.conditions, + required this.config, + }); + factory WafRuleDeny.fromMap( + Map map, + ) { + map = { + '\$id': "", + '\$createdAt': "", + '\$updatedAt': "", + 'name': "", + 'description': "", + 'teamId': "", + 'projectId': "", + 'resourceType': "api", + 'resourceId': "", + 'priority': 0, + 'enabled': true, + 'conditions': [], + 'config': {}, + ...map, + }; + + return WafRuleDeny( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + description: map['description'].toString(), + teamId: map['teamId'].toString(), + projectId: map['projectId'].toString(), + resourceType: map['resourceType'].toString(), + resourceId: map['resourceId'].toString(), + action: enums.WafRuleAction.values.firstWhere( + (e) => e.value == map['action'], + ), + priority: map['priority'], + enabled: map['enabled'], + conditions: List.from(map['conditions'] ?? []), + config: map['config'], + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "description": description, + "teamId": teamId, + "projectId": projectId, + "resourceType": resourceType, + "resourceId": resourceId, + "action": action.value, + "priority": priority, + "enabled": enabled, + "conditions": conditions, + "config": config, + }; + } +} diff --git a/lib/src/models/waf_rule_list.dart b/lib/src/models/waf_rule_list.dart new file mode 100644 index 00000000..7ea2921c --- /dev/null +++ b/lib/src/models/waf_rule_list.dart @@ -0,0 +1,37 @@ +part of '../../models.dart'; + +/// WAF rule list +class WafRuleList implements Model { + /// Total number of rules that matched your query. + final int total; + + /// List of rules. + final List rules; + + WafRuleList({ + required this.total, + required this.rules, + }); + factory WafRuleList.fromMap( + Map map, + ) { + map = { + 'total': 0, + 'rules': [], + ...map, + }; + + return WafRuleList( + total: map['total'], + rules: List.from(map['rules'] ?? []), + ); + } + + @override + Map toMap() { + return { + "total": total, + "rules": rules, + }; + } +} diff --git a/lib/src/models/waf_rule_rate_limit.dart b/lib/src/models/waf_rule_rate_limit.dart new file mode 100644 index 00000000..0590e07f --- /dev/null +++ b/lib/src/models/waf_rule_rate_limit.dart @@ -0,0 +1,157 @@ +part of '../../models.dart'; + +/// WafRuleRateLimit +class WafRuleRateLimit implements Model { + /// Rule ID. + final String $id; + + /// WAF rule creation time in ISO 8601 format. + final String $createdAt; + + /// WAF rule last update time in ISO 8601 format. + final String $updatedAt; + + /// Human friendly rule name. + final String name; + + /// Optional description for the rule. + final String description; + + /// Team ID. + final String teamId; + + /// Project ID. + final String projectId; + + /// Resource type the rule is scoped to. + final String resourceType; + + /// Resource identifier. Empty for API-wide rules. + final String resourceId; + + /// Action performed when the rule matches. + final enums.WafRuleAction action; + + /// Evaluation priority. Lower values execute earlier. + final int priority; + + /// Whether the rule is active. + final bool enabled; + + /// List of conditions evaluated for this rule. + final List conditions; + + /// Action specific configuration. + final Map config; + + /// Maximum number of matching requests allowed for the given interval. + final int limit; + + /// Interval in seconds for the rate limit window. + final int interval; + + /// Rate limit key: `ip` limits per client IP, `userId` limits per authenticated user. + final String key; + + /// Rate limit strategy: `fixedWindow`, `slidingWindow`, or `tokenBucket`. + final String strategy; + + /// Maximum burst capacity in tokens, applied by the `tokenBucket` strategy. The sustained refill rate is `limit / interval`. Defaults to `limit`. + final int maxBucketSize; + + WafRuleRateLimit({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.description, + required this.teamId, + required this.projectId, + required this.resourceType, + required this.resourceId, + required this.action, + required this.priority, + required this.enabled, + required this.conditions, + required this.config, + required this.limit, + required this.interval, + required this.key, + required this.strategy, + required this.maxBucketSize, + }); + factory WafRuleRateLimit.fromMap( + Map map, + ) { + map = { + '\$id': "", + '\$createdAt': "", + '\$updatedAt': "", + 'name': "", + 'description': "", + 'teamId': "", + 'projectId': "", + 'resourceType': "api", + 'resourceId': "", + 'priority': 0, + 'enabled': true, + 'conditions': [], + 'config': {}, + 'limit': 100, + 'interval': 3600, + 'key': "ip", + 'strategy': "fixedWindow", + 'maxBucketSize': 0, + ...map, + }; + + return WafRuleRateLimit( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + description: map['description'].toString(), + teamId: map['teamId'].toString(), + projectId: map['projectId'].toString(), + resourceType: map['resourceType'].toString(), + resourceId: map['resourceId'].toString(), + action: enums.WafRuleAction.values.firstWhere( + (e) => e.value == map['action'], + ), + priority: map['priority'], + enabled: map['enabled'], + conditions: List.from(map['conditions'] ?? []), + config: map['config'], + limit: map['limit'], + interval: map['interval'], + key: map['key'].toString(), + strategy: map['strategy'].toString(), + maxBucketSize: map['maxBucketSize'], + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "description": description, + "teamId": teamId, + "projectId": projectId, + "resourceType": resourceType, + "resourceId": resourceId, + "action": action.value, + "priority": priority, + "enabled": enabled, + "conditions": conditions, + "config": config, + "limit": limit, + "interval": interval, + "key": key, + "strategy": strategy, + "maxBucketSize": maxBucketSize, + }; + } +} diff --git a/lib/src/models/waf_rule_redirect.dart b/lib/src/models/waf_rule_redirect.dart new file mode 100644 index 00000000..05171195 --- /dev/null +++ b/lib/src/models/waf_rule_redirect.dart @@ -0,0 +1,136 @@ +part of '../../models.dart'; + +/// WafRuleRedirect +class WafRuleRedirect implements Model { + /// Rule ID. + final String $id; + + /// WAF rule creation time in ISO 8601 format. + final String $createdAt; + + /// WAF rule last update time in ISO 8601 format. + final String $updatedAt; + + /// Human friendly rule name. + final String name; + + /// Optional description for the rule. + final String description; + + /// Team ID. + final String teamId; + + /// Project ID. + final String projectId; + + /// Resource type the rule is scoped to. + final String resourceType; + + /// Resource identifier. Empty for API-wide rules. + final String resourceId; + + /// Action performed when the rule matches. + final enums.WafRuleAction action; + + /// Evaluation priority. Lower values execute earlier. + final int priority; + + /// Whether the rule is active. + final bool enabled; + + /// List of conditions evaluated for this rule. + final List conditions; + + /// Action specific configuration. + final Map config; + + /// Target location for the redirect. + final String location; + + /// HTTP status code used for the redirect. + final int statusCode; + + WafRuleRedirect({ + required this.$id, + required this.$createdAt, + required this.$updatedAt, + required this.name, + required this.description, + required this.teamId, + required this.projectId, + required this.resourceType, + required this.resourceId, + required this.action, + required this.priority, + required this.enabled, + required this.conditions, + required this.config, + required this.location, + required this.statusCode, + }); + factory WafRuleRedirect.fromMap( + Map map, + ) { + map = { + '\$id': "", + '\$createdAt': "", + '\$updatedAt': "", + 'name': "", + 'description': "", + 'teamId': "", + 'projectId': "", + 'resourceType': "api", + 'resourceId': "", + 'priority': 0, + 'enabled': true, + 'conditions': [], + 'config': {}, + 'location': "/", + 'statusCode': 302, + ...map, + }; + + return WafRuleRedirect( + $id: map['\$id'].toString(), + $createdAt: map['\$createdAt'].toString(), + $updatedAt: map['\$updatedAt'].toString(), + name: map['name'].toString(), + description: map['description'].toString(), + teamId: map['teamId'].toString(), + projectId: map['projectId'].toString(), + resourceType: map['resourceType'].toString(), + resourceId: map['resourceId'].toString(), + action: enums.WafRuleAction.values.firstWhere( + (e) => e.value == map['action'], + ), + priority: map['priority'], + enabled: map['enabled'], + conditions: List.from(map['conditions'] ?? []), + config: map['config'], + location: map['location'].toString(), + statusCode: map['statusCode'], + ); + } + + @override + Map toMap() { + return { + "\$id": $id, + "\$createdAt": $createdAt, + "\$updatedAt": $updatedAt, + "name": name, + "description": description, + "teamId": teamId, + "projectId": projectId, + "resourceType": resourceType, + "resourceId": resourceId, + "action": action.value, + "priority": priority, + "enabled": enabled, + "conditions": conditions, + "config": config, + "location": location, + "statusCode": statusCode, + }; + } +} diff --git a/pubspec.yaml b/pubspec.yaml index ee4fe3d2..e7edc2d2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: dart_appwrite -version: 29.3.1 +version: 29.4.0 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 homepage: https://appwrite.io repository: https://github.com/appwrite/sdk-for-dart diff --git a/test/services/account_test.dart b/test/services/account_test.dart index 3fa2a655..63913093 100644 --- a/test/services/account_test.dart +++ b/test/services/account_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ @@ -966,6 +967,48 @@ void main() { expect(response, isA()); }); + test('test method createRecoveryOTP()', () async { + final Map data = { + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await account.createRecoveryOTP( + email: "email@example.com", + ); + expect(response, isA()); + }); + + test('test method updateRecoveryOTP()', () async { + final Map data = { + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateRecoveryOTP( + userId: "", + secret: "", + password: "password", + ); + expect(response, isA()); + }); + test('test method listSessions()', () async { final Map data = { 'total': 5, @@ -1075,6 +1118,50 @@ void main() { expect(response, isA()); }); + test('test method createIdTokenSession()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5bb8c16897e", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'provider': "email", + 'providerUid': "user@example.com", + 'providerAccessToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'providerAccessTokenExpiry': "2020-10-15T06:38:00.000+00:00", + 'providerRefreshToken': "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + 'ip': "127.0.0.1", + 'osCode': "Mac", + 'osName': "Mac", + 'osVersion': "Mac", + 'clientType': "browser", + 'clientCode': "CM", + 'clientName': "Chrome Mobile iOS", + 'clientVersion': "84.0", + 'clientEngine': "WebKit", + 'clientEngineVersion': "605.1.15", + 'deviceName': "smartphone", + 'deviceBrand': "Google", + 'deviceModel': "Nexus 5", + 'countryCode': "US", + 'countryName': "United States", + 'current': true, + 'factors': [], + 'secret': "5e5bb8c16897e", + 'mfaUpdatedAt': "2020-10-15T06:38:00.000+00:00", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await account.createIdTokenSession( + provider: enums.IdTokenProvider.apple, + idToken: "", + ); + expect(response, isA()); + }); + test('test method updateMagicURLSession()', () async { final Map data = { '\$id': "5e5ea5c16897e", @@ -1527,6 +1614,45 @@ void main() { expect(response, isA()); }); + test('test method createEmailVerificationOTP()', () async { + final Map data = { + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await account.createEmailVerificationOTP(); + expect(response, isA()); + }); + + test('test method updateEmailVerificationOTP()', () async { + final Map data = { + '\$id': "bb8ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + 'userId': "5e5ea5c168bb8", + 'secret': "", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'phrase': "Golden Fox", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await account.updateEmailVerificationOTP( + userId: "", + secret: "", + ); + expect(response, isA()); + }); + test('test method createPhoneVerification()', () async { final Map data = { '\$id': "bb8ea5c16897e", diff --git a/test/services/activities_test.dart b/test/services/activities_test.dart index c61ef129..6dba1f3d 100644 --- a/test/services/activities_test.dart +++ b/test/services/activities_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/advisor_test.dart b/test/services/advisor_test.dart index 6248d9d5..31ad2d31 100644 --- a/test/services/advisor_test.dart +++ b/test/services/advisor_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/apps_test.dart b/test/services/apps_test.dart index f2f6e3a2..4a602054 100644 --- a/test/services/apps_test.dart +++ b/test/services/apps_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/avatars_test.dart b/test/services/avatars_test.dart index 17076c9e..2d786220 100644 --- a/test/services/avatars_test.dart +++ b/test/services/avatars_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ @@ -152,6 +153,52 @@ void main() { expect(response, isA()); }); + test('test method updatePhoto()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "John Doe", + 'registration': "2020-10-15T06:38:00.000+00:00", + 'status': true, + 'labels': [], + 'passwordUpdate': "2020-10-15T06:38:00.000+00:00", + 'email': "john@appwrite.io", + 'phone': "+4930901820", + 'emailVerification': true, + 'phoneVerification': true, + 'mfa': true, + 'prefs': {}, + 'targets': [], + 'accessedAt': "2020-10-15T06:38:00.000+00:00", + }; + + when( + client.chunkedUpload( + path: argThat(isNotNull), + params: argThat(isNotNull), + paramName: argThat(isNotNull), + idParamName: argThat(isNotNull), + headers: argThat(isNotNull), + ), + ).thenAnswer((_) async => Response(data: data)); + + final response = await avatars.updatePhoto( + file: InputFile.fromPath(path: './image.png'), + ); + expect(response, isA()); + }); + + test('test method deletePhoto()', () async { + final data = ''; + + when( + client.call(HttpMethod.delete), + ).thenAnswer((_) async => Response(data: data)); + + final response = await avatars.deletePhoto(); + }); + test('test method getQR()', () async { final Uint8List data = Uint8List.fromList([]); diff --git a/test/services/backups_test.dart b/test/services/backups_test.dart index d180fa83..a1c2be6f 100644 --- a/test/services/backups_test.dart +++ b/test/services/backups_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/databases_test.dart b/test/services/databases_test.dart index 2775bf63..af54abe2 100644 --- a/test/services/databases_test.dart +++ b/test/services/databases_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/documents_db_test.dart b/test/services/documents_db_test.dart index 7764da1f..f40fac2a 100644 --- a/test/services/documents_db_test.dart +++ b/test/services/documents_db_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/domains_test.dart b/test/services/domains_test.dart new file mode 100644 index 00000000..77ed7adb --- /dev/null +++ b/test/services/domains_test.dart @@ -0,0 +1,1166 @@ +import 'package:test/test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; +import 'package:dart_appwrite/src/enums.dart'; +import 'package:dart_appwrite/src/response.dart'; +import 'dart:typed_data'; +import 'package:dart_appwrite/dart_appwrite.dart'; + +class MockClient extends Mock implements Client { + Map config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map params = const {}, + ResponseType? responseType, + }) async { + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); + } + + @override + Future webAuth(Uri? url) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); + } + + @override + Future chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + ResponseType? responseType, + HttpMethod method = HttpMethod.post, + }) async { + return super.noSuchMethod( + Invocation.method(#chunkedUpload, [ + path, + params, + paramName, + idParamName, + headers, + ]), + returnValue: Response(data: {}), + ); + } +} + +void main() { + group('Domains test', () { + late MockClient client; + late Domains domains; + + setUp(() { + client = MockClient(); + domains = Domains(client); + }); + + test('test method list()', () async { + final Map data = { + 'total': 5, + 'domains': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.list(); + expect(response, isA()); + }); + + test('test method create()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'domain': "example.com", + 'registrar': "appwrite", + 'nameservers': "Appwrite", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'renewal': "2020-10-15T06:38:00.000+00:00", + 'autoRenewal': true, + 'renewalPrice': 2599, + 'teamId': "5e5ea5c16897e", + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.create( + teamId: "", + domain: "example.com", + ); + expect(response, isA()); + }); + + test('test method getPrice()', () async { + final Map data = { + 'domain': "example.com", + 'tld': "com", + 'available': true, + 'periodYears': 1, + 'premium': true, + 'renewalPeriodYears': 1, + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.getPrice( + domain: "example.com", + ); + expect(response, isA()); + }); + + test('test method listPrices()', () async { + final Map data = { + 'total': 5, + 'prices': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.listPrices( + domains: [], + ); + expect(response, isA()); + }); + + test('test method get()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'domain': "example.com", + 'registrar': "appwrite", + 'nameservers': "Appwrite", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'renewal': "2020-10-15T06:38:00.000+00:00", + 'autoRenewal': true, + 'renewalPrice': 2599, + 'teamId': "5e5ea5c16897e", + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.get( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method delete()', () async { + final data = ''; + + when( + client.call(HttpMethod.delete), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.delete( + domainId: "", + ); + }); + + test('test method updateNameservers()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'domain': "example.com", + 'registrar': "appwrite", + 'nameservers': "Appwrite", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'renewal': "2020-10-15T06:38:00.000+00:00", + 'autoRenewal': true, + 'renewalPrice': 2599, + 'teamId': "5e5ea5c16897e", + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateNameservers( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method verifyNameservers()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'domain': "example.com", + 'registrar': "appwrite", + 'nameservers': "Appwrite", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'renewal': "2020-10-15T06:38:00.000+00:00", + 'autoRenewal': true, + 'renewalPrice': 2599, + 'teamId': "5e5ea5c16897e", + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.verifyNameservers( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method getPresetGoogleWorkspace()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.getPresetGoogleWorkspace( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method createPresetGoogleWorkspace()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createPresetGoogleWorkspace( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method getPresetICloud()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.getPresetICloud( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method createPresetICloud()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createPresetICloud( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method getPresetMailgun()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.getPresetMailgun( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method createPresetMailgun()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createPresetMailgun( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method getPresetOutlook()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.getPresetOutlook( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method createPresetOutlook()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createPresetOutlook( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method getPresetProtonMail()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.getPresetProtonMail( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method createPresetProtonMail()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createPresetProtonMail( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method getPresetZoho()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.getPresetZoho( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method createPresetZoho()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createPresetZoho( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method listRecords()', () async { + final Map data = { + 'total': 5, + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.listRecords( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method createRecordA()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createRecordA( + domainId: "", + name: "name", + value: "value", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method updateRecordA()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateRecordA( + domainId: "", + recordId: "", + name: "name", + value: "value", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method createRecordAAAA()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createRecordAAAA( + domainId: "", + name: "name", + value: "value", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method updateRecordAAAA()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateRecordAAAA( + domainId: "", + recordId: "", + name: "name", + value: "value", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method createRecordAlias()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createRecordAlias( + domainId: "", + name: "name", + value: "", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method updateRecordAlias()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateRecordAlias( + domainId: "", + recordId: "", + name: "name", + value: "", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method createRecordCAA()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createRecordCAA( + domainId: "", + name: "name", + value: "value", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method updateRecordCAA()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateRecordCAA( + domainId: "", + recordId: "", + name: "name", + value: "value", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method createRecordCNAME()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createRecordCNAME( + domainId: "", + name: "name", + value: "", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method updateRecordCNAME()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateRecordCNAME( + domainId: "", + recordId: "", + name: "name", + value: "", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method createRecordHTTPS()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createRecordHTTPS( + domainId: "", + name: "name", + value: "", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method updateRecordHTTPS()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateRecordHTTPS( + domainId: "", + recordId: "", + name: "name", + value: "", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method createRecordMX()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createRecordMX( + domainId: "", + name: "name", + value: "", + ttl: 1, + priority: 1, + ); + expect(response, isA()); + }); + + test('test method updateRecordMX()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateRecordMX( + domainId: "", + recordId: "", + name: "name", + value: "", + ttl: 1, + priority: 1, + ); + expect(response, isA()); + }); + + test('test method createRecordNS()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createRecordNS( + domainId: "", + name: "name", + value: "", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method updateRecordNS()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateRecordNS( + domainId: "", + recordId: "", + name: "name", + value: "", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method createRecordSRV()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createRecordSRV( + domainId: "", + name: "name", + value: "", + ttl: 1, + priority: 1, + weight: 1, + port: 1, + ); + expect(response, isA()); + }); + + test('test method updateRecordSRV()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateRecordSRV( + domainId: "", + recordId: "", + name: "name", + value: "", + ttl: 1, + priority: 1, + weight: 1, + port: 1, + ); + expect(response, isA()); + }); + + test('test method createRecordTXT()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.createRecordTXT( + domainId: "", + name: "name", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method updateRecordTXT()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateRecordTXT( + domainId: "", + recordId: "", + name: "name", + value: "", + ttl: 1, + ); + expect(response, isA()); + }); + + test('test method getRecord()', () async { + final Map data = { + '\$id': "5f40a6e10c65e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'type': "A", + 'name': "mail", + 'value': "192.0.2.1", + 'ttl': 86400, + 'priority': 10, + 'lock': true, + 'weight': 10, + 'port': 443, + 'comment': "Mail server record", + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.getRecord( + domainId: "", + recordId: "", + ); + expect(response, isA()); + }); + + test('test method deleteRecord()', () async { + final data = ''; + + when( + client.call(HttpMethod.delete), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.deleteRecord( + domainId: "", + recordId: "", + ); + }); + + test('test method updateTeam()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'domain': "example.com", + 'registrar': "appwrite", + 'nameservers': "Appwrite", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'renewal': "2020-10-15T06:38:00.000+00:00", + 'autoRenewal': true, + 'renewalPrice': 2599, + 'teamId': "5e5ea5c16897e", + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateTeam( + domainId: "", + teamId: "", + ); + expect(response, isA()); + }); + + test('test method getTransferStatus()', () async { + final Map data = { + 'status': "pending_registry", + 'reason': "Transfer in progress", + 'timestamp': "2020-10-15T06:38:00.000+00:00", + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.getTransferStatus( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method getZone()', () async { + final data = ''; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.getZone( + domainId: "", + ); + expect(response, isA()); + }); + + test('test method updateZone()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'domain': "example.com", + 'registrar': "appwrite", + 'nameservers': "Appwrite", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'renewal': "2020-10-15T06:38:00.000+00:00", + 'autoRenewal': true, + 'renewalPrice': 2599, + 'teamId': "5e5ea5c16897e", + 'dnsRecords': [], + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await domains.updateZone( + domainId: "", + content: "", + ); + expect(response, isA()); + }); + }); +} diff --git a/test/services/embeddings_test.dart b/test/services/embeddings_test.dart index 50f8a129..63c46270 100644 --- a/test/services/embeddings_test.dart +++ b/test/services/embeddings_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/functions_test.dart b/test/services/functions_test.dart index 81d9b526..449daf57 100644 --- a/test/services/functions_test.dart +++ b/test/services/functions_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/graphql_test.dart b/test/services/graphql_test.dart index 81ec4389..87541a13 100644 --- a/test/services/graphql_test.dart +++ b/test/services/graphql_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/locale_test.dart b/test/services/locale_test.dart index 55b281b3..9a0e2d11 100644 --- a/test/services/locale_test.dart +++ b/test/services/locale_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/messaging_test.dart b/test/services/messaging_test.dart index f1fa83dd..7b0fe6d6 100644 --- a/test/services/messaging_test.dart +++ b/test/services/messaging_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ @@ -431,6 +432,51 @@ void main() { expect(response, isA()); }); + test('test method createAppwriteProvider()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Mailgun", + 'provider': "mailgun", + 'enabled': true, + 'type': "sms", + 'credentials': {}, + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await messaging.createAppwriteProvider( + providerId: "", + name: "", + ); + expect(response, isA()); + }); + + test('test method updateAppwriteProvider()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Mailgun", + 'provider': "mailgun", + 'enabled': true, + 'type': "sms", + 'credentials': {}, + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await messaging.updateAppwriteProvider( + providerId: "", + ); + expect(response, isA()); + }); + test('test method createFcmProvider()', () async { final Map data = { '\$id': "5e5ea5c16897e", diff --git a/test/services/mongo_test.dart b/test/services/mongo_test.dart index 6f7835f1..ada0ee16 100644 --- a/test/services/mongo_test.dart +++ b/test/services/mongo_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/mysql_test.dart b/test/services/mysql_test.dart index 71857ed1..33a9c00e 100644 --- a/test/services/mysql_test.dart +++ b/test/services/mysql_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/oauth2_test.dart b/test/services/oauth2_test.dart index 48c98b9a..c671bdd0 100644 --- a/test/services/oauth2_test.dart +++ b/test/services/oauth2_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ @@ -182,6 +183,21 @@ void main() { expect(response, isA()); }); + test('test method introspect()', () async { + final Map data = { + 'active': true, + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await oauth2.introspect( + token: "", + ); + expect(response, isA()); + }); + test('test method listOrganizations()', () async { final Map data = { 'total': 5, diff --git a/test/services/organization_test.dart b/test/services/organization_test.dart index a5c797d8..dd49b637 100644 --- a/test/services/organization_test.dart +++ b/test/services/organization_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ @@ -871,5 +872,109 @@ void main() { projectId: "", ); }); + + test('test method listProjectKeys()', () async { + final Map data = { + 'total': 5, + 'keys': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await organization.listProjectKeys( + projectId: "", + ); + expect(response, isA()); + }); + + test('test method createEphemeralProjectKey()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "My API Key", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'scopes': [], + 'secret': "919c2d18fb5d4...a2ae413da83346ad2", + 'accessedAt': "2020-10-15T06:38:00.000+00:00", + 'sdks': [], + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await organization.createEphemeralProjectKey( + projectId: "", + scopes: [enums.ProjectKeyScopes.usersRead], + duration: 1, + ); + expect(response, isA()); + }); + + test('test method getProjectKey()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "My API Key", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'scopes': [], + 'secret': "919c2d18fb5d4...a2ae413da83346ad2", + 'accessedAt': "2020-10-15T06:38:00.000+00:00", + 'sdks': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await organization.getProjectKey( + projectId: "", + keyId: "", + ); + expect(response, isA()); + }); + + test('test method updateProjectKey()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "My API Key", + 'expire': "2020-10-15T06:38:00.000+00:00", + 'scopes': [], + 'secret': "919c2d18fb5d4...a2ae413da83346ad2", + 'accessedAt': "2020-10-15T06:38:00.000+00:00", + 'sdks': [], + }; + + when( + client.call(HttpMethod.put), + ).thenAnswer((_) async => Response(data: data)); + + final response = await organization.updateProjectKey( + projectId: "", + keyId: "", + name: "", + scopes: [enums.ProjectKeyScopes.usersRead], + ); + expect(response, isA()); + }); + + test('test method deleteProjectKey()', () async { + final data = ''; + + when( + client.call(HttpMethod.delete), + ).thenAnswer((_) async => Response(data: data)); + + final response = await organization.deleteProjectKey( + projectId: "", + keyId: "", + ); + }); }); } diff --git a/test/services/postgresql_test.dart b/test/services/postgresql_test.dart index 9aa06c77..d28fd265 100644 --- a/test/services/postgresql_test.dart +++ b/test/services/postgresql_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/presences_test.dart b/test/services/presences_test.dart index 2f9e64a4..2ebc16cb 100644 --- a/test/services/presences_test.dart +++ b/test/services/presences_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/project_test.dart b/test/services/project_test.dart index 88b18170..6ac9abb7 100644 --- a/test/services/project_test.dart +++ b/test/services/project_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ @@ -156,6 +157,157 @@ void main() { expect(response, isA()); }); + test('test method listEnvironments()', () async { + final Map data = { + 'total': 5, + 'projects': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await project.listEnvironments(); + expect(response, isA()); + }); + + test('test method createEnvironment()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "New Project", + 'teamId': "1592981250", + 'region': "fra", + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': "John Appwrite", + 'smtpSenderEmail': "john@appwrite.io", + 'smtpReplyToName': "Support Team", + 'smtpReplyToEmail': "support@appwrite.io", + 'smtpHost': "mail.appwrite.io", + 'smtpPort': 25, + 'smtpUsername': "emailuser", + 'smtpPassword': "smtp-password", + 'smtpSecure': "tls", + 'pingCount': 1, + 'pingedAt': "2020-10-15T06:38:00.000+00:00", + 'labels': [], + 'status': "active", + 'onboarding': {}, + 'authMethods': [], + 'services': [], + 'protocols': [], + 'blocks': [], + 'consoleAccessedAt': "2020-10-15T06:38:00.000+00:00", + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await project.createEnvironment( + environmentId: "", + name: "", + ); + expect(response, isA()); + }); + + test('test method getEnvironment()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "New Project", + 'teamId': "1592981250", + 'region': "fra", + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': "John Appwrite", + 'smtpSenderEmail': "john@appwrite.io", + 'smtpReplyToName': "Support Team", + 'smtpReplyToEmail': "support@appwrite.io", + 'smtpHost': "mail.appwrite.io", + 'smtpPort': 25, + 'smtpUsername': "emailuser", + 'smtpPassword': "smtp-password", + 'smtpSecure': "tls", + 'pingCount': 1, + 'pingedAt': "2020-10-15T06:38:00.000+00:00", + 'labels': [], + 'status': "active", + 'onboarding': {}, + 'authMethods': [], + 'services': [], + 'protocols': [], + 'blocks': [], + 'consoleAccessedAt': "2020-10-15T06:38:00.000+00:00", + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await project.getEnvironment( + environmentId: "", + ); + expect(response, isA()); + }); + + test('test method updateEnvironment()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "New Project", + 'teamId': "1592981250", + 'region': "fra", + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': "John Appwrite", + 'smtpSenderEmail': "john@appwrite.io", + 'smtpReplyToName': "Support Team", + 'smtpReplyToEmail': "support@appwrite.io", + 'smtpHost': "mail.appwrite.io", + 'smtpPort': 25, + 'smtpUsername': "emailuser", + 'smtpPassword': "smtp-password", + 'smtpSecure': "tls", + 'pingCount': 1, + 'pingedAt': "2020-10-15T06:38:00.000+00:00", + 'labels': [], + 'status': "active", + 'onboarding': {}, + 'authMethods': [], + 'services': [], + 'protocols': [], + 'blocks': [], + 'consoleAccessedAt': "2020-10-15T06:38:00.000+00:00", + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await project.updateEnvironment( + environmentId: "", + name: "", + ); + expect(response, isA()); + }); + + test('test method deleteEnvironment()', () async { + final data = ''; + + when( + client.call(HttpMethod.delete), + ).thenAnswer((_) async => Response(data: data)); + + final response = await project.deleteEnvironment( + environmentId: "", + ); + }); + test('test method listKeys()', () async { final Map data = { 'total': 5, @@ -803,6 +955,23 @@ void main() { expect(response, isA()); }); + test('test method updateOAuth2Kakao()', () async { + final Map data = { + '\$id': "github", + 'enabled': true, + 'clientId': "839ff5000000000000000000013206de", + 'clientSecret': "jLNVOK00000000000000000000yJebea", + 'prompt': [], + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await project.updateOAuth2Kakao(); + expect(response, isA()); + }); + test('test method updateOAuth2Keycloak()', () async { final Map data = { '\$id': "github", @@ -1065,6 +1234,22 @@ void main() { expect(response, isA()); }); + test('test method updateOAuth2TikTok()', () async { + final Map data = { + '\$id': "github", + 'enabled': true, + 'clientId': "awz000000000tyw0", + 'clientSecret': "6wXewM00000000000000000000yXnite", + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await project.updateOAuth2TikTok(); + expect(response, isA()); + }); + test('test method updateOAuth2Tradeshift()', () async { final Map data = { '\$id': "github", @@ -1113,6 +1298,24 @@ void main() { expect(response, isA()); }); + test('test method updateOAuth2Webflow()', () async { + final Map data = { + '\$id': "github", + 'enabled': true, + 'clientId': + "8bb20000000000000000000000000000000000000000000000000000000040dd", + 'clientSecret': + "59bf00000000000000000000000000000000000000000000000000000000fe59", + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await project.updateOAuth2Webflow(); + expect(response, isA()); + }); + test('test method updateOAuth2WordPress()', () async { final Map data = { '\$id': "github", @@ -1214,10 +1417,10 @@ void main() { test('test method getOAuth2Provider()', () async { final Map data = { 'enabled': true, - 'applicationId': "00001111-aaaa-2222-bbbb-3333cccc4444", - 'applicationSecret': "A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u", - 'tenant': "common", - '\$id': "microsoft", + 'clientId': "839ff5000000000000000000013206de", + 'clientSecret': "jLNVOK00000000000000000000yJebea", + 'prompt': [], + '\$id': "kakao", }; when( @@ -1227,7 +1430,7 @@ void main() { final response = await project.getOAuth2Provider( providerId: enums.ProjectOAuthProviderId.amazon, ); - expect(response, isA()); + expect(response, isA()); }); test('test method listPlatforms()', () async { @@ -1916,6 +2119,84 @@ void main() { expect(response, isA()); }); + test('test method updatePasswordPwnedPolicy()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "New Project", + 'teamId': "1592981250", + 'region': "fra", + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': "John Appwrite", + 'smtpSenderEmail': "john@appwrite.io", + 'smtpReplyToName': "Support Team", + 'smtpReplyToEmail': "support@appwrite.io", + 'smtpHost': "mail.appwrite.io", + 'smtpPort': 25, + 'smtpUsername': "emailuser", + 'smtpPassword': "smtp-password", + 'smtpSecure': "tls", + 'pingCount': 1, + 'pingedAt': "2020-10-15T06:38:00.000+00:00", + 'labels': [], + 'status': "active", + 'onboarding': {}, + 'authMethods': [], + 'services': [], + 'protocols': [], + 'blocks': [], + 'consoleAccessedAt': "2020-10-15T06:38:00.000+00:00", + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await project.updatePasswordPwnedPolicy(); + expect(response, isA()); + }); + + test('test method updatePasswordRotationPolicy()', () async { + final Map data = { + '\$id': "5e5ea5c16897e", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "New Project", + 'teamId': "1592981250", + 'region': "fra", + 'devKeys': [], + 'smtpEnabled': true, + 'smtpSenderName': "John Appwrite", + 'smtpSenderEmail': "john@appwrite.io", + 'smtpReplyToName': "Support Team", + 'smtpReplyToEmail': "support@appwrite.io", + 'smtpHost': "mail.appwrite.io", + 'smtpPort': 25, + 'smtpUsername': "emailuser", + 'smtpPassword': "smtp-password", + 'smtpSecure': "tls", + 'pingCount': 1, + 'pingedAt': "2020-10-15T06:38:00.000+00:00", + 'labels': [], + 'status': "active", + 'onboarding': {}, + 'authMethods': [], + 'services': [], + 'protocols': [], + 'blocks': [], + 'consoleAccessedAt': "2020-10-15T06:38:00.000+00:00", + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await project.updatePasswordRotationPolicy(); + expect(response, isA()); + }); + test('test method updatePasswordStrengthPolicy()', () async { final Map data = { '\$id': "password-dictionary", diff --git a/test/services/proxy_test.dart b/test/services/proxy_test.dart index ce8e0570..10f68fed 100644 --- a/test/services/proxy_test.dart +++ b/test/services/proxy_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/sites_test.dart b/test/services/sites_test.dart index 2d7c6523..98e12124 100644 --- a/test/services/sites_test.dart +++ b/test/services/sites_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/storage_test.dart b/test/services/storage_test.dart index 152c9907..d072e110 100644 --- a/test/services/storage_test.dart +++ b/test/services/storage_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/tables_db_test.dart b/test/services/tables_db_test.dart index 508b3e84..6f71c2f1 100644 --- a/test/services/tables_db_test.dart +++ b/test/services/tables_db_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/teams_test.dart b/test/services/teams_test.dart index 186641c3..8969893c 100644 --- a/test/services/teams_test.dart +++ b/test/services/teams_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/tokens_test.dart b/test/services/tokens_test.dart index bbf1f5a6..87b91ae9 100644 --- a/test/services/tokens_test.dart +++ b/test/services/tokens_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/users_test.dart b/test/services/users_test.dart index bda46a16..ecac64a0 100644 --- a/test/services/users_test.dart +++ b/test/services/users_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/vectors_db_test.dart b/test/services/vectors_db_test.dart index 4cf1a453..4096266f 100644 --- a/test/services/vectors_db_test.dart +++ b/test/services/vectors_db_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/services/waf_test.dart b/test/services/waf_test.dart new file mode 100644 index 00000000..7b3907cd --- /dev/null +++ b/test/services/waf_test.dart @@ -0,0 +1,440 @@ +import 'package:test/test.dart'; +import 'package:mockito/mockito.dart'; +import 'package:dart_appwrite/models.dart' as models; +import 'package:dart_appwrite/enums.dart' as enums; +import 'package:dart_appwrite/src/enums.dart'; +import 'package:dart_appwrite/src/response.dart'; +import 'dart:typed_data'; +import 'package:dart_appwrite/dart_appwrite.dart'; + +class MockClient extends Mock implements Client { + Map config = {'project': 'testproject'}; + String endPoint = 'https://localhost/v1'; + + @override + Future call( + HttpMethod? method, { + String path = '', + Map headers = const {}, + Map params = const {}, + ResponseType? responseType, + }) async { + return super.noSuchMethod( + Invocation.method(#call, [method]), + returnValue: Response(), + ); + } + + @override + Future webAuth(Uri? url) async { + return super.noSuchMethod( + Invocation.method(#webAuth, [url]), + returnValue: 'done', + ); + } + + @override + Future chunkedUpload({ + String? path, + Map? params, + String? paramName, + String? idParamName, + Map? headers, + Function(UploadProgress)? onProgress, + ResponseType? responseType, + HttpMethod method = HttpMethod.post, + }) async { + return super.noSuchMethod( + Invocation.method(#chunkedUpload, [ + path, + params, + paramName, + idParamName, + headers, + ]), + returnValue: Response(data: {}), + ); + } +} + +void main() { + group('Waf test', () { + late MockClient client; + late Waf waf; + + setUp(() { + client = MockClient(); + waf = Waf(client); + }); + + test('test method listRules()', () async { + final Map data = { + 'total': 5, + 'rules': [], + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.listRules(); + expect(response, isA()); + }); + + test('test method createBypassRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'action': "deny", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.createBypassRule( + ruleId: "", + resourceType: "api", + name: "", + ); + expect(response, isA()); + }); + + test('test method updateBypassRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'action': "deny", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.updateBypassRule( + ruleId: "", + ); + expect(response, isA()); + }); + + test('test method createChallengeRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'action': "deny", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + 'challengeType': "compute", + 'difficulty': 3, + 'ttl': 1800, + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.createChallengeRule( + ruleId: "", + resourceType: "api", + name: "", + ); + expect(response, isA()); + }); + + test('test method updateChallengeRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'action': "deny", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + 'challengeType': "compute", + 'difficulty': 3, + 'ttl': 1800, + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.updateChallengeRule( + ruleId: "", + ); + expect(response, isA()); + }); + + test('test method createDenyRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'action': "deny", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.createDenyRule( + ruleId: "", + resourceType: "api", + name: "", + ); + expect(response, isA()); + }); + + test('test method updateDenyRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'action': "deny", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.updateDenyRule( + ruleId: "", + ); + expect(response, isA()); + }); + + test('test method createRateLimitRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'action': "deny", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + 'limit': 1000, + 'interval': 60, + 'key': "userId", + 'strategy': "slidingWindow", + 'maxBucketSize': 200, + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.createRateLimitRule( + ruleId: "", + resourceType: "api", + name: "", + limit: 1, + interval: 1, + ); + expect(response, isA()); + }); + + test('test method updateRateLimitRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'action': "deny", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + 'limit': 1000, + 'interval': 60, + 'key': "userId", + 'strategy': "slidingWindow", + 'maxBucketSize': 200, + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.updateRateLimitRule( + ruleId: "", + ); + expect(response, isA()); + }); + + test('test method createRedirectRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'action': "deny", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + 'location': "/maintenance", + 'statusCode': 301, + }; + + when( + client.call(HttpMethod.post), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.createRedirectRule( + ruleId: "", + resourceType: "api", + name: "", + location: "", + statusCode: 1, + ); + expect(response, isA()); + }); + + test('test method updateRedirectRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'action': "deny", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + 'location': "/maintenance", + 'statusCode': 301, + }; + + when( + client.call(HttpMethod.patch), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.updateRedirectRule( + ruleId: "", + ); + expect(response, isA()); + }); + + test('test method getRule()', () async { + final Map data = { + '\$id': "wafRule1", + '\$createdAt': "2020-10-15T06:38:00.000+00:00", + '\$updatedAt': "2020-10-15T06:38:00.000+00:00", + 'name': "Block anonymous POST traffic", + 'description': "Blocks anonymous POST calls to /v1/graphql", + 'teamId': "5e5ea5c16897e", + 'projectId': "cloudConsole", + 'resourceType': "functions", + 'resourceId': "functionId", + 'priority': 100, + 'enabled': true, + 'conditions': [], + 'config': {}, + 'location': "/maintenance", + 'statusCode': 301, + 'action': "redirect", + }; + + when( + client.call(HttpMethod.get), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.getRule( + ruleId: "", + ); + expect(response, isA()); + }); + + test('test method deleteRule()', () async { + final data = ''; + + when( + client.call(HttpMethod.delete), + ).thenAnswer((_) async => Response(data: data)); + + final response = await waf.deleteRule( + ruleId: "", + ); + }); + }); +} diff --git a/test/services/webhooks_test.dart b/test/services/webhooks_test.dart index 127d9caa..8c8f8e3e 100644 --- a/test/services/webhooks_test.dart +++ b/test/services/webhooks_test.dart @@ -41,6 +41,7 @@ class MockClient extends Mock implements Client { String? idParamName, Map? headers, Function(UploadProgress)? onProgress, + HttpMethod method = HttpMethod.post, }) async { return super.noSuchMethod( Invocation.method(#chunkedUpload, [ diff --git a/test/src/models/account_test.dart b/test/src/models/account_test.dart new file mode 100644 index 00000000..c4cb55f8 --- /dev/null +++ b/test/src/models/account_test.dart @@ -0,0 +1,46 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Account', () { + test('model', () { + final model = Account( + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + name: "John Doe", + registration: "2020-10-15T06:38:00.000+00:00", + status: true, + labels: [], + passwordUpdate: "2020-10-15T06:38:00.000+00:00", + email: "john@appwrite.io", + phone: "+4930901820", + emailVerification: true, + phoneVerification: true, + mfa: true, + prefs: Preferences(data: {}), + targets: [], + accessedAt: "2020-10-15T06:38:00.000+00:00", + ); + + final map = model.toMap(); + final result = Account.fromMap(map); + + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.name, "John Doe"); + expect(result.registration, "2020-10-15T06:38:00.000+00:00"); + expect(result.status, true); + expect(result.labels, []); + expect(result.passwordUpdate, "2020-10-15T06:38:00.000+00:00"); + expect(result.email, "john@appwrite.io"); + expect(result.phone, "+4930901820"); + expect(result.emailVerification, true); + expect(result.phoneVerification, true); + expect(result.mfa, true); + expect(result.targets, []); + expect(result.accessedAt, "2020-10-15T06:38:00.000+00:00"); + }); + }); +} diff --git a/test/src/models/dns_record_test.dart b/test/src/models/dns_record_test.dart new file mode 100644 index 00000000..ef55723f --- /dev/null +++ b/test/src/models/dns_record_test.dart @@ -0,0 +1,39 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('DnsRecord', () { + test('model', () { + final model = DnsRecord( + $id: "5f40a6e10c65e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + type: "A", + name: "mail", + value: "192.0.2.1", + ttl: 86400, + priority: 10, + lock: true, + weight: 10, + port: 443, + comment: "Mail server record", + ); + + final map = model.toMap(); + final result = DnsRecord.fromMap(map); + + expect(result.$id, "5f40a6e10c65e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.type, "A"); + expect(result.name, "mail"); + expect(result.value, "192.0.2.1"); + expect(result.ttl, 86400); + expect(result.priority, 10); + expect(result.lock, true); + expect(result.weight, 10); + expect(result.port, 443); + expect(result.comment, "Mail server record"); + }); + }); +} diff --git a/test/src/models/dns_records_list_test.dart b/test/src/models/dns_records_list_test.dart new file mode 100644 index 00000000..9a43da64 --- /dev/null +++ b/test/src/models/dns_records_list_test.dart @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('DnsRecordsList', () { + test('model', () { + final model = DnsRecordsList( + total: 5, + dnsRecords: [], + ); + + final map = model.toMap(); + final result = DnsRecordsList.fromMap(map); + + expect(result.total, 5); + expect(result.dnsRecords, []); + }); + }); +} diff --git a/test/src/models/domain_price_test.dart b/test/src/models/domain_price_test.dart new file mode 100644 index 00000000..88d37fbb --- /dev/null +++ b/test/src/models/domain_price_test.dart @@ -0,0 +1,27 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('DomainPrice', () { + test('model', () { + final model = DomainPrice( + domain: "example.com", + tld: "com", + available: true, + periodYears: 1, + premium: true, + renewalPeriodYears: 1, + ); + + final map = model.toMap(); + final result = DomainPrice.fromMap(map); + + expect(result.domain, "example.com"); + expect(result.tld, "com"); + expect(result.available, true); + expect(result.periodYears, 1); + expect(result.premium, true); + expect(result.renewalPeriodYears, 1); + }); + }); +} diff --git a/test/src/models/domain_prices_list_test.dart b/test/src/models/domain_prices_list_test.dart new file mode 100644 index 00000000..2fdfc6c3 --- /dev/null +++ b/test/src/models/domain_prices_list_test.dart @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('DomainPricesList', () { + test('model', () { + final model = DomainPricesList( + total: 5, + prices: [], + ); + + final map = model.toMap(); + final result = DomainPricesList.fromMap(map); + + expect(result.total, 5); + expect(result.prices, []); + }); + }); +} diff --git a/test/src/models/domain_test.dart b/test/src/models/domain_test.dart new file mode 100644 index 00000000..f72c2fce --- /dev/null +++ b/test/src/models/domain_test.dart @@ -0,0 +1,40 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:dart_appwrite/enums.dart'; +import 'package:test/test.dart'; + +void main() { + group('Domain', () { + test('model', () { + final model = Domain( + $id: "5e5ea5c16897e", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + domain: "example.com", + registrar: "appwrite", + nameservers: "Appwrite", + expire: "2020-10-15T06:38:00.000+00:00", + renewal: "2020-10-15T06:38:00.000+00:00", + autoRenewal: true, + renewalPrice: 2599, + teamId: "5e5ea5c16897e", + dnsRecords: [], + ); + + final map = model.toMap(); + final result = Domain.fromMap(map); + + expect(result.$id, "5e5ea5c16897e"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.domain, "example.com"); + expect(result.registrar, "appwrite"); + expect(result.nameservers, "Appwrite"); + expect(result.expire, "2020-10-15T06:38:00.000+00:00"); + expect(result.renewal, "2020-10-15T06:38:00.000+00:00"); + expect(result.autoRenewal, true); + expect(result.renewalPrice, 2599); + expect(result.teamId, "5e5ea5c16897e"); + expect(result.dnsRecords, []); + }); + }); +} diff --git a/test/src/models/domain_transfer_status_test.dart b/test/src/models/domain_transfer_status_test.dart new file mode 100644 index 00000000..92cff08a --- /dev/null +++ b/test/src/models/domain_transfer_status_test.dart @@ -0,0 +1,22 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:dart_appwrite/enums.dart'; +import 'package:test/test.dart'; + +void main() { + group('DomainTransferStatus', () { + test('model', () { + final model = DomainTransferStatus( + status: DomainTransferStatusEnum.transferrable, + reason: "Transfer in progress", + timestamp: "2020-10-15T06:38:00.000+00:00", + ); + + final map = model.toMap(); + final result = DomainTransferStatus.fromMap(map); + + expect(result.status, DomainTransferStatusEnum.transferrable); + expect(result.reason, "Transfer in progress"); + expect(result.timestamp, "2020-10-15T06:38:00.000+00:00"); + }); + }); +} diff --git a/test/src/models/domains_list_test.dart b/test/src/models/domains_list_test.dart new file mode 100644 index 00000000..a5b6d582 --- /dev/null +++ b/test/src/models/domains_list_test.dart @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('DomainsList', () { + test('model', () { + final model = DomainsList( + total: 5, + domains: [], + ); + + final map = model.toMap(); + final result = DomainsList.fromMap(map); + + expect(result.total, 5); + expect(result.domains, []); + }); + }); +} diff --git a/test/src/models/o_auth2_kakao_test.dart b/test/src/models/o_auth2_kakao_test.dart new file mode 100644 index 00000000..50507a5b --- /dev/null +++ b/test/src/models/o_auth2_kakao_test.dart @@ -0,0 +1,25 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('OAuth2Kakao', () { + test('model', () { + final model = OAuth2Kakao( + $id: "github", + enabled: true, + clientId: "839ff5000000000000000000013206de", + clientSecret: "jLNVOK00000000000000000000yJebea", + prompt: [], + ); + + final map = model.toMap(); + final result = OAuth2Kakao.fromMap(map); + + expect(result.$id, "github"); + expect(result.enabled, true); + expect(result.clientId, "839ff5000000000000000000013206de"); + expect(result.clientSecret, "jLNVOK00000000000000000000yJebea"); + expect(result.prompt, []); + }); + }); +} diff --git a/test/src/models/o_auth2_tik_tok_test.dart b/test/src/models/o_auth2_tik_tok_test.dart new file mode 100644 index 00000000..b30faaaf --- /dev/null +++ b/test/src/models/o_auth2_tik_tok_test.dart @@ -0,0 +1,23 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('OAuth2TikTok', () { + test('model', () { + final model = OAuth2TikTok( + $id: "github", + enabled: true, + clientId: "awz000000000tyw0", + clientSecret: "6wXewM00000000000000000000yXnite", + ); + + final map = model.toMap(); + final result = OAuth2TikTok.fromMap(map); + + expect(result.$id, "github"); + expect(result.enabled, true); + expect(result.clientId, "awz000000000tyw0"); + expect(result.clientSecret, "6wXewM00000000000000000000yXnite"); + }); + }); +} diff --git a/test/src/models/o_auth2_webflow_test.dart b/test/src/models/o_auth2_webflow_test.dart new file mode 100644 index 00000000..5d4d72d8 --- /dev/null +++ b/test/src/models/o_auth2_webflow_test.dart @@ -0,0 +1,31 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('OAuth2Webflow', () { + test('model', () { + final model = OAuth2Webflow( + $id: "github", + enabled: true, + clientId: + "8bb20000000000000000000000000000000000000000000000000000000040dd", + clientSecret: + "59bf00000000000000000000000000000000000000000000000000000000fe59", + ); + + final map = model.toMap(); + final result = OAuth2Webflow.fromMap(map); + + expect(result.$id, "github"); + expect(result.enabled, true); + expect( + result.clientId, + "8bb20000000000000000000000000000000000000000000000000000000040dd", + ); + expect( + result.clientSecret, + "59bf00000000000000000000000000000000000000000000000000000000fe59", + ); + }); + }); +} diff --git a/test/src/models/oauth2_introspection_test.dart b/test/src/models/oauth2_introspection_test.dart new file mode 100644 index 00000000..542797b4 --- /dev/null +++ b/test/src/models/oauth2_introspection_test.dart @@ -0,0 +1,17 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('Oauth2Introspection', () { + test('model', () { + final model = Oauth2Introspection( + active: true, + ); + + final map = model.toMap(); + final result = Oauth2Introspection.fromMap(map); + + expect(result.active, true); + }); + }); +} diff --git a/test/src/models/policy_password_pwned_test.dart b/test/src/models/policy_password_pwned_test.dart new file mode 100644 index 00000000..4bf24d0e --- /dev/null +++ b/test/src/models/policy_password_pwned_test.dart @@ -0,0 +1,23 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('PolicyPasswordPwned', () { + test('model', () { + final model = PolicyPasswordPwned( + $id: "password-dictionary", + enabled: true, + sessions: true, + users: true, + ); + + final map = model.toMap(); + final result = PolicyPasswordPwned.fromMap(map); + + expect(result.$id, "password-dictionary"); + expect(result.enabled, true); + expect(result.sessions, true); + expect(result.users, true); + }); + }); +} diff --git a/test/src/models/policy_password_rotation_test.dart b/test/src/models/policy_password_rotation_test.dart new file mode 100644 index 00000000..d4e6c007 --- /dev/null +++ b/test/src/models/policy_password_rotation_test.dart @@ -0,0 +1,21 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('PolicyPasswordRotation', () { + test('model', () { + final model = PolicyPasswordRotation( + $id: "password-dictionary", + enabled: true, + maxAge: 31536000, + ); + + final map = model.toMap(); + final result = PolicyPasswordRotation.fromMap(map); + + expect(result.$id, "password-dictionary"); + expect(result.enabled, true); + expect(result.maxAge, 31536000); + }); + }); +} diff --git a/test/src/models/waf_rule_bypass_test.dart b/test/src/models/waf_rule_bypass_test.dart new file mode 100644 index 00000000..0144a6ce --- /dev/null +++ b/test/src/models/waf_rule_bypass_test.dart @@ -0,0 +1,44 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:dart_appwrite/enums.dart'; +import 'package:test/test.dart'; + +void main() { + group('WafRuleBypass', () { + test('model', () { + final model = WafRuleBypass( + $id: "wafRule1", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + name: "Block anonymous POST traffic", + description: "Blocks anonymous POST calls to /v1/graphql", + teamId: "5e5ea5c16897e", + projectId: "cloudConsole", + resourceType: "functions", + resourceId: "functionId", + action: WafRuleAction.bypass, + priority: 100, + enabled: true, + conditions: [], + config: {}, + ); + + final map = model.toMap(); + final result = WafRuleBypass.fromMap(map); + + expect(result.$id, "wafRule1"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.name, "Block anonymous POST traffic"); + expect(result.description, "Blocks anonymous POST calls to /v1/graphql"); + expect(result.teamId, "5e5ea5c16897e"); + expect(result.projectId, "cloudConsole"); + expect(result.resourceType, "functions"); + expect(result.resourceId, "functionId"); + expect(result.action, WafRuleAction.bypass); + expect(result.priority, 100); + expect(result.enabled, true); + expect(result.conditions, []); + expect(result.config, {}); + }); + }); +} diff --git a/test/src/models/waf_rule_challenge_test.dart b/test/src/models/waf_rule_challenge_test.dart new file mode 100644 index 00000000..b35dfa3a --- /dev/null +++ b/test/src/models/waf_rule_challenge_test.dart @@ -0,0 +1,50 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:dart_appwrite/enums.dart'; +import 'package:test/test.dart'; + +void main() { + group('WafRuleChallenge', () { + test('model', () { + final model = WafRuleChallenge( + $id: "wafRule1", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + name: "Block anonymous POST traffic", + description: "Blocks anonymous POST calls to /v1/graphql", + teamId: "5e5ea5c16897e", + projectId: "cloudConsole", + resourceType: "functions", + resourceId: "functionId", + action: WafRuleAction.bypass, + priority: 100, + enabled: true, + conditions: [], + config: {}, + challengeType: "compute", + difficulty: 3, + ttl: 1800, + ); + + final map = model.toMap(); + final result = WafRuleChallenge.fromMap(map); + + expect(result.$id, "wafRule1"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.name, "Block anonymous POST traffic"); + expect(result.description, "Blocks anonymous POST calls to /v1/graphql"); + expect(result.teamId, "5e5ea5c16897e"); + expect(result.projectId, "cloudConsole"); + expect(result.resourceType, "functions"); + expect(result.resourceId, "functionId"); + expect(result.action, WafRuleAction.bypass); + expect(result.priority, 100); + expect(result.enabled, true); + expect(result.conditions, []); + expect(result.config, {}); + expect(result.challengeType, "compute"); + expect(result.difficulty, 3); + expect(result.ttl, 1800); + }); + }); +} diff --git a/test/src/models/waf_rule_deny_test.dart b/test/src/models/waf_rule_deny_test.dart new file mode 100644 index 00000000..f80ffb26 --- /dev/null +++ b/test/src/models/waf_rule_deny_test.dart @@ -0,0 +1,44 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:dart_appwrite/enums.dart'; +import 'package:test/test.dart'; + +void main() { + group('WafRuleDeny', () { + test('model', () { + final model = WafRuleDeny( + $id: "wafRule1", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + name: "Block anonymous POST traffic", + description: "Blocks anonymous POST calls to /v1/graphql", + teamId: "5e5ea5c16897e", + projectId: "cloudConsole", + resourceType: "functions", + resourceId: "functionId", + action: WafRuleAction.bypass, + priority: 100, + enabled: true, + conditions: [], + config: {}, + ); + + final map = model.toMap(); + final result = WafRuleDeny.fromMap(map); + + expect(result.$id, "wafRule1"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.name, "Block anonymous POST traffic"); + expect(result.description, "Blocks anonymous POST calls to /v1/graphql"); + expect(result.teamId, "5e5ea5c16897e"); + expect(result.projectId, "cloudConsole"); + expect(result.resourceType, "functions"); + expect(result.resourceId, "functionId"); + expect(result.action, WafRuleAction.bypass); + expect(result.priority, 100); + expect(result.enabled, true); + expect(result.conditions, []); + expect(result.config, {}); + }); + }); +} diff --git a/test/src/models/waf_rule_list_test.dart b/test/src/models/waf_rule_list_test.dart new file mode 100644 index 00000000..13eeeba1 --- /dev/null +++ b/test/src/models/waf_rule_list_test.dart @@ -0,0 +1,19 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:test/test.dart'; + +void main() { + group('WafRuleList', () { + test('model', () { + final model = WafRuleList( + total: 5, + rules: [], + ); + + final map = model.toMap(); + final result = WafRuleList.fromMap(map); + + expect(result.total, 5); + expect(result.rules, []); + }); + }); +} diff --git a/test/src/models/waf_rule_rate_limit_test.dart b/test/src/models/waf_rule_rate_limit_test.dart new file mode 100644 index 00000000..bb83a502 --- /dev/null +++ b/test/src/models/waf_rule_rate_limit_test.dart @@ -0,0 +1,54 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:dart_appwrite/enums.dart'; +import 'package:test/test.dart'; + +void main() { + group('WafRuleRateLimit', () { + test('model', () { + final model = WafRuleRateLimit( + $id: "wafRule1", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + name: "Block anonymous POST traffic", + description: "Blocks anonymous POST calls to /v1/graphql", + teamId: "5e5ea5c16897e", + projectId: "cloudConsole", + resourceType: "functions", + resourceId: "functionId", + action: WafRuleAction.bypass, + priority: 100, + enabled: true, + conditions: [], + config: {}, + limit: 1000, + interval: 60, + key: "userId", + strategy: "slidingWindow", + maxBucketSize: 200, + ); + + final map = model.toMap(); + final result = WafRuleRateLimit.fromMap(map); + + expect(result.$id, "wafRule1"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.name, "Block anonymous POST traffic"); + expect(result.description, "Blocks anonymous POST calls to /v1/graphql"); + expect(result.teamId, "5e5ea5c16897e"); + expect(result.projectId, "cloudConsole"); + expect(result.resourceType, "functions"); + expect(result.resourceId, "functionId"); + expect(result.action, WafRuleAction.bypass); + expect(result.priority, 100); + expect(result.enabled, true); + expect(result.conditions, []); + expect(result.config, {}); + expect(result.limit, 1000); + expect(result.interval, 60); + expect(result.key, "userId"); + expect(result.strategy, "slidingWindow"); + expect(result.maxBucketSize, 200); + }); + }); +} diff --git a/test/src/models/waf_rule_redirect_test.dart b/test/src/models/waf_rule_redirect_test.dart new file mode 100644 index 00000000..12db8ee5 --- /dev/null +++ b/test/src/models/waf_rule_redirect_test.dart @@ -0,0 +1,48 @@ +import 'package:dart_appwrite/models.dart'; +import 'package:dart_appwrite/enums.dart'; +import 'package:test/test.dart'; + +void main() { + group('WafRuleRedirect', () { + test('model', () { + final model = WafRuleRedirect( + $id: "wafRule1", + $createdAt: "2020-10-15T06:38:00.000+00:00", + $updatedAt: "2020-10-15T06:38:00.000+00:00", + name: "Block anonymous POST traffic", + description: "Blocks anonymous POST calls to /v1/graphql", + teamId: "5e5ea5c16897e", + projectId: "cloudConsole", + resourceType: "functions", + resourceId: "functionId", + action: WafRuleAction.bypass, + priority: 100, + enabled: true, + conditions: [], + config: {}, + location: "/maintenance", + statusCode: 301, + ); + + final map = model.toMap(); + final result = WafRuleRedirect.fromMap(map); + + expect(result.$id, "wafRule1"); + expect(result.$createdAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.$updatedAt, "2020-10-15T06:38:00.000+00:00"); + expect(result.name, "Block anonymous POST traffic"); + expect(result.description, "Blocks anonymous POST calls to /v1/graphql"); + expect(result.teamId, "5e5ea5c16897e"); + expect(result.projectId, "cloudConsole"); + expect(result.resourceType, "functions"); + expect(result.resourceId, "functionId"); + expect(result.action, WafRuleAction.bypass); + expect(result.priority, 100); + expect(result.enabled, true); + expect(result.conditions, []); + expect(result.config, {}); + expect(result.location, "/maintenance"); + expect(result.statusCode, 301); + }); + }); +}