diff --git a/CHANGELOG.md b/CHANGELOG.md index adbaa019..0a41a9e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Change Log +## 27.0.0 + +* Breaking: Removed `Health` service with its models and enums +* Breaking: Removed `Usage` service and usage models +* Breaking: Removed `Messaging` methods `listMessageLogs`, `listProviderLogs`, `listSubscriberLogs`, `listTopicLogs` +* Breaking: Renamed `TablesDB::create` parameter `dedicatedDatabaseId` to `specification` +* Breaking: Removed `countryCode` and `countryName` from `ActivityEvent` model +* Added: `Organization` service `get`, `update`, `delete`, and membership CRUD methods +* Added: `Client::setSigningKey` and `Client::setBearer` for JWT and bearer authentication +* Added: vector query helpers `Query::vectorDot`, `Query::vectorCosine`, `Query::vectorEuclidean` +* Added: `appwrite` OAuth2 provider and `Project::updateOAuth2Appwrite` method +* Added: `prompt` and `maxAge` parameters to `updateOAuth2Oidc`, `defaultScopes` to `updateOAuth2Server` +* Added: `newSpecification` parameter to `Backups::createRestoration` +* Added: `type` parameter to `Functions` and `Sites` `listSpecifications` +* Added: `token` parameter to `Functions::getDeploymentDownload` +* Added: `mode` to `Block`, `status` to `Database`, geolocation/ISP fields to `Locale` models +* Added: `onboarding` and `oAuth2ServerDefaultScopes` to `Project` model +* Added: organization membership, organization, and `project.oauth2`/`stages` key scopes +* Added: billing plan models, `BillingPlanGroup`, `DatabaseStatus`, OIDC prompt enums +* Updated: deprecated `Databases` transaction and text attribute methods in favor of `TablesDB` + ## 26.1.0 * Updated: Reworked `usage.listEvents` into an aggregation query with `metric`, `interval`, `dimensions`, and `orderBy` diff --git a/composer.json b/composer.json index a5eb1aa5..54fa8a06 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "require": { "php": ">=8.2.0", "ext-curl": "*", - "ext-json": "*" + "ext-json": "*", + "adhocore/jwt": "^1.1" }, "require-dev": { "phpunit/phpunit": "^12", diff --git a/docs/account.md b/docs/account.md index 9368ea08..31ac8d2e 100644 --- a/docs/account.md +++ b/docs/account.md @@ -565,7 +565,7 @@ A user is limited to 10 active sessions at a time by default. [Learn more about | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| provider | string | **Required** OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. | | +| provider | string | **Required** OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. | | | success | string | URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | | | failure | string | URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | | | scopes | array | A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. | [] | diff --git a/docs/backups.md b/docs/backups.md index 36a4ee91..3ad1f4eb 100644 --- a/docs/backups.md +++ b/docs/backups.md @@ -133,7 +133,10 @@ DELETE https://cloud.appwrite.io/v1/backups/policies/{policyId} POST https://cloud.appwrite.io/v1/backups/restoration ``` -** Create and trigger a new restoration for a backup on a project. ** +** Create and trigger a new restoration for a backup on a project. + +When restoring a DocumentsDB or VectorsDB database to a new resource, pass `newSpecification` to provision the restored database on a different specification than the archived one (for example, restoring onto a larger or smaller dedicated database). Use `serverless` to restore onto the shared pool, or a dedicated specification slug to restore onto a dedicated database of that size. The specification must be permitted by the organization's plan. `newSpecification` is not supported for legacy/TablesDB databases or for bucket restores. + ** ### Parameters @@ -143,6 +146,7 @@ POST https://cloud.appwrite.io/v1/backups/restoration | services | array | Array of services to restore | | | newResourceId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | newResourceName | string | Database name. Max length: 128 chars. | | +| newSpecification | string | Specification to provision the restored database on, when restoring a DocumentsDB or VectorsDB database to a new resource. Defaults to the archived database's specification. Use `serverless` for the shared pool or a dedicated specification slug. | | ```http request diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md index 61d9e0b2..e572dd47 100644 --- a/docs/examples/backups/create-restoration.md +++ b/docs/examples/backups/create-restoration.md @@ -16,5 +16,6 @@ $result = $backups->createRestoration( archiveId: '', services: [BackupServices::DATABASES()], newResourceId: '', // optional - newResourceName: '' // optional + newResourceName: '', // optional + newSpecification: 'serverless' // optional );``` diff --git a/docs/examples/functions/get-deployment-download.md b/docs/examples/functions/get-deployment-download.md index 73842f54..e267d325 100644 --- a/docs/examples/functions/get-deployment-download.md +++ b/docs/examples/functions/get-deployment-download.md @@ -15,5 +15,6 @@ $functions = new Functions($client); $result = $functions->getDeploymentDownload( functionId: '', deploymentId: '', - type: DeploymentDownloadType::SOURCE() // optional + type: DeploymentDownloadType::SOURCE(), // optional + token: '' // optional );``` diff --git a/docs/examples/functions/list-specifications.md b/docs/examples/functions/list-specifications.md index f5afe80b..7211ce69 100644 --- a/docs/examples/functions/list-specifications.md +++ b/docs/examples/functions/list-specifications.md @@ -11,5 +11,6 @@ $client = (new Client()) $functions = new Functions($client); -$result = $functions->listSpecifications(); -``` +$result = $functions->listSpecifications( + type: 'runtimes' // optional +);``` diff --git a/docs/examples/health/get-audits-db.md b/docs/examples/health/get-audits-db.md deleted file mode 100644 index 045c32fd..00000000 --- a/docs/examples/health/get-audits-db.md +++ /dev/null @@ -1,15 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getAuditsDB(); -``` diff --git a/docs/examples/health/get-cache.md b/docs/examples/health/get-cache.md deleted file mode 100644 index 8443c64f..00000000 --- a/docs/examples/health/get-cache.md +++ /dev/null @@ -1,15 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getCache(); -``` diff --git a/docs/examples/health/get-certificate.md b/docs/examples/health/get-certificate.md deleted file mode 100644 index d1d1fd1e..00000000 --- a/docs/examples/health/get-certificate.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getCertificate( - domain: '' // optional -);``` diff --git a/docs/examples/health/get-db.md b/docs/examples/health/get-db.md deleted file mode 100644 index 1682bcf3..00000000 --- a/docs/examples/health/get-db.md +++ /dev/null @@ -1,15 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getDB(); -``` diff --git a/docs/examples/health/get-pub-sub.md b/docs/examples/health/get-pub-sub.md deleted file mode 100644 index 97dc4b6f..00000000 --- a/docs/examples/health/get-pub-sub.md +++ /dev/null @@ -1,15 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getPubSub(); -``` diff --git a/docs/examples/health/get-queue-databases.md b/docs/examples/health/get-queue-databases.md deleted file mode 100644 index 96bfb6fd..00000000 --- a/docs/examples/health/get-queue-databases.md +++ /dev/null @@ -1,17 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getQueueDatabases( - name: '', // optional - threshold: null // optional -);``` diff --git a/docs/examples/health/get-queue-deletes.md b/docs/examples/health/get-queue-deletes.md deleted file mode 100644 index 2b147f42..00000000 --- a/docs/examples/health/get-queue-deletes.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getQueueDeletes( - threshold: null // optional -);``` diff --git a/docs/examples/health/get-queue-functions.md b/docs/examples/health/get-queue-functions.md deleted file mode 100644 index d5b58442..00000000 --- a/docs/examples/health/get-queue-functions.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getQueueFunctions( - threshold: null // optional -);``` diff --git a/docs/examples/health/get-queue-logs.md b/docs/examples/health/get-queue-logs.md deleted file mode 100644 index cb0125cb..00000000 --- a/docs/examples/health/get-queue-logs.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getQueueLogs( - threshold: null // optional -);``` diff --git a/docs/examples/health/get-queue-mails.md b/docs/examples/health/get-queue-mails.md deleted file mode 100644 index 56babd6c..00000000 --- a/docs/examples/health/get-queue-mails.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getQueueMails( - threshold: null // optional -);``` diff --git a/docs/examples/health/get-queue-messaging.md b/docs/examples/health/get-queue-messaging.md deleted file mode 100644 index 4539c5d9..00000000 --- a/docs/examples/health/get-queue-messaging.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getQueueMessaging( - threshold: null // optional -);``` diff --git a/docs/examples/health/get-queue-migrations.md b/docs/examples/health/get-queue-migrations.md deleted file mode 100644 index 36b8d4b4..00000000 --- a/docs/examples/health/get-queue-migrations.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getQueueMigrations( - threshold: null // optional -);``` diff --git a/docs/examples/health/get-queue-stats-resources.md b/docs/examples/health/get-queue-stats-resources.md deleted file mode 100644 index da4cee7a..00000000 --- a/docs/examples/health/get-queue-stats-resources.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getQueueStatsResources( - threshold: null // optional -);``` diff --git a/docs/examples/health/get-queue-usage.md b/docs/examples/health/get-queue-usage.md deleted file mode 100644 index dd35802b..00000000 --- a/docs/examples/health/get-queue-usage.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getQueueUsage( - threshold: null // optional -);``` diff --git a/docs/examples/health/get-queue-webhooks.md b/docs/examples/health/get-queue-webhooks.md deleted file mode 100644 index d2877ce6..00000000 --- a/docs/examples/health/get-queue-webhooks.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getQueueWebhooks( - threshold: null // optional -);``` diff --git a/docs/examples/health/get-storage-local.md b/docs/examples/health/get-storage-local.md deleted file mode 100644 index d7524bad..00000000 --- a/docs/examples/health/get-storage-local.md +++ /dev/null @@ -1,15 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getStorageLocal(); -``` diff --git a/docs/examples/health/get-storage.md b/docs/examples/health/get-storage.md deleted file mode 100644 index 2a109dec..00000000 --- a/docs/examples/health/get-storage.md +++ /dev/null @@ -1,15 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getStorage(); -``` diff --git a/docs/examples/health/get-time.md b/docs/examples/health/get-time.md deleted file mode 100644 index 559b1797..00000000 --- a/docs/examples/health/get-time.md +++ /dev/null @@ -1,15 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$health = new Health($client); - -$result = $health->getTime(); -``` diff --git a/docs/examples/messaging/list-provider-logs.md b/docs/examples/messaging/list-provider-logs.md deleted file mode 100644 index afc3df91..00000000 --- a/docs/examples/messaging/list-provider-logs.md +++ /dev/null @@ -1,18 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$messaging = new Messaging($client); - -$result = $messaging->listProviderLogs( - providerId: '', - queries: [], // optional - total: false // optional -);``` diff --git a/docs/examples/messaging/list-subscriber-logs.md b/docs/examples/messaging/list-subscriber-logs.md deleted file mode 100644 index 7a0e5ad7..00000000 --- a/docs/examples/messaging/list-subscriber-logs.md +++ /dev/null @@ -1,18 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$messaging = new Messaging($client); - -$result = $messaging->listSubscriberLogs( - subscriberId: '', - queries: [], // optional - total: false // optional -);``` diff --git a/docs/examples/messaging/list-topic-logs.md b/docs/examples/messaging/list-topic-logs.md deleted file mode 100644 index d32d27ae..00000000 --- a/docs/examples/messaging/list-topic-logs.md +++ /dev/null @@ -1,18 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$messaging = new Messaging($client); - -$result = $messaging->listTopicLogs( - topicId: '', - queries: [], // optional - total: false // optional -);``` diff --git a/docs/examples/organization/create-membership.md b/docs/examples/organization/create-membership.md new file mode 100644 index 00000000..372c09cc --- /dev/null +++ b/docs/examples/organization/create-membership.md @@ -0,0 +1,21 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$organization = new Organization($client); + +$result = $organization->createMembership( + roles: [], + email: 'email@example.com', // optional + userId: '', // optional + phone: '+12065550100', // optional + url: 'https://example.com', // optional + name: '' // optional +);``` diff --git a/docs/examples/health/get-queue-certificates.md b/docs/examples/organization/delete-membership.md similarity index 62% rename from docs/examples/health/get-queue-certificates.md rename to docs/examples/organization/delete-membership.md index d70b6574..9da3b64f 100644 --- a/docs/examples/health/get-queue-certificates.md +++ b/docs/examples/organization/delete-membership.md @@ -2,15 +2,15 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$health = new Health($client); +$organization = new Organization($client); -$result = $health->getQueueCertificates( - threshold: null // optional +$result = $organization->deleteMembership( + membershipId: '' );``` diff --git a/docs/examples/health/get-antivirus.md b/docs/examples/organization/delete.md similarity index 69% rename from docs/examples/health/get-antivirus.md rename to docs/examples/organization/delete.md index 7f57d8aa..1160857a 100644 --- a/docs/examples/health/get-antivirus.md +++ b/docs/examples/organization/delete.md @@ -2,14 +2,14 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$health = new Health($client); +$organization = new Organization($client); -$result = $health->getAntivirus(); +$result = $organization->delete(); ``` diff --git a/docs/examples/health/get-queue-builds.md b/docs/examples/organization/get-membership.md similarity index 62% rename from docs/examples/health/get-queue-builds.md rename to docs/examples/organization/get-membership.md index 607acb20..52e2d17d 100644 --- a/docs/examples/health/get-queue-builds.md +++ b/docs/examples/organization/get-membership.md @@ -2,15 +2,15 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$health = new Health($client); +$organization = new Organization($client); -$result = $health->getQueueBuilds( - threshold: null // optional +$result = $organization->getMembership( + membershipId: '' );``` diff --git a/docs/examples/health/get.md b/docs/examples/organization/get.md similarity index 70% rename from docs/examples/health/get.md rename to docs/examples/organization/get.md index 4b46ac2c..6fb38198 100644 --- a/docs/examples/health/get.md +++ b/docs/examples/organization/get.md @@ -2,14 +2,14 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$health = new Health($client); +$organization = new Organization($client); -$result = $health->get(); +$result = $organization->get(); ``` diff --git a/docs/examples/messaging/list-message-logs.md b/docs/examples/organization/list-memberships.md similarity index 67% rename from docs/examples/messaging/list-message-logs.md rename to docs/examples/organization/list-memberships.md index 8bc5631c..17858996 100644 --- a/docs/examples/messaging/list-message-logs.md +++ b/docs/examples/organization/list-memberships.md @@ -2,17 +2,17 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$messaging = new Messaging($client); +$organization = new Organization($client); -$result = $messaging->listMessageLogs( - messageId: '', +$result = $organization->listMemberships( queries: [], // optional + search: '', // optional total: false // optional );``` diff --git a/docs/examples/health/get-console-pausing.md b/docs/examples/organization/update-membership.md similarity index 60% rename from docs/examples/health/get-console-pausing.md rename to docs/examples/organization/update-membership.md index 06a434d8..7097729e 100644 --- a/docs/examples/health/get-console-pausing.md +++ b/docs/examples/organization/update-membership.md @@ -2,16 +2,16 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$health = new Health($client); +$organization = new Organization($client); -$result = $health->getConsolePausing( - threshold: null, // optional - inactivityDays: null // optional +$result = $organization->updateMembership( + membershipId: '', + roles: [] );``` diff --git a/docs/examples/health/get-queue-audits.md b/docs/examples/organization/update.md similarity index 66% rename from docs/examples/health/get-queue-audits.md rename to docs/examples/organization/update.md index 2bfc32e8..45e7f0ff 100644 --- a/docs/examples/health/get-queue-audits.md +++ b/docs/examples/organization/update.md @@ -2,15 +2,15 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$health = new Health($client); +$organization = new Organization($client); -$result = $health->getQueueAudits( - threshold: null // optional +$result = $organization->update( + name: '' );``` diff --git a/docs/examples/health/get-failed-jobs.md b/docs/examples/project/update-o-auth-2-appwrite.md similarity index 53% rename from docs/examples/health/get-failed-jobs.md rename to docs/examples/project/update-o-auth-2-appwrite.md index de204109..be24abdb 100644 --- a/docs/examples/health/get-failed-jobs.md +++ b/docs/examples/project/update-o-auth-2-appwrite.md @@ -2,17 +2,17 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$health = new Health($client); +$project = new Project($client); -$result = $health->getFailedJobs( - name: HealthQueueName::V1DATABASE(), - threshold: null // optional +$result = $project->updateOAuth2Appwrite( + clientId: '', // optional + clientSecret: '', // optional + enabled: false // optional );``` diff --git a/docs/examples/project/update-o-auth-2-oidc.md b/docs/examples/project/update-o-auth-2-oidc.md index 1b9d9b86..2c06fe89 100644 --- a/docs/examples/project/update-o-auth-2-oidc.md +++ b/docs/examples/project/update-o-auth-2-oidc.md @@ -3,6 +3,7 @@ use Appwrite\Client; use Appwrite\Services\Project; +use Appwrite\Enums\ProjectOAuth2OidcPrompt; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -18,5 +19,7 @@ $result = $project->updateOAuth2Oidc( authorizationURL: 'https://example.com', // optional tokenURL: 'https://example.com', // optional userInfoURL: 'https://example.com', // optional + prompt: [ProjectOAuth2OidcPrompt::NONE()], // optional + maxAge: 0, // optional enabled: false // optional );``` diff --git a/docs/examples/project/update-o-auth-2-server.md b/docs/examples/project/update-o-auth-2-server.md index d8974303..9c3eb9a8 100644 --- a/docs/examples/project/update-o-auth-2-server.md +++ b/docs/examples/project/update-o-auth-2-server.md @@ -24,5 +24,6 @@ $result = $project->updateOAuth2Server( verificationUrl: 'https://example.com', // optional userCodeLength: 6, // optional userCodeFormat: 'numeric', // optional - deviceCodeDuration: 60 // optional + deviceCodeDuration: 60, // optional + defaultScopes: [] // optional );``` diff --git a/docs/examples/sites/list-specifications.md b/docs/examples/sites/list-specifications.md index 1a732b6a..33bc0c59 100644 --- a/docs/examples/sites/list-specifications.md +++ b/docs/examples/sites/list-specifications.md @@ -11,5 +11,6 @@ $client = (new Client()) $sites = new Sites($client); -$result = $sites->listSpecifications(); -``` +$result = $sites->listSpecifications( + type: 'runtimes' // optional +);``` diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index 34d30569..9cbbf307 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -15,5 +15,5 @@ $result = $tablesDB->create( databaseId: '', name: '', enabled: false, // optional - dedicatedDatabaseId: '' // optional + specification: 'serverless' // optional );``` diff --git a/docs/examples/usage/list-events.md b/docs/examples/usage/list-events.md deleted file mode 100644 index e7cfe438..00000000 --- a/docs/examples/usage/list-events.md +++ /dev/null @@ -1,26 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$usage = new Usage($client); - -$result = $usage->listEvents( - metric: '', - resource: '', // optional - resourceId: '', // optional - interval: '1m', // optional - dimensions: [], // optional - startAt: '2020-10-15T06:38:00.000+00:00', // optional - endAt: '2020-10-15T06:38:00.000+00:00', // optional - orderBy: 'time', // optional - orderDir: 'asc', // optional - limit: 1, // optional - offset: 0 // optional -);``` diff --git a/docs/examples/usage/list-gauges.md b/docs/examples/usage/list-gauges.md deleted file mode 100644 index 899c052b..00000000 --- a/docs/examples/usage/list-gauges.md +++ /dev/null @@ -1,26 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$usage = new Usage($client); - -$result = $usage->listGauges( - metric: '', - resourceId: '', // optional - teamId: '', // optional - interval: '1m', // optional - dimensions: [], // optional - startAt: '2020-10-15T06:38:00.000+00:00', // optional - endAt: '2020-10-15T06:38:00.000+00:00', // optional - orderBy: 'time', // optional - orderDir: 'asc', // optional - limit: 1, // optional - offset: 0 // optional -);``` diff --git a/docs/functions.md b/docs/functions.md index 04fed225..86be1ee9 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -37,7 +37,7 @@ POST https://cloud.appwrite.io/v1/functions | logging | boolean | When disabled, executions will exclude logs and errors, and will be slightly faster. | 1 | | entrypoint | string | Entrypoint File. This path is relative to the "providerRootDirectory". | | | commands | string | Build Commands. | | -| scopes | array | List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed. | [] | +| scopes | array | List of scopes allowed for API key auto-generated for every execution. Maximum of 200 scopes are allowed. | [] | | installationId | string | Appwrite Installation ID for VCS (Version Control System) deployment. | | | providerRepositoryId | string | Repository ID of the repo linked to the function. | | | providerBranch | string | Production branch for the repo linked to the function. | | @@ -63,6 +63,12 @@ GET https://cloud.appwrite.io/v1/functions/specifications ** List allowed function specifications for this instance. ** +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| type | string | Specification type to list. Can be one of: runtimes, builds. | runtimes | + ```http request GET https://cloud.appwrite.io/v1/functions/{functionId} @@ -98,7 +104,7 @@ PUT https://cloud.appwrite.io/v1/functions/{functionId} | logging | boolean | When disabled, executions will exclude logs and errors, and will be slightly faster. | 1 | | entrypoint | string | Entrypoint File. This path is relative to the "providerRootDirectory". | | | commands | string | Build Commands. | | -| scopes | array | List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed. | [] | +| scopes | array | List of scopes allowed for API Key auto-generated for every execution. Maximum of 200 scopes are allowed. | [] | | installationId | string | Appwrite Installation ID for VCS (Version Controle System) deployment. | | | providerRepositoryId | string | Repository ID of the repo linked to the function | | | providerBranch | string | Production branch for the repo linked to the function | | @@ -106,7 +112,7 @@ PUT https://cloud.appwrite.io/v1/functions/{functionId} | providerRootDirectory | string | Path to function code in the linked repo. | | | providerBranches | array | List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. | | | providerPaths | array | List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. | | -| buildSpecification | string | Build specification for the function deployments. | [] | +| buildSpecification | string | Build specification for the function deployments. | | | runtimeSpecification | string | Runtime specification for the function executions. | [] | | deploymentRetention | integer | Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. | 0 | @@ -270,6 +276,7 @@ GET https://cloud.appwrite.io/v1/functions/{functionId}/deployments/{deploymentI | functionId | string | **Required** Function ID. | | | deploymentId | string | **Required** Deployment ID. | | | type | string | Deployment file to download. Can be: "source", "output". | source | +| token | string | Presigned source-download token for accessing this deployment without a session (jobs-service). | | ```http request diff --git a/docs/health.md b/docs/health.md deleted file mode 100644 index 2dc98889..00000000 --- a/docs/health.md +++ /dev/null @@ -1,280 +0,0 @@ -# Health Service - - -```http request -GET https://cloud.appwrite.io/v1/health -``` - -** Check the Appwrite HTTP server is up and responsive. ** - - -```http request -GET https://cloud.appwrite.io/v1/health/anti-virus -``` - -** Check the Appwrite Antivirus server is up and connection is successful. ** - - -```http request -GET https://cloud.appwrite.io/v1/health/audits-db -``` - -** Check the database that backs the audit and activity store. When the connection is reachable the endpoint returns a passing status with its response time. - ** - - -```http request -GET https://cloud.appwrite.io/v1/health/cache -``` - -** Check the Appwrite in-memory cache servers are up and connection is successful. ** - - -```http request -GET https://cloud.appwrite.io/v1/health/certificate -``` - -** Get the SSL certificate for a domain ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| domain | string | string | | - - -```http request -GET https://cloud.appwrite.io/v1/health/console-pausing -``` - -** Get console pausing health status. Monitors projects approaching the pause threshold to detect potential issues with console access tracking. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Percentage threshold of projects approaching pause. When hit (equal or higher), endpoint returns server error. Default value is 10. | 10 | -| inactivityDays | integer | Number of days of inactivity before a project is paused. Should match the plan's projectInactivityDays setting. Default value is 7. | 7 | - - -```http request -GET https://cloud.appwrite.io/v1/health/db -``` - -** Check the Appwrite database servers are up and connection is successful. ** - - -```http request -GET https://cloud.appwrite.io/v1/health/pubsub -``` - -** Check the Appwrite pub-sub servers are up and connection is successful. ** - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/audits -``` - -** Get the number of audit logs that are waiting to be processed in the Appwrite internal queue server. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/builds -``` - -** Get the number of builds that are waiting to be processed in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/certificates -``` - -** Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/databases -``` - -** Get the number of database changes that are waiting to be processed in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| name | string | Queue name for which to check the queue size | database_db_main | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/deletes -``` - -** Get the number of background destructive changes that are waiting to be processed in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/failed/{name} -``` - -** Returns the amount of failed jobs in a given queue. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| name | string | **Required** The name of the queue | | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/functions -``` - -** Get the number of function executions that are waiting to be processed in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/logs -``` - -** Get the number of logs that are waiting to be processed in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/mails -``` - -** Get the number of mails that are waiting to be processed in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/messaging -``` - -** Get the number of messages that are waiting to be processed in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/migrations -``` - -** Get the number of migrations that are waiting to be processed in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/stats-resources -``` - -** Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/stats-usage -``` - -** Get the number of metrics that are waiting to be processed in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/webhooks -``` - -** Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/storage -``` - -** Check the Appwrite storage device is up and connection is successful. ** - - -```http request -GET https://cloud.appwrite.io/v1/health/storage/local -``` - -** Check the Appwrite local storage device is up and connection is successful. ** - - -```http request -GET https://cloud.appwrite.io/v1/health/time -``` - -** Check the Appwrite server time is synced with Google remote NTP server. We use this technology to smoothly handle leap seconds with no disruptive events. The [Network Time Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is used by hundreds of millions of computers and devices to synchronize their clocks over the Internet. If your computer sets its own clock, it likely uses NTP. ** - diff --git a/docs/messaging.md b/docs/messaging.md index 15f8056c..e2585239 100644 --- a/docs/messaging.md +++ b/docs/messaging.md @@ -233,21 +233,6 @@ DELETE https://cloud.appwrite.io/v1/messaging/messages/{messageId} | messageId | string | **Required** Message ID. | | -```http request -GET https://cloud.appwrite.io/v1/messaging/messages/{messageId}/logs -``` - -** Get the message activity logs listed by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| messageId | string | **Required** Message ID. | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset | [] | -| total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | - - ```http request GET https://cloud.appwrite.io/v1/messaging/messages/{messageId}/targets ``` @@ -901,36 +886,6 @@ DELETE https://cloud.appwrite.io/v1/messaging/providers/{providerId} | providerId | string | **Required** Provider ID. | | -```http request -GET https://cloud.appwrite.io/v1/messaging/providers/{providerId}/logs -``` - -** Get the provider activity logs listed by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| providerId | string | **Required** Provider ID. | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset | [] | -| total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | - - -```http request -GET https://cloud.appwrite.io/v1/messaging/subscribers/{subscriberId}/logs -``` - -** Get the subscriber activity logs listed by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| subscriberId | string | **Required** Subscriber ID. | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset | [] | -| total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | - - ```http request GET https://cloud.appwrite.io/v1/messaging/topics ``` @@ -1004,21 +959,6 @@ DELETE https://cloud.appwrite.io/v1/messaging/topics/{topicId} | topicId | string | **Required** Topic ID. | | -```http request -GET https://cloud.appwrite.io/v1/messaging/topics/{topicId}/logs -``` - -** Get the topic activity logs listed by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| topicId | string | **Required** Topic ID. | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset | [] | -| total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | - - ```http request GET https://cloud.appwrite.io/v1/messaging/topics/{topicId}/subscribers ``` diff --git a/docs/organization.md b/docs/organization.md index 6bd35ae8..65a24932 100644 --- a/docs/organization.md +++ b/docs/organization.md @@ -1,6 +1,33 @@ # Organization Service +```http request +GET https://cloud.appwrite.io/v1/organization +``` + +** Get the current organization. ** + + +```http request +PUT https://cloud.appwrite.io/v1/organization +``` + +** Update the current organization's name. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| name | string | New organization name. Max length: 128 chars. | | + + +```http request +DELETE https://cloud.appwrite.io/v1/organization +``` + +** Delete the current organization. All projects that belong to the organization are deleted as well. ** + + ```http request GET https://cloud.appwrite.io/v1/organization/keys ``` @@ -27,7 +54,7 @@ POST https://cloud.appwrite.io/v1/organization/keys | --- | --- | --- | --- | | keyId | string | Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | name | string | Key name. Max length: 128 chars. | | -| scopes | array | Key scopes list. Maximum of 100 scopes are allowed. | | +| scopes | array | Key scopes list. Maximum of 200 scopes are allowed. | | | expire | string | Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. | | @@ -56,7 +83,7 @@ PUT https://cloud.appwrite.io/v1/organization/keys/{keyId} | --- | --- | --- | --- | | keyId | string | **Required** Key unique ID. | | | name | string | Key name. Max length: 128 chars. | | -| scopes | array | Key scopes list. Maximum of 100 scopes are allowed. | | +| scopes | array | Key scopes list. Maximum of 200 scopes are allowed. | | | expire | string | Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. | | @@ -73,6 +100,79 @@ DELETE https://cloud.appwrite.io/v1/organization/keys/{keyId} | keyId | string | **Required** Key unique ID. | | +```http request +GET https://cloud.appwrite.io/v1/organization/memberships +``` + +** Get a list of all memberships from the current organization. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm, roles | [] | +| search | string | Search term to filter your list results. Max length: 256 chars. | | +| total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | + + +```http request +POST https://cloud.appwrite.io/v1/organization/memberships +``` + +** Invite a new member to join the current organization. An email with a link to join the organization will be sent to the new member's email address. If member doesn't exist in the project it will be automatically created. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| email | string | Email of the new organization member. | | +| userId | string | ID of the user to be added to the organization. | | +| phone | string | Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| roles | array | Array of strings. Use this param to set the user roles in the organization. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. | | +| url | string | URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. | | +| name | string | Name of the new organization member. Max length: 128 chars. | | + + +```http request +GET https://cloud.appwrite.io/v1/organization/memberships/{membershipId} +``` + +** Get a membership from the current organization by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| membershipId | string | **Required** Membership ID. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/organization/memberships/{membershipId} +``` + +** Modify the roles of a member in the current organization. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| membershipId | string | **Required** Membership ID. | | +| roles | array | An array of strings. Use this param to set the user's roles in the organization. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. | | + + +```http request +DELETE https://cloud.appwrite.io/v1/organization/memberships/{membershipId} +``` + +** Remove a member from the current organization. The member is removed whether they accepted the invitation or not; a pending invitation is revoked. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| membershipId | string | **Required** Membership ID. | | + + ```http request GET https://cloud.appwrite.io/v1/organization/projects ``` @@ -83,7 +183,7 @@ GET https://cloud.appwrite.io/v1/organization/projects | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search | [] | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId, labels, search, accessedAt | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | | total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | diff --git a/docs/project.md b/docs/project.md index 6cb25b4a..ca8f7cb6 100644 --- a/docs/project.md +++ b/docs/project.md @@ -57,7 +57,7 @@ You can also create an ephemeral API key if you need a short-lived key instead. | --- | --- | --- | --- | | keyId | string | Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | name | string | Key name. Max length: 128 chars. | | -| scopes | array | Key scopes list. Maximum of 100 scopes are allowed. | | +| scopes | array | Key scopes list. Maximum of 200 scopes are allowed. | | | expire | string | Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. | | @@ -73,7 +73,7 @@ You can also create a standard API key if you need a longer-lived key instead. * | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| scopes | array | Key scopes list. Maximum of 100 scopes are allowed. | | +| scopes | array | Key scopes list. Maximum of 200 scopes are allowed. | | | duration | integer | Time in seconds before ephemeral key expires. Maximum duration is 3600 seconds. | | @@ -102,7 +102,7 @@ PUT https://cloud.appwrite.io/v1/project/keys/{keyId} | --- | --- | --- | --- | | keyId | string | **Required** Key ID. | | | name | string | Key name. Max length: 128 chars. | | -| scopes | array | Key scopes list. Maximum of 100 scopes are allowed. | | +| scopes | array | Key scopes list. Maximum of 200 scopes are allowed. | | | expire | string | Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. | | @@ -237,6 +237,7 @@ PUT https://cloud.appwrite.io/v1/project/oauth2-server | userCodeLength | integer | Number of characters in the device flow user code, excluding the formatting separator. Shorter codes are easier to type but weaker; pair short codes with short expiry. Leave empty to use default 8. | | | userCodeFormat | string | Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. | alphanumeric | | deviceCodeDuration | integer | Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. | | +| defaultScopes | array | List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. | [] | ```http request @@ -271,6 +272,21 @@ PATCH https://cloud.appwrite.io/v1/project/oauth2/apple | enabled | boolean | OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. | | +```http request +PATCH https://cloud.appwrite.io/v1/project/oauth2/appwrite +``` + +** Update the project OAuth2 Appwrite configuration. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| clientId | string | 'Client ID' of Appwrite OAuth2 app. For example: 6a42000000000000b5a0 | | +| clientSecret | string | 'Client Secret' of Appwrite OAuth2 app. For example: b86afd000000000000000000000000000000000000000000000000000ced5f93 | | +| enabled | boolean | OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. | | + + ```http request PATCH https://cloud.appwrite.io/v1/project/oauth2/auth0 ``` @@ -625,6 +641,8 @@ PATCH https://cloud.appwrite.io/v1/project/oauth2/oidc | authorizationURL | string | OpenID Connect authorization endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/authorize | | | tokenURL | string | OpenID Connect token endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/token | | | userInfoURL | string | OpenID Connect user info endpoint URL. Required when wellKnownURL is not provided. For example: https://myoauth.com/oauth2/userinfo | | +| prompt | array | Array of OpenID Connect prompt values controlling the authentication and consent screens. If "none" is included, it must be the only element. "none" means: don't display any authentication or consent screens. "login" means: prompt the user to re-authenticate. "consent" means: prompt the user for consent. "select_account" means: prompt the user to select an account. | | +| maxAge | integer | Maximum authentication age in seconds. When set, the user must have authenticated within this many seconds, otherwise they are prompted to re-authenticate. | | | enabled | boolean | OAuth2 sign-in method status. Set to true to enable new session creation. Setting to true will trigger end-to-end credentials validation, and will throw if the credentials are invalid. | | diff --git a/docs/sites.md b/docs/sites.md index 80247d5a..74c000aa 100644 --- a/docs/sites.md +++ b/docs/sites.md @@ -64,6 +64,12 @@ GET https://cloud.appwrite.io/v1/sites/specifications ** List allowed site specifications for this instance. ** +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| type | string | Specification type to list. Can be one of: runtimes, builds. | runtimes | + ```http request GET https://cloud.appwrite.io/v1/sites/{siteId} @@ -108,7 +114,7 @@ PUT https://cloud.appwrite.io/v1/sites/{siteId} | providerRootDirectory | string | Path to site code in the linked repo. | | | providerBranches | array | List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches. | | | providerPaths | array | List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes. | | -| buildSpecification | string | Build specification for the site deployments. | [] | +| buildSpecification | string | Build specification for the site deployments. | | | runtimeSpecification | string | Runtime specification for the SSR executions. | [] | | deploymentRetention | integer | Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept. | 0 | diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 7580ce10..1df71a2b 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -30,7 +30,7 @@ POST https://cloud.appwrite.io/v1/tablesdb | databaseId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | name | string | Database name. Max length: 128 chars. | | | enabled | boolean | Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. | 1 | -| dedicatedDatabaseId | string | Optional dedicated database (compute) ID to attach this database to. Leave empty to create a database on the shared pool. | | +| specification | string | Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. | serverless | ```http request diff --git a/docs/usage.md b/docs/usage.md deleted file mode 100644 index c8466fc9..00000000 --- a/docs/usage.md +++ /dev/null @@ -1,60 +0,0 @@ -# Usage Service - - -```http request -GET https://cloud.appwrite.io/v1/usage/events -``` - -** Aggregate usage event metrics. `metric` is required. - -**Two response shapes**: -- Omit `interval` for a flat top-N table — one row per dimension combination, no time axis. Useful for "top 10 paths by bandwidth in the last 7 days". -- Pass `interval` (`1m`, `15m`, `30m`, `1h`, `1d`) for a time series — one row per (time bucket × dimension combination). - -`dimensions[]` breaks each row down by one or more attributes (service, path, status, country, …). `resource` and `resourceId` filter the underlying events. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N by aggregated value. When `startAt` is omitted, the default window adapts to `interval` (or 7d when interval is omitted). ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| metric | string | **Required** Metric name (required). Example: executions, network.requests. | | -| resource | string | Resource type filter (singular form). Common values: function, site, database, bucket, file, webhook, team, user, project. | | -| resourceId | string | Resource id filter. | | -| interval | string | Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. | | -| dimensions | array | Break-down dimensions (max 10). Allowed: path, method, status, service, country, region, hostname, osName, clientType, clientName, deviceName, teamId, resourceId. | [] | -| startAt | string | Range start in ISO 8601. Defaults adapt to interval (7d for the no-interval aggregate). | | -| endAt | string | Range end in ISO 8601. Defaults to the current time. | | -| orderBy | string | Column to order by. Allowed: time, value. Default time when an interval is set; otherwise value. | time | -| orderDir | string | Sort direction: asc or desc. Default desc — paired with the default limit, returns the most recent / highest-value groups first. | desc | -| limit | integer | Maximum rows to return (1-5000). | 500 | -| offset | integer | Pagination offset (0-100000). | 0 | - - -```http request -GET https://cloud.appwrite.io/v1/usage/gauges -``` - -** Aggregate usage gauge snapshots. Gauges are point-in-time values (storage totals, resource counts, …); each group carries the latest snapshot in its interval via `argMax(value, time)`. `metric` is required. - -**Two response shapes**: -- Omit `interval` for a flat top-N table — `argMax(value, time)` per dimension combination over the whole window, no time axis. Useful for "top 10 resources by current storage". -- Pass `interval` (`1m`, `15m`, `30m`, `1h`, `1d`) for a time series — one snapshot per (time bucket × dimension combination). - -`dimensions[]` breaks each row down further — only `resourceId` and `teamId` are supported on gauges. `resourceId` and `teamId` parameters filter the underlying rows. `orderBy=value`+`orderDir=desc`+`limit=N` returns the top-N. When `startAt` is omitted, the default window adapts to interval (or 7d when interval is omitted). ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| metric | string | **Required** Metric name (required). Example: files.storage, deployments.storage. | | -| resourceId | string | Resource id filter. | | -| teamId | string | Team id filter. | | -| interval | string | Time interval size. Omit (null) for a flat aggregate over the whole window. Allowed: 1m, 15m, 30m, 1h, 1d. | | -| dimensions | array | Break-down dimensions. Allowed: resourceId, teamId. | [] | -| startAt | string | Range start in ISO 8601. Defaults to endAt - 7d. | | -| endAt | string | Range end in ISO 8601. Defaults to the current time. | | -| orderBy | string | Column to order by. Allowed: time, value. Default time. | time | -| orderDir | string | Sort direction: asc or desc. Default desc — paired with the default limit, this returns the most recent groups first. Pass asc for chronological charting. | desc | -| limit | integer | Maximum rows to return (1-5000). | 500 | -| offset | integer | Pagination offset (0-100000). | 0 | - diff --git a/docs/users.md b/docs/users.md index 5c246265..02d1d014 100644 --- a/docs/users.md +++ b/docs/users.md @@ -11,7 +11,7 @@ GET https://cloud.appwrite.io/v1/users | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator | [] | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels, impersonator, accessedAt | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | | total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 0242bc6b..9a1a4cd9 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -2,6 +2,8 @@ namespace Appwrite; +use Ahc\Jwt\JWT; + class Client { const METHOD_GET = 'GET'; @@ -15,6 +17,7 @@ class Client const METHOD_TRACE = 'TRACE'; const CHUNK_SIZE = 5 * 1024 * 1024; + const JWT_MAX_AGE_SECONDS = 3600; /** * Is Self Signed Certificates Allowed? @@ -37,11 +40,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/26.1.0 ()', + 'user-agent' => 'AppwritePHPSDK/27.0.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '26.1.0', + 'x-sdk-version'=> '27.0.0', ]; /** @@ -51,6 +54,27 @@ class Client */ protected array $config = []; + /** + * API key for JWT generation + * + * @var string|null + */ + protected ?string $key = null; + + /** + * Cached authorization header value + * + * @var string|null + */ + protected ?string $authorization = null; + + /** + * Authorization header expiry time + * + * @var \DateTime|null + */ + protected ?\DateTime $authorizationExpiresAt = null; + /** * Timeout in seconds * @@ -124,6 +148,26 @@ public function setJWT(string $value): Client return $this; } + /** + * Set Bearer + * + * The OAuth access token to authenticate with + * + * @param string $value + * + * @return Client + */ + public function setBearer(string $value): Client + { + $this->addHeader('Authorization', "Bearer {$value}"); + $this->config['bearer'] = $value; + $this->key = null; + $this->authorization = null; + $this->authorizationExpiresAt = null; + + return $this; + } + /** * Set Locale * @@ -258,6 +302,25 @@ public function setImpersonateUserPhone(string $value): Client return $this; } + /** + * Set Signing Key + * + * Set a secret key used to self-sign short-lived JWTs for the Authorization header + * + * @param string $key + * + * @return Client + */ + public function setSigningKey(string $key): Client + { + $this->key = $key; + $this->authorization = null; + $this->authorizationExpiresAt = null; + unset($this->headers['authorization'], $this->config['bearer']); + + return $this; + } + public function getConfig(string $key): string { @@ -334,6 +397,25 @@ public function getHeaders(): array return $this->headers; } + /** + * Get authorization header, generating a new JWT if needed + * + * @return string + */ + private function getAuthorization(): string + { + if (\is_string($this->authorization) && $this->authorizationExpiresAt > new \DateTime()) { + return $this->authorization; + } + + $jwt = new JWT($this->key, maxAge: self::JWT_MAX_AGE_SECONDS); + $this->authorization = "Bearer {$jwt->encode([])}"; + + $this->authorizationExpiresAt = (new \DateTime())->modify('+' . (self::JWT_MAX_AGE_SECONDS - 5) . ' seconds'); + + return $this->authorization; + } + /** * Call * @@ -354,6 +436,9 @@ public function call( ?string $responseType = null ) { + if ($this->key !== null) { + $this->headers['authorization'] = $this->getAuthorization(); + } $headers = array_merge($this->headers, $headers); $querySeparator = str_contains($path, '?') ? '&' : '?'; $ch = curl_init($this->endpoint . $path . (($method == self::METHOD_GET && !empty($params)) ? $querySeparator . http_build_query($params) : '')); diff --git a/src/Appwrite/Enums/BillingPlanGroup.php b/src/Appwrite/Enums/BillingPlanGroup.php new file mode 100644 index 00000000..a58d7e91 --- /dev/null +++ b/src/Appwrite/Enums/BillingPlanGroup.php @@ -0,0 +1,61 @@ +value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function STARTER(): BillingPlanGroup + { + if (!isset(self::$STARTER)) { + self::$STARTER = new BillingPlanGroup('starter'); + } + return self::$STARTER; + } + public static function PRO(): BillingPlanGroup + { + if (!isset(self::$PRO)) { + self::$PRO = new BillingPlanGroup('pro'); + } + return self::$PRO; + } + public static function SCALE(): BillingPlanGroup + { + if (!isset(self::$SCALE)) { + self::$SCALE = new BillingPlanGroup('scale'); + } + return self::$SCALE; + } + + public static function from(string $value): self + { + return match ($value) { + 'starter' => self::STARTER(), + 'pro' => self::PRO(), + 'scale' => self::SCALE(), + default => throw new \InvalidArgumentException('Unknown BillingPlanGroup value: ' . $value), + }; + } +} diff --git a/src/Appwrite/Enums/DatabaseStatus.php b/src/Appwrite/Enums/DatabaseStatus.php new file mode 100644 index 00000000..0555a062 --- /dev/null +++ b/src/Appwrite/Enums/DatabaseStatus.php @@ -0,0 +1,61 @@ +value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function PROVISIONING(): DatabaseStatus + { + if (!isset(self::$PROVISIONING)) { + self::$PROVISIONING = new DatabaseStatus('provisioning'); + } + return self::$PROVISIONING; + } + public static function READY(): DatabaseStatus + { + if (!isset(self::$READY)) { + self::$READY = new DatabaseStatus('ready'); + } + return self::$READY; + } + public static function FAILED(): DatabaseStatus + { + if (!isset(self::$FAILED)) { + self::$FAILED = new DatabaseStatus('failed'); + } + return self::$FAILED; + } + + public static function from(string $value): self + { + return match ($value) { + 'provisioning' => self::PROVISIONING(), + 'ready' => self::READY(), + 'failed' => self::FAILED(), + default => throw new \InvalidArgumentException('Unknown DatabaseStatus value: ' . $value), + }; + } +} diff --git a/src/Appwrite/Enums/HealthAntivirusStatus.php b/src/Appwrite/Enums/HealthAntivirusStatus.php deleted file mode 100644 index edee6045..00000000 --- a/src/Appwrite/Enums/HealthAntivirusStatus.php +++ /dev/null @@ -1,61 +0,0 @@ -value = $value; - } - - public function __toString(): string - { - return $this->value; - } - - public function jsonSerialize(): string - { - return $this->value; - } - - public static function DISABLED(): HealthAntivirusStatus - { - if (!isset(self::$DISABLED)) { - self::$DISABLED = new HealthAntivirusStatus('disabled'); - } - return self::$DISABLED; - } - public static function OFFLINE(): HealthAntivirusStatus - { - if (!isset(self::$OFFLINE)) { - self::$OFFLINE = new HealthAntivirusStatus('offline'); - } - return self::$OFFLINE; - } - public static function ONLINE(): HealthAntivirusStatus - { - if (!isset(self::$ONLINE)) { - self::$ONLINE = new HealthAntivirusStatus('online'); - } - return self::$ONLINE; - } - - public static function from(string $value): self - { - return match ($value) { - 'disabled' => self::DISABLED(), - 'offline' => self::OFFLINE(), - 'online' => self::ONLINE(), - default => throw new \InvalidArgumentException('Unknown HealthAntivirusStatus value: ' . $value), - }; - } -} diff --git a/src/Appwrite/Enums/HealthCheckStatus.php b/src/Appwrite/Enums/HealthCheckStatus.php deleted file mode 100644 index 8d36ec4e..00000000 --- a/src/Appwrite/Enums/HealthCheckStatus.php +++ /dev/null @@ -1,52 +0,0 @@ -value = $value; - } - - public function __toString(): string - { - return $this->value; - } - - public function jsonSerialize(): string - { - return $this->value; - } - - public static function PASS(): HealthCheckStatus - { - if (!isset(self::$PASS)) { - self::$PASS = new HealthCheckStatus('pass'); - } - return self::$PASS; - } - public static function FAIL(): HealthCheckStatus - { - if (!isset(self::$FAIL)) { - self::$FAIL = new HealthCheckStatus('fail'); - } - return self::$FAIL; - } - - public static function from(string $value): self - { - return match ($value) { - 'pass' => self::PASS(), - 'fail' => self::FAIL(), - default => throw new \InvalidArgumentException('Unknown HealthCheckStatus value: ' . $value), - }; - } -} diff --git a/src/Appwrite/Enums/HealthQueueName.php b/src/Appwrite/Enums/HealthQueueName.php deleted file mode 100644 index e03d7c81..00000000 --- a/src/Appwrite/Enums/HealthQueueName.php +++ /dev/null @@ -1,151 +0,0 @@ -value = $value; - } - - public function __toString(): string - { - return $this->value; - } - - public function jsonSerialize(): string - { - return $this->value; - } - - public static function V1DATABASE(): HealthQueueName - { - if (!isset(self::$V1DATABASE)) { - self::$V1DATABASE = new HealthQueueName('v1-database'); - } - return self::$V1DATABASE; - } - public static function V1DELETES(): HealthQueueName - { - if (!isset(self::$V1DELETES)) { - self::$V1DELETES = new HealthQueueName('v1-deletes'); - } - return self::$V1DELETES; - } - public static function V1AUDITS(): HealthQueueName - { - if (!isset(self::$V1AUDITS)) { - self::$V1AUDITS = new HealthQueueName('v1-audits'); - } - return self::$V1AUDITS; - } - public static function V1MAILS(): HealthQueueName - { - if (!isset(self::$V1MAILS)) { - self::$V1MAILS = new HealthQueueName('v1-mails'); - } - return self::$V1MAILS; - } - public static function V1FUNCTIONS(): HealthQueueName - { - if (!isset(self::$V1FUNCTIONS)) { - self::$V1FUNCTIONS = new HealthQueueName('v1-functions'); - } - return self::$V1FUNCTIONS; - } - public static function V1STATSRESOURCES(): HealthQueueName - { - if (!isset(self::$V1STATSRESOURCES)) { - self::$V1STATSRESOURCES = new HealthQueueName('v1-stats-resources'); - } - return self::$V1STATSRESOURCES; - } - public static function V1STATSUSAGE(): HealthQueueName - { - if (!isset(self::$V1STATSUSAGE)) { - self::$V1STATSUSAGE = new HealthQueueName('v1-stats-usage'); - } - return self::$V1STATSUSAGE; - } - public static function V1WEBHOOKS(): HealthQueueName - { - if (!isset(self::$V1WEBHOOKS)) { - self::$V1WEBHOOKS = new HealthQueueName('v1-webhooks'); - } - return self::$V1WEBHOOKS; - } - public static function V1CERTIFICATES(): HealthQueueName - { - if (!isset(self::$V1CERTIFICATES)) { - self::$V1CERTIFICATES = new HealthQueueName('v1-certificates'); - } - return self::$V1CERTIFICATES; - } - public static function V1BUILDS(): HealthQueueName - { - if (!isset(self::$V1BUILDS)) { - self::$V1BUILDS = new HealthQueueName('v1-builds'); - } - return self::$V1BUILDS; - } - public static function V1SCREENSHOTS(): HealthQueueName - { - if (!isset(self::$V1SCREENSHOTS)) { - self::$V1SCREENSHOTS = new HealthQueueName('v1-screenshots'); - } - return self::$V1SCREENSHOTS; - } - public static function V1MESSAGING(): HealthQueueName - { - if (!isset(self::$V1MESSAGING)) { - self::$V1MESSAGING = new HealthQueueName('v1-messaging'); - } - return self::$V1MESSAGING; - } - public static function V1MIGRATIONS(): HealthQueueName - { - if (!isset(self::$V1MIGRATIONS)) { - self::$V1MIGRATIONS = new HealthQueueName('v1-migrations'); - } - return self::$V1MIGRATIONS; - } - - public static function from(string $value): self - { - return match ($value) { - 'v1-database' => self::V1DATABASE(), - 'v1-deletes' => self::V1DELETES(), - 'v1-audits' => self::V1AUDITS(), - 'v1-mails' => self::V1MAILS(), - 'v1-functions' => self::V1FUNCTIONS(), - 'v1-stats-resources' => self::V1STATSRESOURCES(), - 'v1-stats-usage' => self::V1STATSUSAGE(), - 'v1-webhooks' => self::V1WEBHOOKS(), - 'v1-certificates' => self::V1CERTIFICATES(), - 'v1-builds' => self::V1BUILDS(), - 'v1-screenshots' => self::V1SCREENSHOTS(), - 'v1-messaging' => self::V1MESSAGING(), - 'v1-migrations' => self::V1MIGRATIONS(), - default => throw new \InvalidArgumentException('Unknown HealthQueueName value: ' . $value), - }; - } -} diff --git a/src/Appwrite/Enums/OAuth2OidcPrompt.php b/src/Appwrite/Enums/OAuth2OidcPrompt.php new file mode 100644 index 00000000..bbdad5ad --- /dev/null +++ b/src/Appwrite/Enums/OAuth2OidcPrompt.php @@ -0,0 +1,70 @@ +value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function NONE(): OAuth2OidcPrompt + { + if (!isset(self::$NONE)) { + self::$NONE = new OAuth2OidcPrompt('none'); + } + return self::$NONE; + } + public static function LOGIN(): OAuth2OidcPrompt + { + if (!isset(self::$LOGIN)) { + self::$LOGIN = new OAuth2OidcPrompt('login'); + } + return self::$LOGIN; + } + public static function CONSENT(): OAuth2OidcPrompt + { + if (!isset(self::$CONSENT)) { + self::$CONSENT = new OAuth2OidcPrompt('consent'); + } + return self::$CONSENT; + } + public static function SELECTACCOUNT(): OAuth2OidcPrompt + { + if (!isset(self::$SELECTACCOUNT)) { + self::$SELECTACCOUNT = new OAuth2OidcPrompt('select_account'); + } + return self::$SELECTACCOUNT; + } + + public static function from(string $value): self + { + return match ($value) { + 'none' => self::NONE(), + 'login' => self::LOGIN(), + 'consent' => self::CONSENT(), + 'select_account' => self::SELECTACCOUNT(), + default => throw new \InvalidArgumentException('Unknown OAuth2OidcPrompt value: ' . $value), + }; + } +} diff --git a/src/Appwrite/Enums/OAuthProvider.php b/src/Appwrite/Enums/OAuthProvider.php index 4763c082..decb1d46 100644 --- a/src/Appwrite/Enums/OAuthProvider.php +++ b/src/Appwrite/Enums/OAuthProvider.php @@ -8,6 +8,7 @@ class OAuthProvider implements JsonSerializable { private static OAuthProvider $AMAZON; private static OAuthProvider $APPLE; + private static OAuthProvider $APPWRITE; private static OAuthProvider $AUTH0; private static OAuthProvider $AUTHENTIK; private static OAuthProvider $AUTODESK; @@ -81,6 +82,13 @@ public static function APPLE(): OAuthProvider } return self::$APPLE; } + public static function APPWRITE(): OAuthProvider + { + if (!isset(self::$APPWRITE)) { + self::$APPWRITE = new OAuthProvider('appwrite'); + } + return self::$APPWRITE; + } public static function AUTH0(): OAuthProvider { if (!isset(self::$AUTH0)) { @@ -374,6 +382,7 @@ public static function from(string $value): self return match ($value) { 'amazon' => self::AMAZON(), 'apple' => self::APPLE(), + 'appwrite' => self::APPWRITE(), 'auth0' => self::AUTH0(), 'authentik' => self::AUTHENTIK(), 'autodesk' => self::AUTODESK(), diff --git a/src/Appwrite/Enums/OrganizationKeyScopes.php b/src/Appwrite/Enums/OrganizationKeyScopes.php index b013d0f2..7bf3987f 100644 --- a/src/Appwrite/Enums/OrganizationKeyScopes.php +++ b/src/Appwrite/Enums/OrganizationKeyScopes.php @@ -12,6 +12,10 @@ class OrganizationKeyScopes implements JsonSerializable private static OrganizationKeyScopes $DEVKEYSWRITE; private static OrganizationKeyScopes $ORGANIZATIONKEYSREAD; private static OrganizationKeyScopes $ORGANIZATIONKEYSWRITE; + private static OrganizationKeyScopes $ORGANIZATIONMEMBERSHIPSREAD; + private static OrganizationKeyScopes $ORGANIZATIONMEMBERSHIPSWRITE; + private static OrganizationKeyScopes $ORGANIZATIONREAD; + private static OrganizationKeyScopes $ORGANIZATIONWRITE; private static OrganizationKeyScopes $DOMAINSREAD; private static OrganizationKeyScopes $DOMAINSWRITE; private static OrganizationKeyScopes $KEYSREAD; @@ -76,6 +80,34 @@ public static function ORGANIZATIONKEYSWRITE(): OrganizationKeyScopes } return self::$ORGANIZATIONKEYSWRITE; } + public static function ORGANIZATIONMEMBERSHIPSREAD(): OrganizationKeyScopes + { + if (!isset(self::$ORGANIZATIONMEMBERSHIPSREAD)) { + self::$ORGANIZATIONMEMBERSHIPSREAD = new OrganizationKeyScopes('organization.memberships.read'); + } + return self::$ORGANIZATIONMEMBERSHIPSREAD; + } + public static function ORGANIZATIONMEMBERSHIPSWRITE(): OrganizationKeyScopes + { + if (!isset(self::$ORGANIZATIONMEMBERSHIPSWRITE)) { + self::$ORGANIZATIONMEMBERSHIPSWRITE = new OrganizationKeyScopes('organization.memberships.write'); + } + return self::$ORGANIZATIONMEMBERSHIPSWRITE; + } + public static function ORGANIZATIONREAD(): OrganizationKeyScopes + { + if (!isset(self::$ORGANIZATIONREAD)) { + self::$ORGANIZATIONREAD = new OrganizationKeyScopes('organization.read'); + } + return self::$ORGANIZATIONREAD; + } + public static function ORGANIZATIONWRITE(): OrganizationKeyScopes + { + if (!isset(self::$ORGANIZATIONWRITE)) { + self::$ORGANIZATIONWRITE = new OrganizationKeyScopes('organization.write'); + } + return self::$ORGANIZATIONWRITE; + } public static function DOMAINSREAD(): OrganizationKeyScopes { if (!isset(self::$DOMAINSREAD)) { @@ -114,6 +146,10 @@ public static function from(string $value): self 'devKeys.write' => self::DEVKEYSWRITE(), 'organization.keys.read' => self::ORGANIZATIONKEYSREAD(), 'organization.keys.write' => self::ORGANIZATIONKEYSWRITE(), + 'organization.memberships.read' => self::ORGANIZATIONMEMBERSHIPSREAD(), + 'organization.memberships.write' => self::ORGANIZATIONMEMBERSHIPSWRITE(), + 'organization.read' => self::ORGANIZATIONREAD(), + 'organization.write' => self::ORGANIZATIONWRITE(), 'domains.read' => self::DOMAINSREAD(), 'domains.write' => self::DOMAINSWRITE(), 'keys.read' => self::KEYSREAD(), diff --git a/src/Appwrite/Enums/ProjectKeyScopes.php b/src/Appwrite/Enums/ProjectKeyScopes.php index 2c78383f..c087a037 100644 --- a/src/Appwrite/Enums/ProjectKeyScopes.php +++ b/src/Appwrite/Enums/ProjectKeyScopes.php @@ -18,10 +18,12 @@ class ProjectKeyScopes implements JsonSerializable private static ProjectKeyScopes $POLICIESWRITE; private static ProjectKeyScopes $PROJECTPOLICIESREAD; private static ProjectKeyScopes $PROJECTPOLICIESWRITE; + private static ProjectKeyScopes $PROJECTOAUTH2READ; + private static ProjectKeyScopes $PROJECTOAUTH2WRITE; private static ProjectKeyScopes $TEMPLATESREAD; private static ProjectKeyScopes $TEMPLATESWRITE; - private static ProjectKeyScopes $OAUTH2READ; - private static ProjectKeyScopes $OAUTH2WRITE; + private static ProjectKeyScopes $STAGESREAD; + private static ProjectKeyScopes $STAGESWRITE; private static ProjectKeyScopes $USERSREAD; private static ProjectKeyScopes $USERSWRITE; private static ProjectKeyScopes $SESSIONSREAD; @@ -102,6 +104,8 @@ class ProjectKeyScopes implements JsonSerializable private static ProjectKeyScopes $EVENTSREAD; private static ProjectKeyScopes $APPSREAD; private static ProjectKeyScopes $APPSWRITE; + private static ProjectKeyScopes $OAUTH2READ; + private static ProjectKeyScopes $OAUTH2WRITE; private static ProjectKeyScopes $USAGEREAD; private string $value; @@ -205,6 +209,20 @@ public static function PROJECTPOLICIESWRITE(): ProjectKeyScopes } return self::$PROJECTPOLICIESWRITE; } + public static function PROJECTOAUTH2READ(): ProjectKeyScopes + { + if (!isset(self::$PROJECTOAUTH2READ)) { + self::$PROJECTOAUTH2READ = new ProjectKeyScopes('project.oauth2.read'); + } + return self::$PROJECTOAUTH2READ; + } + public static function PROJECTOAUTH2WRITE(): ProjectKeyScopes + { + if (!isset(self::$PROJECTOAUTH2WRITE)) { + self::$PROJECTOAUTH2WRITE = new ProjectKeyScopes('project.oauth2.write'); + } + return self::$PROJECTOAUTH2WRITE; + } public static function TEMPLATESREAD(): ProjectKeyScopes { if (!isset(self::$TEMPLATESREAD)) { @@ -219,19 +237,19 @@ public static function TEMPLATESWRITE(): ProjectKeyScopes } return self::$TEMPLATESWRITE; } - public static function OAUTH2READ(): ProjectKeyScopes + public static function STAGESREAD(): ProjectKeyScopes { - if (!isset(self::$OAUTH2READ)) { - self::$OAUTH2READ = new ProjectKeyScopes('oauth2.read'); + if (!isset(self::$STAGESREAD)) { + self::$STAGESREAD = new ProjectKeyScopes('stages.read'); } - return self::$OAUTH2READ; + return self::$STAGESREAD; } - public static function OAUTH2WRITE(): ProjectKeyScopes + public static function STAGESWRITE(): ProjectKeyScopes { - if (!isset(self::$OAUTH2WRITE)) { - self::$OAUTH2WRITE = new ProjectKeyScopes('oauth2.write'); + if (!isset(self::$STAGESWRITE)) { + self::$STAGESWRITE = new ProjectKeyScopes('stages.write'); } - return self::$OAUTH2WRITE; + return self::$STAGESWRITE; } public static function USERSREAD(): ProjectKeyScopes { @@ -793,6 +811,20 @@ public static function APPSWRITE(): ProjectKeyScopes } return self::$APPSWRITE; } + public static function OAUTH2READ(): ProjectKeyScopes + { + if (!isset(self::$OAUTH2READ)) { + self::$OAUTH2READ = new ProjectKeyScopes('oauth2.read'); + } + return self::$OAUTH2READ; + } + public static function OAUTH2WRITE(): ProjectKeyScopes + { + if (!isset(self::$OAUTH2WRITE)) { + self::$OAUTH2WRITE = new ProjectKeyScopes('oauth2.write'); + } + return self::$OAUTH2WRITE; + } public static function USAGEREAD(): ProjectKeyScopes { if (!isset(self::$USAGEREAD)) { @@ -816,10 +848,12 @@ public static function from(string $value): self 'policies.write' => self::POLICIESWRITE(), 'project.policies.read' => self::PROJECTPOLICIESREAD(), 'project.policies.write' => self::PROJECTPOLICIESWRITE(), + 'project.oauth2.read' => self::PROJECTOAUTH2READ(), + 'project.oauth2.write' => self::PROJECTOAUTH2WRITE(), 'templates.read' => self::TEMPLATESREAD(), 'templates.write' => self::TEMPLATESWRITE(), - 'oauth2.read' => self::OAUTH2READ(), - 'oauth2.write' => self::OAUTH2WRITE(), + 'stages.read' => self::STAGESREAD(), + 'stages.write' => self::STAGESWRITE(), 'users.read' => self::USERSREAD(), 'users.write' => self::USERSWRITE(), 'sessions.read' => self::SESSIONSREAD(), @@ -900,6 +934,8 @@ public static function from(string $value): self 'events.read' => self::EVENTSREAD(), 'apps.read' => self::APPSREAD(), 'apps.write' => self::APPSWRITE(), + 'oauth2.read' => self::OAUTH2READ(), + 'oauth2.write' => self::OAUTH2WRITE(), 'usage.read' => self::USAGEREAD(), default => throw new \InvalidArgumentException('Unknown ProjectKeyScopes value: ' . $value), }; diff --git a/src/Appwrite/Enums/ProjectOAuth2OidcPrompt.php b/src/Appwrite/Enums/ProjectOAuth2OidcPrompt.php new file mode 100644 index 00000000..867ee098 --- /dev/null +++ b/src/Appwrite/Enums/ProjectOAuth2OidcPrompt.php @@ -0,0 +1,70 @@ +value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function NONE(): ProjectOAuth2OidcPrompt + { + if (!isset(self::$NONE)) { + self::$NONE = new ProjectOAuth2OidcPrompt('none'); + } + return self::$NONE; + } + public static function LOGIN(): ProjectOAuth2OidcPrompt + { + if (!isset(self::$LOGIN)) { + self::$LOGIN = new ProjectOAuth2OidcPrompt('login'); + } + return self::$LOGIN; + } + public static function CONSENT(): ProjectOAuth2OidcPrompt + { + if (!isset(self::$CONSENT)) { + self::$CONSENT = new ProjectOAuth2OidcPrompt('consent'); + } + return self::$CONSENT; + } + public static function SELECTACCOUNT(): ProjectOAuth2OidcPrompt + { + if (!isset(self::$SELECTACCOUNT)) { + self::$SELECTACCOUNT = new ProjectOAuth2OidcPrompt('select_account'); + } + return self::$SELECTACCOUNT; + } + + public static function from(string $value): self + { + return match ($value) { + 'none' => self::NONE(), + 'login' => self::LOGIN(), + 'consent' => self::CONSENT(), + 'select_account' => self::SELECTACCOUNT(), + default => throw new \InvalidArgumentException('Unknown ProjectOAuth2OidcPrompt value: ' . $value), + }; + } +} diff --git a/src/Appwrite/Enums/ProjectOAuthProviderId.php b/src/Appwrite/Enums/ProjectOAuthProviderId.php index a9325a75..7f697114 100644 --- a/src/Appwrite/Enums/ProjectOAuthProviderId.php +++ b/src/Appwrite/Enums/ProjectOAuthProviderId.php @@ -8,6 +8,7 @@ class ProjectOAuthProviderId implements JsonSerializable { private static ProjectOAuthProviderId $AMAZON; private static ProjectOAuthProviderId $APPLE; + private static ProjectOAuthProviderId $APPWRITE; private static ProjectOAuthProviderId $AUTH0; private static ProjectOAuthProviderId $AUTHENTIK; private static ProjectOAuthProviderId $AUTODESK; @@ -81,6 +82,13 @@ public static function APPLE(): ProjectOAuthProviderId } return self::$APPLE; } + public static function APPWRITE(): ProjectOAuthProviderId + { + if (!isset(self::$APPWRITE)) { + self::$APPWRITE = new ProjectOAuthProviderId('appwrite'); + } + return self::$APPWRITE; + } public static function AUTH0(): ProjectOAuthProviderId { if (!isset(self::$AUTH0)) { @@ -374,6 +382,7 @@ public static function from(string $value): self return match ($value) { 'amazon' => self::AMAZON(), 'apple' => self::APPLE(), + 'appwrite' => self::APPWRITE(), 'auth0' => self::AUTH0(), 'authentik' => self::AUTHENTIK(), 'autodesk' => self::AUTODESK(), diff --git a/src/Appwrite/Models/ActivityEvent.php b/src/Appwrite/Models/ActivityEvent.php index 287011dd..5c6429ab 100644 --- a/src/Appwrite/Models/ActivityEvent.php +++ b/src/Appwrite/Models/ActivityEvent.php @@ -30,8 +30,6 @@ * @param string $projectId project id. * @param string $teamId team id. * @param string $hostname hostname. - * @param string $countryCode country two-character iso 3166-1 alpha code. - * @param string $countryName country name. */ public function __construct( public string $id, @@ -51,9 +49,7 @@ public function __construct( public string $time, public string $projectId, public string $teamId, - public string $hostname, - public string $countryCode, - public string $countryName + public string $hostname ) { } @@ -116,12 +112,6 @@ public static function from(array $data): static if (!array_key_exists('hostname', $data)) { throw new \InvalidArgumentException('Missing required field "hostname" for ' . static::class . '.'); } - if (!array_key_exists('countryCode', $data)) { - throw new \InvalidArgumentException('Missing required field "countryCode" for ' . static::class . '.'); - } - if (!array_key_exists('countryName', $data)) { - throw new \InvalidArgumentException('Missing required field "countryName" for ' . static::class . '.'); - } return new static( id: $data['$id'], @@ -141,9 +131,7 @@ public static function from(array $data): static time: $data['time'], projectId: $data['projectId'], teamId: $data['teamId'], - hostname: $data['hostname'], - countryCode: $data['countryCode'], - countryName: $data['countryName'] + hostname: $data['hostname'] ); } @@ -170,9 +158,7 @@ public function toArray(): array 'time' => static::serializeValue($this->time), 'projectId' => static::serializeValue($this->projectId), 'teamId' => static::serializeValue($this->teamId), - 'hostname' => static::serializeValue($this->hostname), - 'countryCode' => static::serializeValue($this->countryCode), - 'countryName' => static::serializeValue($this->countryName) + 'hostname' => static::serializeValue($this->hostname) ]; return $result; diff --git a/src/Appwrite/Models/AdditionalResource.php b/src/Appwrite/Models/AdditionalResource.php new file mode 100644 index 00000000..22ccf01a --- /dev/null +++ b/src/Appwrite/Models/AdditionalResource.php @@ -0,0 +1,82 @@ + $data + */ + public static function from(array $data): static + { + if (!array_key_exists('name', $data)) { + throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); + } + if (!array_key_exists('unit', $data)) { + throw new \InvalidArgumentException('Missing required field "unit" for ' . static::class . '.'); + } + if (!array_key_exists('currency', $data)) { + throw new \InvalidArgumentException('Missing required field "currency" for ' . static::class . '.'); + } + if (!array_key_exists('price', $data)) { + throw new \InvalidArgumentException('Missing required field "price" for ' . static::class . '.'); + } + if (!array_key_exists('value', $data)) { + throw new \InvalidArgumentException('Missing required field "value" for ' . static::class . '.'); + } + if (!array_key_exists('invoiceDesc', $data)) { + throw new \InvalidArgumentException('Missing required field "invoiceDesc" for ' . static::class . '.'); + } + + return new static( + name: $data['name'], + unit: $data['unit'], + currency: $data['currency'], + price: $data['price'], + value: $data['value'], + invoiceDesc: $data['invoiceDesc'] + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + 'name' => static::serializeValue($this->name), + 'unit' => static::serializeValue($this->unit), + 'currency' => static::serializeValue($this->currency), + 'price' => static::serializeValue($this->price), + 'value' => static::serializeValue($this->value), + 'invoiceDesc' => static::serializeValue($this->invoiceDesc) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/BillingPlan.php b/src/Appwrite/Models/BillingPlan.php new file mode 100644 index 00000000..dcfd652e --- /dev/null +++ b/src/Appwrite/Models/BillingPlan.php @@ -0,0 +1,506 @@ + $data + */ + public static function from(array $data): static + { + if (!array_key_exists('$id', $data)) { + throw new \InvalidArgumentException('Missing required field "$id" for ' . static::class . '.'); + } + if (!array_key_exists('name', $data)) { + throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); + } + if (!array_key_exists('desc', $data)) { + throw new \InvalidArgumentException('Missing required field "desc" for ' . static::class . '.'); + } + if (!array_key_exists('order', $data)) { + throw new \InvalidArgumentException('Missing required field "order" for ' . static::class . '.'); + } + if (!array_key_exists('price', $data)) { + throw new \InvalidArgumentException('Missing required field "price" for ' . static::class . '.'); + } + if (!array_key_exists('trial', $data)) { + throw new \InvalidArgumentException('Missing required field "trial" for ' . static::class . '.'); + } + if (!array_key_exists('bandwidth', $data)) { + throw new \InvalidArgumentException('Missing required field "bandwidth" for ' . static::class . '.'); + } + if (!array_key_exists('storage', $data)) { + throw new \InvalidArgumentException('Missing required field "storage" for ' . static::class . '.'); + } + if (!array_key_exists('imageTransformations', $data)) { + throw new \InvalidArgumentException('Missing required field "imageTransformations" for ' . static::class . '.'); + } + if (!array_key_exists('screenshotsGenerated', $data)) { + throw new \InvalidArgumentException('Missing required field "screenshotsGenerated" for ' . static::class . '.'); + } + if (!array_key_exists('members', $data)) { + throw new \InvalidArgumentException('Missing required field "members" for ' . static::class . '.'); + } + if (!array_key_exists('webhooks', $data)) { + throw new \InvalidArgumentException('Missing required field "webhooks" for ' . static::class . '.'); + } + if (!array_key_exists('projects', $data)) { + throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); + } + if (!array_key_exists('platforms', $data)) { + throw new \InvalidArgumentException('Missing required field "platforms" for ' . static::class . '.'); + } + if (!array_key_exists('users', $data)) { + throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); + } + if (!array_key_exists('teams', $data)) { + throw new \InvalidArgumentException('Missing required field "teams" for ' . static::class . '.'); + } + if (!array_key_exists('databases', $data)) { + throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); + } + if (!array_key_exists('databasesReads', $data)) { + throw new \InvalidArgumentException('Missing required field "databasesReads" for ' . static::class . '.'); + } + if (!array_key_exists('databasesWrites', $data)) { + throw new \InvalidArgumentException('Missing required field "databasesWrites" for ' . static::class . '.'); + } + if (!array_key_exists('databasesBatchSize', $data)) { + throw new \InvalidArgumentException('Missing required field "databasesBatchSize" for ' . static::class . '.'); + } + if (!array_key_exists('buckets', $data)) { + throw new \InvalidArgumentException('Missing required field "buckets" for ' . static::class . '.'); + } + if (!array_key_exists('fileSize', $data)) { + throw new \InvalidArgumentException('Missing required field "fileSize" for ' . static::class . '.'); + } + if (!array_key_exists('functions', $data)) { + throw new \InvalidArgumentException('Missing required field "functions" for ' . static::class . '.'); + } + if (!array_key_exists('sites', $data)) { + throw new \InvalidArgumentException('Missing required field "sites" for ' . static::class . '.'); + } + if (!array_key_exists('executions', $data)) { + throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.'); + } + if (!array_key_exists('executionsRetentionCount', $data)) { + throw new \InvalidArgumentException('Missing required field "executionsRetentionCount" for ' . static::class . '.'); + } + if (!array_key_exists('GBHours', $data)) { + throw new \InvalidArgumentException('Missing required field "GBHours" for ' . static::class . '.'); + } + if (!array_key_exists('realtime', $data)) { + throw new \InvalidArgumentException('Missing required field "realtime" for ' . static::class . '.'); + } + if (!array_key_exists('realtimeMessages', $data)) { + throw new \InvalidArgumentException('Missing required field "realtimeMessages" for ' . static::class . '.'); + } + if (!array_key_exists('messages', $data)) { + throw new \InvalidArgumentException('Missing required field "messages" for ' . static::class . '.'); + } + if (!array_key_exists('topics', $data)) { + throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); + } + if (!array_key_exists('authPhone', $data)) { + throw new \InvalidArgumentException('Missing required field "authPhone" for ' . static::class . '.'); + } + if (!array_key_exists('domains', $data)) { + throw new \InvalidArgumentException('Missing required field "domains" for ' . static::class . '.'); + } + if (!array_key_exists('activityLogs', $data)) { + throw new \InvalidArgumentException('Missing required field "activityLogs" for ' . static::class . '.'); + } + if (!array_key_exists('usageLogs', $data)) { + throw new \InvalidArgumentException('Missing required field "usageLogs" for ' . static::class . '.'); + } + if (!array_key_exists('projectInactivityDays', $data)) { + throw new \InvalidArgumentException('Missing required field "projectInactivityDays" for ' . static::class . '.'); + } + if (!array_key_exists('alertLimit', $data)) { + throw new \InvalidArgumentException('Missing required field "alertLimit" for ' . static::class . '.'); + } + if (!array_key_exists('usage', $data)) { + throw new \InvalidArgumentException('Missing required field "usage" for ' . static::class . '.'); + } + if (!array_key_exists('addons', $data)) { + throw new \InvalidArgumentException('Missing required field "addons" for ' . static::class . '.'); + } + if (!array_key_exists('budgetCapEnabled', $data)) { + throw new \InvalidArgumentException('Missing required field "budgetCapEnabled" for ' . static::class . '.'); + } + if (!array_key_exists('customSmtp', $data)) { + throw new \InvalidArgumentException('Missing required field "customSmtp" for ' . static::class . '.'); + } + if (!array_key_exists('emailBranding', $data)) { + throw new \InvalidArgumentException('Missing required field "emailBranding" for ' . static::class . '.'); + } + if (!array_key_exists('requiresPaymentMethod', $data)) { + throw new \InvalidArgumentException('Missing required field "requiresPaymentMethod" for ' . static::class . '.'); + } + if (!array_key_exists('requiresBillingAddress', $data)) { + throw new \InvalidArgumentException('Missing required field "requiresBillingAddress" for ' . static::class . '.'); + } + if (!array_key_exists('isAvailable', $data)) { + throw new \InvalidArgumentException('Missing required field "isAvailable" for ' . static::class . '.'); + } + if (!array_key_exists('selfService', $data)) { + throw new \InvalidArgumentException('Missing required field "selfService" for ' . static::class . '.'); + } + if (!array_key_exists('premiumSupport', $data)) { + throw new \InvalidArgumentException('Missing required field "premiumSupport" for ' . static::class . '.'); + } + if (!array_key_exists('budgeting', $data)) { + throw new \InvalidArgumentException('Missing required field "budgeting" for ' . static::class . '.'); + } + if (!array_key_exists('supportsMockNumbers', $data)) { + throw new \InvalidArgumentException('Missing required field "supportsMockNumbers" for ' . static::class . '.'); + } + if (!array_key_exists('supportsOrganizationRoles', $data)) { + throw new \InvalidArgumentException('Missing required field "supportsOrganizationRoles" for ' . static::class . '.'); + } + if (!array_key_exists('supportsCredits', $data)) { + throw new \InvalidArgumentException('Missing required field "supportsCredits" for ' . static::class . '.'); + } + if (!array_key_exists('supportsDisposableEmailValidation', $data)) { + throw new \InvalidArgumentException('Missing required field "supportsDisposableEmailValidation" for ' . static::class . '.'); + } + if (!array_key_exists('supportsCanonicalEmailValidation', $data)) { + throw new \InvalidArgumentException('Missing required field "supportsCanonicalEmailValidation" for ' . static::class . '.'); + } + if (!array_key_exists('supportsFreeEmailValidation', $data)) { + throw new \InvalidArgumentException('Missing required field "supportsFreeEmailValidation" for ' . static::class . '.'); + } + if (!array_key_exists('supportsCorporateEmailValidation', $data)) { + throw new \InvalidArgumentException('Missing required field "supportsCorporateEmailValidation" for ' . static::class . '.'); + } + if (!array_key_exists('supportsProjectSpecificRoles', $data)) { + throw new \InvalidArgumentException('Missing required field "supportsProjectSpecificRoles" for ' . static::class . '.'); + } + if (!array_key_exists('backupsEnabled', $data)) { + throw new \InvalidArgumentException('Missing required field "backupsEnabled" for ' . static::class . '.'); + } + if (!array_key_exists('usagePerProject', $data)) { + throw new \InvalidArgumentException('Missing required field "usagePerProject" for ' . static::class . '.'); + } + if (!array_key_exists('supportedAddons', $data)) { + throw new \InvalidArgumentException('Missing required field "supportedAddons" for ' . static::class . '.'); + } + if (!array_key_exists('backupPolicies', $data)) { + throw new \InvalidArgumentException('Missing required field "backupPolicies" for ' . static::class . '.'); + } + if (!array_key_exists('deploymentSize', $data)) { + throw new \InvalidArgumentException('Missing required field "deploymentSize" for ' . static::class . '.'); + } + if (!array_key_exists('buildSize', $data)) { + throw new \InvalidArgumentException('Missing required field "buildSize" for ' . static::class . '.'); + } + if (!array_key_exists('databasesAllowEncrypt', $data)) { + throw new \InvalidArgumentException('Missing required field "databasesAllowEncrypt" for ' . static::class . '.'); + } + if (!array_key_exists('group', $data)) { + throw new \InvalidArgumentException('Missing required field "group" for ' . static::class . '.'); + } + + return new static( + id: $data['$id'], + name: $data['name'], + desc: $data['desc'], + order: $data['order'], + price: $data['price'], + trial: $data['trial'], + bandwidth: $data['bandwidth'], + storage: $data['storage'], + imageTransformations: $data['imageTransformations'], + screenshotsGenerated: $data['screenshotsGenerated'], + members: $data['members'], + webhooks: $data['webhooks'], + projects: $data['projects'], + platforms: $data['platforms'], + users: $data['users'], + teams: $data['teams'], + databases: $data['databases'], + databasesReads: $data['databasesReads'], + databasesWrites: $data['databasesWrites'], + databasesBatchSize: $data['databasesBatchSize'], + buckets: $data['buckets'], + fileSize: $data['fileSize'], + functions: $data['functions'], + sites: $data['sites'], + executions: $data['executions'], + executionsRetentionCount: $data['executionsRetentionCount'], + gBHours: $data['GBHours'], + realtime: $data['realtime'], + realtimeMessages: $data['realtimeMessages'], + messages: $data['messages'], + topics: $data['topics'], + authPhone: $data['authPhone'], + domains: $data['domains'], + activityLogs: $data['activityLogs'], + usageLogs: $data['usageLogs'], + projectInactivityDays: $data['projectInactivityDays'], + alertLimit: $data['alertLimit'], + usage: static::hydrateTypedValue(UsageBillingPlan::class, $data['usage']), + addons: static::hydrateTypedValue(BillingPlanAddon::class, $data['addons']), + budgetCapEnabled: $data['budgetCapEnabled'], + customSmtp: $data['customSmtp'], + emailBranding: $data['emailBranding'], + requiresPaymentMethod: $data['requiresPaymentMethod'], + requiresBillingAddress: $data['requiresBillingAddress'], + isAvailable: $data['isAvailable'], + selfService: $data['selfService'], + premiumSupport: $data['premiumSupport'], + budgeting: $data['budgeting'], + supportsMockNumbers: $data['supportsMockNumbers'], + supportsOrganizationRoles: $data['supportsOrganizationRoles'], + supportsCredits: $data['supportsCredits'], + supportsDisposableEmailValidation: $data['supportsDisposableEmailValidation'], + supportsCanonicalEmailValidation: $data['supportsCanonicalEmailValidation'], + supportsFreeEmailValidation: $data['supportsFreeEmailValidation'], + supportsCorporateEmailValidation: $data['supportsCorporateEmailValidation'], + supportsProjectSpecificRoles: $data['supportsProjectSpecificRoles'], + backupsEnabled: $data['backupsEnabled'], + usagePerProject: $data['usagePerProject'], + supportedAddons: static::hydrateTypedValue(BillingPlanSupportedAddons::class, $data['supportedAddons']), + backupPolicies: $data['backupPolicies'], + deploymentSize: $data['deploymentSize'], + buildSize: $data['buildSize'], + databasesAllowEncrypt: $data['databasesAllowEncrypt'], + group: static::hydrateTypedValue(BillingPlanGroup::class, $data['group']), + usageLogsIntervals: array_key_exists('usageLogsIntervals', $data) ? $data['usageLogsIntervals'] : null, + limits: array_key_exists('limits', $data) ? static::hydrateTypedValue(BillingPlanLimits::class, $data['limits'], true) : null, + program: array_key_exists('program', $data) ? static::hydrateTypedValue(Program::class, $data['program'], true) : null, + dedicatedDatabases: array_key_exists('dedicatedDatabases', $data) ? static::hydrateTypedValue(BillingPlanDedicatedDatabaseLimits::class, $data['dedicatedDatabases'], true) : null + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + '$id' => static::serializeValue($this->id), + 'name' => static::serializeValue($this->name), + 'desc' => static::serializeValue($this->desc), + 'order' => static::serializeValue($this->order), + 'price' => static::serializeValue($this->price), + 'trial' => static::serializeValue($this->trial), + 'bandwidth' => static::serializeValue($this->bandwidth), + 'storage' => static::serializeValue($this->storage), + 'imageTransformations' => static::serializeValue($this->imageTransformations), + 'screenshotsGenerated' => static::serializeValue($this->screenshotsGenerated), + 'members' => static::serializeValue($this->members), + 'webhooks' => static::serializeValue($this->webhooks), + 'projects' => static::serializeValue($this->projects), + 'platforms' => static::serializeValue($this->platforms), + 'users' => static::serializeValue($this->users), + 'teams' => static::serializeValue($this->teams), + 'databases' => static::serializeValue($this->databases), + 'databasesReads' => static::serializeValue($this->databasesReads), + 'databasesWrites' => static::serializeValue($this->databasesWrites), + 'databasesBatchSize' => static::serializeValue($this->databasesBatchSize), + 'buckets' => static::serializeValue($this->buckets), + 'fileSize' => static::serializeValue($this->fileSize), + 'functions' => static::serializeValue($this->functions), + 'sites' => static::serializeValue($this->sites), + 'executions' => static::serializeValue($this->executions), + 'executionsRetentionCount' => static::serializeValue($this->executionsRetentionCount), + 'GBHours' => static::serializeValue($this->gBHours), + 'realtime' => static::serializeValue($this->realtime), + 'realtimeMessages' => static::serializeValue($this->realtimeMessages), + 'messages' => static::serializeValue($this->messages), + 'topics' => static::serializeValue($this->topics), + 'authPhone' => static::serializeValue($this->authPhone), + 'domains' => static::serializeValue($this->domains), + 'activityLogs' => static::serializeValue($this->activityLogs), + 'usageLogs' => static::serializeValue($this->usageLogs), + 'usageLogsIntervals' => static::serializeValue($this->usageLogsIntervals), + 'projectInactivityDays' => static::serializeValue($this->projectInactivityDays), + 'alertLimit' => static::serializeValue($this->alertLimit), + 'usage' => static::serializeValue($this->usage), + 'addons' => static::serializeValue($this->addons), + 'budgetCapEnabled' => static::serializeValue($this->budgetCapEnabled), + 'customSmtp' => static::serializeValue($this->customSmtp), + 'emailBranding' => static::serializeValue($this->emailBranding), + 'requiresPaymentMethod' => static::serializeValue($this->requiresPaymentMethod), + 'requiresBillingAddress' => static::serializeValue($this->requiresBillingAddress), + 'isAvailable' => static::serializeValue($this->isAvailable), + 'selfService' => static::serializeValue($this->selfService), + 'premiumSupport' => static::serializeValue($this->premiumSupport), + 'budgeting' => static::serializeValue($this->budgeting), + 'supportsMockNumbers' => static::serializeValue($this->supportsMockNumbers), + 'supportsOrganizationRoles' => static::serializeValue($this->supportsOrganizationRoles), + 'supportsCredits' => static::serializeValue($this->supportsCredits), + 'supportsDisposableEmailValidation' => static::serializeValue($this->supportsDisposableEmailValidation), + 'supportsCanonicalEmailValidation' => static::serializeValue($this->supportsCanonicalEmailValidation), + 'supportsFreeEmailValidation' => static::serializeValue($this->supportsFreeEmailValidation), + 'supportsCorporateEmailValidation' => static::serializeValue($this->supportsCorporateEmailValidation), + 'supportsProjectSpecificRoles' => static::serializeValue($this->supportsProjectSpecificRoles), + 'backupsEnabled' => static::serializeValue($this->backupsEnabled), + 'usagePerProject' => static::serializeValue($this->usagePerProject), + 'supportedAddons' => static::serializeValue($this->supportedAddons), + 'backupPolicies' => static::serializeValue($this->backupPolicies), + 'deploymentSize' => static::serializeValue($this->deploymentSize), + 'buildSize' => static::serializeValue($this->buildSize), + 'databasesAllowEncrypt' => static::serializeValue($this->databasesAllowEncrypt), + 'limits' => static::serializeValue($this->limits), + 'group' => static::serializeValue($this->group), + 'program' => static::serializeValue($this->program), + 'dedicatedDatabases' => static::serializeValue($this->dedicatedDatabases) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/BillingPlanAddon.php b/src/Appwrite/Models/BillingPlanAddon.php new file mode 100644 index 00000000..7e79ea14 --- /dev/null +++ b/src/Appwrite/Models/BillingPlanAddon.php @@ -0,0 +1,54 @@ + $data + */ + public static function from(array $data): static + { + if (!array_key_exists('seats', $data)) { + throw new \InvalidArgumentException('Missing required field "seats" for ' . static::class . '.'); + } + if (!array_key_exists('projects', $data)) { + throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); + } + + return new static( + seats: static::hydrateTypedValue(BillingPlanAddonDetails::class, $data['seats']), + projects: static::hydrateTypedValue(BillingPlanAddonDetails::class, $data['projects']) + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + 'seats' => static::serializeValue($this->seats), + 'projects' => static::serializeValue($this->projects) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/BillingPlanAddonDetails.php b/src/Appwrite/Models/BillingPlanAddonDetails.php new file mode 100644 index 00000000..60f94449 --- /dev/null +++ b/src/Appwrite/Models/BillingPlanAddonDetails.php @@ -0,0 +1,96 @@ + $data + */ + public static function from(array $data): static + { + if (!array_key_exists('supported', $data)) { + throw new \InvalidArgumentException('Missing required field "supported" for ' . static::class . '.'); + } + if (!array_key_exists('planIncluded', $data)) { + throw new \InvalidArgumentException('Missing required field "planIncluded" for ' . static::class . '.'); + } + if (!array_key_exists('limit', $data)) { + throw new \InvalidArgumentException('Missing required field "limit" for ' . static::class . '.'); + } + if (!array_key_exists('type', $data)) { + throw new \InvalidArgumentException('Missing required field "type" for ' . static::class . '.'); + } + if (!array_key_exists('currency', $data)) { + throw new \InvalidArgumentException('Missing required field "currency" for ' . static::class . '.'); + } + if (!array_key_exists('price', $data)) { + throw new \InvalidArgumentException('Missing required field "price" for ' . static::class . '.'); + } + if (!array_key_exists('value', $data)) { + throw new \InvalidArgumentException('Missing required field "value" for ' . static::class . '.'); + } + if (!array_key_exists('invoiceDesc', $data)) { + throw new \InvalidArgumentException('Missing required field "invoiceDesc" for ' . static::class . '.'); + } + + return new static( + supported: $data['supported'], + planIncluded: $data['planIncluded'], + limit: $data['limit'], + type: $data['type'], + currency: $data['currency'], + price: $data['price'], + value: $data['value'], + invoiceDesc: $data['invoiceDesc'] + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + 'supported' => static::serializeValue($this->supported), + 'planIncluded' => static::serializeValue($this->planIncluded), + 'limit' => static::serializeValue($this->limit), + 'type' => static::serializeValue($this->type), + 'currency' => static::serializeValue($this->currency), + 'price' => static::serializeValue($this->price), + 'value' => static::serializeValue($this->value), + 'invoiceDesc' => static::serializeValue($this->invoiceDesc) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/BillingPlanDedicatedDatabaseLimits.php b/src/Appwrite/Models/BillingPlanDedicatedDatabaseLimits.php new file mode 100644 index 00000000..97a088b1 --- /dev/null +++ b/src/Appwrite/Models/BillingPlanDedicatedDatabaseLimits.php @@ -0,0 +1,116 @@ + $data + */ + public static function from(array $data): static + { + + return new static( + minCpu: array_key_exists('minCpu', $data) ? $data['minCpu'] : null, + maxCpu: array_key_exists('maxCpu', $data) ? $data['maxCpu'] : null, + minMemoryMb: array_key_exists('minMemoryMb', $data) ? $data['minMemoryMb'] : null, + maxMemoryMb: array_key_exists('maxMemoryMb', $data) ? $data['maxMemoryMb'] : null, + minStorageGb: array_key_exists('minStorageGb', $data) ? $data['minStorageGb'] : null, + maxStorageGb: array_key_exists('maxStorageGb', $data) ? $data['maxStorageGb'] : null, + maxReplicas: array_key_exists('maxReplicas', $data) ? $data['maxReplicas'] : null, + maxConnections: array_key_exists('maxConnections', $data) ? $data['maxConnections'] : null, + maxIpAllowlistSize: array_key_exists('maxIpAllowlistSize', $data) ? $data['maxIpAllowlistSize'] : null, + maxExtensions: array_key_exists('maxExtensions', $data) ? $data['maxExtensions'] : null, + maxBackupRetentionDays: array_key_exists('maxBackupRetentionDays', $data) ? $data['maxBackupRetentionDays'] : null, + maxPitrRetentionDays: array_key_exists('maxPitrRetentionDays', $data) ? $data['maxPitrRetentionDays'] : null, + maxSqlApiMaxRows: array_key_exists('maxSqlApiMaxRows', $data) ? $data['maxSqlApiMaxRows'] : null, + maxSqlApiMaxBytes: array_key_exists('maxSqlApiMaxBytes', $data) ? $data['maxSqlApiMaxBytes'] : null, + maxSqlApiTimeoutSeconds: array_key_exists('maxSqlApiTimeoutSeconds', $data) ? $data['maxSqlApiTimeoutSeconds'] : null, + maxSqlApiAllowedStatements: array_key_exists('maxSqlApiAllowedStatements', $data) ? $data['maxSqlApiAllowedStatements'] : null, + allowedSqlStatements: array_key_exists('allowedSqlStatements', $data) ? $data['allowedSqlStatements'] : null, + allowedStorageClasses: array_key_exists('allowedStorageClasses', $data) ? $data['allowedStorageClasses'] : null, + allowedSyncModes: array_key_exists('allowedSyncModes', $data) ? $data['allowedSyncModes'] : null + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + 'minCpu' => static::serializeValue($this->minCpu), + 'maxCpu' => static::serializeValue($this->maxCpu), + 'minMemoryMb' => static::serializeValue($this->minMemoryMb), + 'maxMemoryMb' => static::serializeValue($this->maxMemoryMb), + 'minStorageGb' => static::serializeValue($this->minStorageGb), + 'maxStorageGb' => static::serializeValue($this->maxStorageGb), + 'maxReplicas' => static::serializeValue($this->maxReplicas), + 'maxConnections' => static::serializeValue($this->maxConnections), + 'maxIpAllowlistSize' => static::serializeValue($this->maxIpAllowlistSize), + 'maxExtensions' => static::serializeValue($this->maxExtensions), + 'maxBackupRetentionDays' => static::serializeValue($this->maxBackupRetentionDays), + 'maxPitrRetentionDays' => static::serializeValue($this->maxPitrRetentionDays), + 'maxSqlApiMaxRows' => static::serializeValue($this->maxSqlApiMaxRows), + 'maxSqlApiMaxBytes' => static::serializeValue($this->maxSqlApiMaxBytes), + 'maxSqlApiTimeoutSeconds' => static::serializeValue($this->maxSqlApiTimeoutSeconds), + 'maxSqlApiAllowedStatements' => static::serializeValue($this->maxSqlApiAllowedStatements), + 'allowedSqlStatements' => static::serializeValue($this->allowedSqlStatements), + 'allowedStorageClasses' => static::serializeValue($this->allowedStorageClasses), + 'allowedSyncModes' => static::serializeValue($this->allowedSyncModes) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/BillingPlanLimits.php b/src/Appwrite/Models/BillingPlanLimits.php new file mode 100644 index 00000000..2f8d9d86 --- /dev/null +++ b/src/Appwrite/Models/BillingPlanLimits.php @@ -0,0 +1,48 @@ + $data + */ + public static function from(array $data): static + { + + return new static( + credits: array_key_exists('credits', $data) ? $data['credits'] : null, + dailyCredits: array_key_exists('dailyCredits', $data) ? $data['dailyCredits'] : null + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + 'credits' => static::serializeValue($this->credits), + 'dailyCredits' => static::serializeValue($this->dailyCredits) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/BillingPlanSupportedAddons.php b/src/Appwrite/Models/BillingPlanSupportedAddons.php new file mode 100644 index 00000000..344ce998 --- /dev/null +++ b/src/Appwrite/Models/BillingPlanSupportedAddons.php @@ -0,0 +1,61 @@ + $data + */ + public static function from(array $data): static + { + if (!array_key_exists('baa', $data)) { + throw new \InvalidArgumentException('Missing required field "baa" for ' . static::class . '.'); + } + if (!array_key_exists('premiumGeoDB', $data)) { + throw new \InvalidArgumentException('Missing required field "premiumGeoDB" for ' . static::class . '.'); + } + if (!array_key_exists('premiumGeoDBOrg', $data)) { + throw new \InvalidArgumentException('Missing required field "premiumGeoDBOrg" for ' . static::class . '.'); + } + + return new static( + baa: $data['baa'], + premiumGeoDB: $data['premiumGeoDB'], + premiumGeoDBOrg: $data['premiumGeoDBOrg'] + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + 'baa' => static::serializeValue($this->baa), + 'premiumGeoDB' => static::serializeValue($this->premiumGeoDB), + 'premiumGeoDBOrg' => static::serializeValue($this->premiumGeoDBOrg) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/Block.php b/src/Appwrite/Models/Block.php index 350d0c12..4079f849 100644 --- a/src/Appwrite/Models/Block.php +++ b/src/Appwrite/Models/Block.php @@ -15,6 +15,7 @@ * @param string $createdAt block creation date in iso 8601 format. * @param string $resourceType resource type that is blocked * @param string $resourceId resource identifier that is blocked + * @param string $mode block mode. full blocks reads and writes; readonly blocks writes only. * @param string $projectName name of the project this block applies to. * @param string $region region of the project this block applies to. * @param string $organizationName name of the organization that owns the project. @@ -27,6 +28,7 @@ public function __construct( public string $createdAt, public string $resourceType, public string $resourceId, + public string $mode, public string $projectName, public string $region, public string $organizationName, @@ -51,6 +53,9 @@ public static function from(array $data): static if (!array_key_exists('resourceId', $data)) { throw new \InvalidArgumentException('Missing required field "resourceId" for ' . static::class . '.'); } + if (!array_key_exists('mode', $data)) { + throw new \InvalidArgumentException('Missing required field "mode" for ' . static::class . '.'); + } if (!array_key_exists('projectName', $data)) { throw new \InvalidArgumentException('Missing required field "projectName" for ' . static::class . '.'); } @@ -71,6 +76,7 @@ public static function from(array $data): static createdAt: $data['$createdAt'], resourceType: $data['resourceType'], resourceId: $data['resourceId'], + mode: $data['mode'], projectName: $data['projectName'], region: $data['region'], organizationName: $data['organizationName'], @@ -90,6 +96,7 @@ public function toArray(): array '$createdAt' => static::serializeValue($this->createdAt), 'resourceType' => static::serializeValue($this->resourceType), 'resourceId' => static::serializeValue($this->resourceId), + 'mode' => static::serializeValue($this->mode), 'reason' => static::serializeValue($this->reason), 'expiredAt' => static::serializeValue($this->expiredAt), 'projectName' => static::serializeValue($this->projectName), diff --git a/src/Appwrite/Models/Database.php b/src/Appwrite/Models/Database.php index fc06cde2..6a226440 100644 --- a/src/Appwrite/Models/Database.php +++ b/src/Appwrite/Models/Database.php @@ -3,6 +3,7 @@ namespace Appwrite\Models; use Appwrite\Enums\DatabaseType; +use Appwrite\Enums\DatabaseStatus; /** * Database @@ -22,6 +23,7 @@ * @param DatabaseType $type database type. * @param list $policies database backup policies. * @param list $archives database backup archives. + * @param DatabaseStatus|null $status database status. possible values: `provisioning`, `ready` or `failed` */ public function __construct( public string $id, @@ -31,7 +33,8 @@ public function __construct( public bool $enabled, public DatabaseType $type, public array $policies, - public array $archives + public array $archives, + public ?DatabaseStatus $status = null ) { } @@ -83,7 +86,8 @@ public static function from(array $data): static static fn (mixed $item): mixed => static::hydrateTypedValue(BackupArchive::class, $item), $data['archives'] ) - : $data['archives'] + : $data['archives'], + status: array_key_exists('status', $data) ? static::hydrateTypedValue(DatabaseStatus::class, $data['status'], true) : null ); } @@ -99,6 +103,7 @@ public function toArray(): array '$updatedAt' => static::serializeValue($this->updatedAt), 'enabled' => static::serializeValue($this->enabled), 'type' => static::serializeValue($this->type), + 'status' => static::serializeValue($this->status), 'policies' => static::serializeValue($this->policies), 'archives' => static::serializeValue($this->archives) ]; diff --git a/src/Appwrite/Models/HealthAntivirus.php b/src/Appwrite/Models/HealthAntivirus.php deleted file mode 100644 index 31a47bbd..00000000 --- a/src/Appwrite/Models/HealthAntivirus.php +++ /dev/null @@ -1,56 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('version', $data)) { - throw new \InvalidArgumentException('Missing required field "version" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - - return new static( - version: $data['version'], - status: static::hydrateTypedValue(HealthAntivirusStatus::class, $data['status']) - ); - } - - /** - * @return array - */ - public function toArray(): array - { - $result = [ - 'version' => static::serializeValue($this->version), - 'status' => static::serializeValue($this->status) - ]; - - return $result; - } -} diff --git a/src/Appwrite/Models/HealthCertificate.php b/src/Appwrite/Models/HealthCertificate.php deleted file mode 100644 index bad516ff..00000000 --- a/src/Appwrite/Models/HealthCertificate.php +++ /dev/null @@ -1,82 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('subjectSN', $data)) { - throw new \InvalidArgumentException('Missing required field "subjectSN" for ' . static::class . '.'); - } - if (!array_key_exists('issuerOrganisation', $data)) { - throw new \InvalidArgumentException('Missing required field "issuerOrganisation" for ' . static::class . '.'); - } - if (!array_key_exists('validFrom', $data)) { - throw new \InvalidArgumentException('Missing required field "validFrom" for ' . static::class . '.'); - } - if (!array_key_exists('validTo', $data)) { - throw new \InvalidArgumentException('Missing required field "validTo" for ' . static::class . '.'); - } - if (!array_key_exists('signatureTypeSN', $data)) { - throw new \InvalidArgumentException('Missing required field "signatureTypeSN" for ' . static::class . '.'); - } - - return new static( - name: $data['name'], - subjectSN: $data['subjectSN'], - issuerOrganisation: $data['issuerOrganisation'], - validFrom: $data['validFrom'], - validTo: $data['validTo'], - signatureTypeSN: $data['signatureTypeSN'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - $result = [ - 'name' => static::serializeValue($this->name), - 'subjectSN' => static::serializeValue($this->subjectSN), - 'issuerOrganisation' => static::serializeValue($this->issuerOrganisation), - 'validFrom' => static::serializeValue($this->validFrom), - 'validTo' => static::serializeValue($this->validTo), - 'signatureTypeSN' => static::serializeValue($this->signatureTypeSN) - ]; - - return $result; - } -} diff --git a/src/Appwrite/Models/HealthQueue.php b/src/Appwrite/Models/HealthQueue.php deleted file mode 100644 index f709a229..00000000 --- a/src/Appwrite/Models/HealthQueue.php +++ /dev/null @@ -1,47 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('size', $data)) { - throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); - } - - return new static( - size: $data['size'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - $result = [ - 'size' => static::serializeValue($this->size) - ]; - - return $result; - } -} diff --git a/src/Appwrite/Models/HealthStatus.php b/src/Appwrite/Models/HealthStatus.php deleted file mode 100644 index 6238a2eb..00000000 --- a/src/Appwrite/Models/HealthStatus.php +++ /dev/null @@ -1,63 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('name', $data)) { - throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); - } - if (!array_key_exists('ping', $data)) { - throw new \InvalidArgumentException('Missing required field "ping" for ' . static::class . '.'); - } - if (!array_key_exists('status', $data)) { - throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); - } - - return new static( - name: $data['name'], - ping: $data['ping'], - status: static::hydrateTypedValue(HealthCheckStatus::class, $data['status']) - ); - } - - /** - * @return array - */ - public function toArray(): array - { - $result = [ - 'name' => static::serializeValue($this->name), - 'ping' => static::serializeValue($this->ping), - 'status' => static::serializeValue($this->status) - ]; - - return $result; - } -} diff --git a/src/Appwrite/Models/HealthStatusList.php b/src/Appwrite/Models/HealthStatusList.php deleted file mode 100644 index 4b13218d..00000000 --- a/src/Appwrite/Models/HealthStatusList.php +++ /dev/null @@ -1,59 +0,0 @@ - $statuses list of statuses. - */ - public function __construct( - public int $total, - public array $statuses - ) { - } - - /** - * @param array $data - */ - public static function from(array $data): static - { - if (!array_key_exists('total', $data)) { - throw new \InvalidArgumentException('Missing required field "total" for ' . static::class . '.'); - } - if (!array_key_exists('statuses', $data)) { - throw new \InvalidArgumentException('Missing required field "statuses" for ' . static::class . '.'); - } - - return new static( - total: $data['total'], - statuses: is_array($data['statuses']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(HealthStatus::class, $item), - $data['statuses'] - ) - : $data['statuses'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - $result = [ - 'total' => static::serializeValue($this->total), - 'statuses' => static::serializeValue($this->statuses) - ]; - - return $result; - } -} diff --git a/src/Appwrite/Models/HealthTime.php b/src/Appwrite/Models/HealthTime.php deleted file mode 100644 index c3036d1e..00000000 --- a/src/Appwrite/Models/HealthTime.php +++ /dev/null @@ -1,61 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('remoteTime', $data)) { - throw new \InvalidArgumentException('Missing required field "remoteTime" for ' . static::class . '.'); - } - if (!array_key_exists('localTime', $data)) { - throw new \InvalidArgumentException('Missing required field "localTime" for ' . static::class . '.'); - } - if (!array_key_exists('diff', $data)) { - throw new \InvalidArgumentException('Missing required field "diff" for ' . static::class . '.'); - } - - return new static( - remoteTime: $data['remoteTime'], - localTime: $data['localTime'], - diff: $data['diff'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - $result = [ - 'remoteTime' => static::serializeValue($this->remoteTime), - 'localTime' => static::serializeValue($this->localTime), - 'diff' => static::serializeValue($this->diff) - ]; - - return $result; - } -} diff --git a/src/Appwrite/Models/Locale.php b/src/Appwrite/Models/Locale.php index 183919af..e7ab2726 100644 --- a/src/Appwrite/Models/Locale.php +++ b/src/Appwrite/Models/Locale.php @@ -19,6 +19,17 @@ * @param string $continent continent name. this field support localization. * @param bool $eu true if country is part of the european union. * @param string $currency currency code in [iso 4217-1](http://en.wikipedia.org/wiki/iso_4217) three-character format + * @param string|null $city city + * @param string|null $timeZone name of timezone + * @param string|null $postalCode postal code + * @param float|null $latitude latitude + * @param float|null $longitude longitude + * @param string|null $autonomousSystemNumber autonomous system number (asn) of the ip + * @param string|null $autonomousSystemOrganization organization that owns the asn + * @param string|null $isp internet service provider of the ip + * @param string|null $connectionType connection type of the ip (e.g. cable, cellular, corporate) + * @param string|null $connectionUsageType user type classification of the ip (e.g. residential, business, hosting) + * @param string|null $connectionOrganization registered organization of the ip */ public function __construct( public string $ip, @@ -27,7 +38,18 @@ public function __construct( public string $continentCode, public string $continent, public bool $eu, - public string $currency + public string $currency, + public ?string $city = null, + public ?string $timeZone = null, + public ?string $postalCode = null, + public ?float $latitude = null, + public ?float $longitude = null, + public ?string $autonomousSystemNumber = null, + public ?string $autonomousSystemOrganization = null, + public ?string $isp = null, + public ?string $connectionType = null, + public ?string $connectionUsageType = null, + public ?string $connectionOrganization = null ) { } @@ -65,7 +87,18 @@ public static function from(array $data): static continentCode: $data['continentCode'], continent: $data['continent'], eu: $data['eu'], - currency: $data['currency'] + currency: $data['currency'], + city: array_key_exists('city', $data) ? $data['city'] : null, + timeZone: array_key_exists('timeZone', $data) ? $data['timeZone'] : null, + postalCode: array_key_exists('postalCode', $data) ? $data['postalCode'] : null, + latitude: array_key_exists('latitude', $data) ? $data['latitude'] : null, + longitude: array_key_exists('longitude', $data) ? $data['longitude'] : null, + autonomousSystemNumber: array_key_exists('autonomousSystemNumber', $data) ? $data['autonomousSystemNumber'] : null, + autonomousSystemOrganization: array_key_exists('autonomousSystemOrganization', $data) ? $data['autonomousSystemOrganization'] : null, + isp: array_key_exists('isp', $data) ? $data['isp'] : null, + connectionType: array_key_exists('connectionType', $data) ? $data['connectionType'] : null, + connectionUsageType: array_key_exists('connectionUsageType', $data) ? $data['connectionUsageType'] : null, + connectionOrganization: array_key_exists('connectionOrganization', $data) ? $data['connectionOrganization'] : null ); } @@ -81,7 +114,18 @@ public function toArray(): array 'continentCode' => static::serializeValue($this->continentCode), 'continent' => static::serializeValue($this->continent), 'eu' => static::serializeValue($this->eu), - 'currency' => static::serializeValue($this->currency) + 'currency' => static::serializeValue($this->currency), + 'city' => static::serializeValue($this->city), + 'timeZone' => static::serializeValue($this->timeZone), + 'postalCode' => static::serializeValue($this->postalCode), + 'latitude' => static::serializeValue($this->latitude), + 'longitude' => static::serializeValue($this->longitude), + 'autonomousSystemNumber' => static::serializeValue($this->autonomousSystemNumber), + 'autonomousSystemOrganization' => static::serializeValue($this->autonomousSystemOrganization), + 'isp' => static::serializeValue($this->isp), + 'connectionType' => static::serializeValue($this->connectionType), + 'connectionUsageType' => static::serializeValue($this->connectionUsageType), + 'connectionOrganization' => static::serializeValue($this->connectionOrganization) ]; return $result; diff --git a/src/Appwrite/Models/Log.php b/src/Appwrite/Models/Log.php index f3f74cee..8cb811db 100644 --- a/src/Appwrite/Models/Log.php +++ b/src/Appwrite/Models/Log.php @@ -17,7 +17,7 @@ * @param string $userEmail user email of the actor recorded for this log. during impersonation, this is the original impersonator. * @param string $userName user name of the actor recorded for this log. during impersonation, this is the original impersonator. * @param string $mode api mode when event triggered. - * @param string $userType user type who triggered the audit log. possible values: user, admin, guest, keyproject, keyaccount, keyorganization. + * @param string $userType user type who triggered the audit log. possible values: user, admin, guest, hidden, keyproject, keyaccount, keyorganization. * @param string $ip ip session in use when the session was created. * @param string $time log creation date in iso 8601 format. * @param string $osCode operating system code name. view list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json). diff --git a/src/Appwrite/Models/OAuth2Appwrite.php b/src/Appwrite/Models/OAuth2Appwrite.php new file mode 100644 index 00000000..1ae1b35a --- /dev/null +++ b/src/Appwrite/Models/OAuth2Appwrite.php @@ -0,0 +1,68 @@ + $data + */ + public static function from(array $data): static + { + if (!array_key_exists('$id', $data)) { + throw new \InvalidArgumentException('Missing required field "$id" for ' . static::class . '.'); + } + if (!array_key_exists('enabled', $data)) { + throw new \InvalidArgumentException('Missing required field "enabled" for ' . static::class . '.'); + } + if (!array_key_exists('clientId', $data)) { + throw new \InvalidArgumentException('Missing required field "clientId" for ' . static::class . '.'); + } + if (!array_key_exists('clientSecret', $data)) { + throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.'); + } + + return new static( + id: $data['$id'], + enabled: $data['enabled'], + clientId: $data['clientId'], + clientSecret: $data['clientSecret'] + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + '$id' => static::serializeValue($this->id), + 'enabled' => static::serializeValue($this->enabled), + 'clientId' => static::serializeValue($this->clientId), + 'clientSecret' => static::serializeValue($this->clientSecret) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/OAuth2Oidc.php b/src/Appwrite/Models/OAuth2Oidc.php index 7fd780e9..26a21ce1 100644 --- a/src/Appwrite/Models/OAuth2Oidc.php +++ b/src/Appwrite/Models/OAuth2Oidc.php @@ -2,6 +2,8 @@ namespace Appwrite\Models; +use Appwrite\Enums\OAuth2OidcPrompt; + /** * OAuth2Oidc */ @@ -20,6 +22,8 @@ * @param string $authorizationURL openid connect authorization endpoint url. * @param string $tokenURL openid connect token endpoint url. * @param string $userInfoURL openid connect user info endpoint url. + * @param list $prompt openid connect prompt values controlling the authentication and consent screens. + * @param int|null $maxAge maximum authentication age in seconds. when set, the user must have authenticated within this many seconds. */ public function __construct( public string $id, @@ -29,7 +33,9 @@ public function __construct( public string $wellKnownURL, public string $authorizationURL, public string $tokenURL, - public string $userInfoURL + public string $userInfoURL, + public array $prompt, + public ?int $maxAge = null ) { } @@ -62,6 +68,9 @@ public static function from(array $data): static if (!array_key_exists('userInfoURL', $data)) { throw new \InvalidArgumentException('Missing required field "userInfoURL" for ' . static::class . '.'); } + if (!array_key_exists('prompt', $data)) { + throw new \InvalidArgumentException('Missing required field "prompt" for ' . static::class . '.'); + } return new static( id: $data['$id'], @@ -71,7 +80,14 @@ public static function from(array $data): static wellKnownURL: $data['wellKnownURL'], authorizationURL: $data['authorizationURL'], tokenURL: $data['tokenURL'], - userInfoURL: $data['userInfoURL'] + userInfoURL: $data['userInfoURL'], + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OidcPrompt::class, $item), + $data['prompt'] + ) + : $data['prompt'], + maxAge: array_key_exists('maxAge', $data) ? $data['maxAge'] : null ); } @@ -88,7 +104,9 @@ public function toArray(): array 'wellKnownURL' => static::serializeValue($this->wellKnownURL), 'authorizationURL' => static::serializeValue($this->authorizationURL), 'tokenURL' => static::serializeValue($this->tokenURL), - 'userInfoURL' => static::serializeValue($this->userInfoURL) + 'userInfoURL' => static::serializeValue($this->userInfoURL), + 'prompt' => static::serializeValue($this->prompt), + 'maxAge' => static::serializeValue($this->maxAge) ]; return $result; diff --git a/src/Appwrite/Models/Organization.php b/src/Appwrite/Models/Organization.php new file mode 100644 index 00000000..8842b34f --- /dev/null +++ b/src/Appwrite/Models/Organization.php @@ -0,0 +1,282 @@ + $data + */ + public static function from(array $data): static + { + if (!array_key_exists('$id', $data)) { + throw new \InvalidArgumentException('Missing required field "$id" for ' . static::class . '.'); + } + if (!array_key_exists('$createdAt', $data)) { + throw new \InvalidArgumentException('Missing required field "$createdAt" for ' . static::class . '.'); + } + if (!array_key_exists('$updatedAt', $data)) { + throw new \InvalidArgumentException('Missing required field "$updatedAt" for ' . static::class . '.'); + } + if (!array_key_exists('name', $data)) { + throw new \InvalidArgumentException('Missing required field "name" for ' . static::class . '.'); + } + if (!array_key_exists('total', $data)) { + throw new \InvalidArgumentException('Missing required field "total" for ' . static::class . '.'); + } + if (!array_key_exists('prefs', $data)) { + throw new \InvalidArgumentException('Missing required field "prefs" for ' . static::class . '.'); + } + if (!array_key_exists('billingBudget', $data)) { + throw new \InvalidArgumentException('Missing required field "billingBudget" for ' . static::class . '.'); + } + if (!array_key_exists('budgetAlerts', $data)) { + throw new \InvalidArgumentException('Missing required field "budgetAlerts" for ' . static::class . '.'); + } + if (!array_key_exists('billingPlan', $data)) { + throw new \InvalidArgumentException('Missing required field "billingPlan" for ' . static::class . '.'); + } + if (!array_key_exists('billingPlanId', $data)) { + throw new \InvalidArgumentException('Missing required field "billingPlanId" for ' . static::class . '.'); + } + if (!array_key_exists('billingPlanDetails', $data)) { + throw new \InvalidArgumentException('Missing required field "billingPlanDetails" for ' . static::class . '.'); + } + if (!array_key_exists('billingEmail', $data)) { + throw new \InvalidArgumentException('Missing required field "billingEmail" for ' . static::class . '.'); + } + if (!array_key_exists('billingStartDate', $data)) { + throw new \InvalidArgumentException('Missing required field "billingStartDate" for ' . static::class . '.'); + } + if (!array_key_exists('billingCurrentInvoiceDate', $data)) { + throw new \InvalidArgumentException('Missing required field "billingCurrentInvoiceDate" for ' . static::class . '.'); + } + if (!array_key_exists('billingNextInvoiceDate', $data)) { + throw new \InvalidArgumentException('Missing required field "billingNextInvoiceDate" for ' . static::class . '.'); + } + if (!array_key_exists('billingTrialStartDate', $data)) { + throw new \InvalidArgumentException('Missing required field "billingTrialStartDate" for ' . static::class . '.'); + } + if (!array_key_exists('billingTrialDays', $data)) { + throw new \InvalidArgumentException('Missing required field "billingTrialDays" for ' . static::class . '.'); + } + if (!array_key_exists('billingAggregationId', $data)) { + throw new \InvalidArgumentException('Missing required field "billingAggregationId" for ' . static::class . '.'); + } + if (!array_key_exists('billingInvoiceId', $data)) { + throw new \InvalidArgumentException('Missing required field "billingInvoiceId" for ' . static::class . '.'); + } + if (!array_key_exists('paymentMethodId', $data)) { + throw new \InvalidArgumentException('Missing required field "paymentMethodId" for ' . static::class . '.'); + } + if (!array_key_exists('billingAddressId', $data)) { + throw new \InvalidArgumentException('Missing required field "billingAddressId" for ' . static::class . '.'); + } + if (!array_key_exists('backupPaymentMethodId', $data)) { + throw new \InvalidArgumentException('Missing required field "backupPaymentMethodId" for ' . static::class . '.'); + } + if (!array_key_exists('status', $data)) { + throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); + } + if (!array_key_exists('remarks', $data)) { + throw new \InvalidArgumentException('Missing required field "remarks" for ' . static::class . '.'); + } + if (!array_key_exists('agreementBAA', $data)) { + throw new \InvalidArgumentException('Missing required field "agreementBAA" for ' . static::class . '.'); + } + if (!array_key_exists('programManagerName', $data)) { + throw new \InvalidArgumentException('Missing required field "programManagerName" for ' . static::class . '.'); + } + if (!array_key_exists('programManagerCalendar', $data)) { + throw new \InvalidArgumentException('Missing required field "programManagerCalendar" for ' . static::class . '.'); + } + if (!array_key_exists('programDiscordChannelName', $data)) { + throw new \InvalidArgumentException('Missing required field "programDiscordChannelName" for ' . static::class . '.'); + } + if (!array_key_exists('programDiscordChannelUrl', $data)) { + throw new \InvalidArgumentException('Missing required field "programDiscordChannelUrl" for ' . static::class . '.'); + } + if (!array_key_exists('billingPlanDowngrade', $data)) { + throw new \InvalidArgumentException('Missing required field "billingPlanDowngrade" for ' . static::class . '.'); + } + if (!array_key_exists('billingTaxId', $data)) { + throw new \InvalidArgumentException('Missing required field "billingTaxId" for ' . static::class . '.'); + } + if (!array_key_exists('markedForDeletion', $data)) { + throw new \InvalidArgumentException('Missing required field "markedForDeletion" for ' . static::class . '.'); + } + if (!array_key_exists('platform', $data)) { + throw new \InvalidArgumentException('Missing required field "platform" for ' . static::class . '.'); + } + if (!array_key_exists('projects', $data)) { + throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); + } + + return new static( + id: $data['$id'], + createdAt: $data['$createdAt'], + updatedAt: $data['$updatedAt'], + name: $data['name'], + total: $data['total'], + prefs: static::hydrateTypedValue(Preferences::class, $data['prefs']), + billingBudget: $data['billingBudget'], + budgetAlerts: $data['budgetAlerts'], + billingPlan: $data['billingPlan'], + billingPlanId: $data['billingPlanId'], + billingPlanDetails: static::hydrateTypedValue(BillingPlan::class, $data['billingPlanDetails']), + billingEmail: $data['billingEmail'], + billingStartDate: $data['billingStartDate'], + billingCurrentInvoiceDate: $data['billingCurrentInvoiceDate'], + billingNextInvoiceDate: $data['billingNextInvoiceDate'], + billingTrialStartDate: $data['billingTrialStartDate'], + billingTrialDays: $data['billingTrialDays'], + billingAggregationId: $data['billingAggregationId'], + billingInvoiceId: $data['billingInvoiceId'], + paymentMethodId: $data['paymentMethodId'], + billingAddressId: $data['billingAddressId'], + backupPaymentMethodId: $data['backupPaymentMethodId'], + status: $data['status'], + remarks: $data['remarks'], + agreementBAA: $data['agreementBAA'], + programManagerName: $data['programManagerName'], + programManagerCalendar: $data['programManagerCalendar'], + programDiscordChannelName: $data['programDiscordChannelName'], + programDiscordChannelUrl: $data['programDiscordChannelUrl'], + billingPlanDowngrade: $data['billingPlanDowngrade'], + billingTaxId: $data['billingTaxId'], + markedForDeletion: $data['markedForDeletion'], + platform: $data['platform'], + projects: $data['projects'], + billingLimits: array_key_exists('billingLimits', $data) ? static::hydrateTypedValue(BillingLimits::class, $data['billingLimits'], true) : null + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + '$id' => static::serializeValue($this->id), + '$createdAt' => static::serializeValue($this->createdAt), + '$updatedAt' => static::serializeValue($this->updatedAt), + 'name' => static::serializeValue($this->name), + 'total' => static::serializeValue($this->total), + 'prefs' => static::serializeValue($this->prefs), + 'billingBudget' => static::serializeValue($this->billingBudget), + 'budgetAlerts' => static::serializeValue($this->budgetAlerts), + 'billingPlan' => static::serializeValue($this->billingPlan), + 'billingPlanId' => static::serializeValue($this->billingPlanId), + 'billingPlanDetails' => static::serializeValue($this->billingPlanDetails), + 'billingEmail' => static::serializeValue($this->billingEmail), + 'billingStartDate' => static::serializeValue($this->billingStartDate), + 'billingCurrentInvoiceDate' => static::serializeValue($this->billingCurrentInvoiceDate), + 'billingNextInvoiceDate' => static::serializeValue($this->billingNextInvoiceDate), + 'billingTrialStartDate' => static::serializeValue($this->billingTrialStartDate), + 'billingTrialDays' => static::serializeValue($this->billingTrialDays), + 'billingAggregationId' => static::serializeValue($this->billingAggregationId), + 'billingInvoiceId' => static::serializeValue($this->billingInvoiceId), + 'paymentMethodId' => static::serializeValue($this->paymentMethodId), + 'billingAddressId' => static::serializeValue($this->billingAddressId), + 'backupPaymentMethodId' => static::serializeValue($this->backupPaymentMethodId), + 'status' => static::serializeValue($this->status), + 'remarks' => static::serializeValue($this->remarks), + 'agreementBAA' => static::serializeValue($this->agreementBAA), + 'programManagerName' => static::serializeValue($this->programManagerName), + 'programManagerCalendar' => static::serializeValue($this->programManagerCalendar), + 'programDiscordChannelName' => static::serializeValue($this->programDiscordChannelName), + 'programDiscordChannelUrl' => static::serializeValue($this->programDiscordChannelUrl), + 'billingLimits' => static::serializeValue($this->billingLimits), + 'billingPlanDowngrade' => static::serializeValue($this->billingPlanDowngrade), + 'billingTaxId' => static::serializeValue($this->billingTaxId), + 'markedForDeletion' => static::serializeValue($this->markedForDeletion), + 'platform' => static::serializeValue($this->platform), + 'projects' => static::serializeValue($this->projects) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/Program.php b/src/Appwrite/Models/Program.php new file mode 100644 index 00000000..a6bdcd53 --- /dev/null +++ b/src/Appwrite/Models/Program.php @@ -0,0 +1,103 @@ + $data + */ + public static function from(array $data): static + { + if (!array_key_exists('$id', $data)) { + throw new \InvalidArgumentException('Missing required field "$id" for ' . static::class . '.'); + } + if (!array_key_exists('title', $data)) { + throw new \InvalidArgumentException('Missing required field "title" for ' . static::class . '.'); + } + if (!array_key_exists('description', $data)) { + throw new \InvalidArgumentException('Missing required field "description" for ' . static::class . '.'); + } + if (!array_key_exists('tag', $data)) { + throw new \InvalidArgumentException('Missing required field "tag" for ' . static::class . '.'); + } + if (!array_key_exists('icon', $data)) { + throw new \InvalidArgumentException('Missing required field "icon" for ' . static::class . '.'); + } + if (!array_key_exists('url', $data)) { + throw new \InvalidArgumentException('Missing required field "url" for ' . static::class . '.'); + } + if (!array_key_exists('active', $data)) { + throw new \InvalidArgumentException('Missing required field "active" for ' . static::class . '.'); + } + if (!array_key_exists('external', $data)) { + throw new \InvalidArgumentException('Missing required field "external" for ' . static::class . '.'); + } + if (!array_key_exists('billingPlanId', $data)) { + throw new \InvalidArgumentException('Missing required field "billingPlanId" for ' . static::class . '.'); + } + + return new static( + id: $data['$id'], + title: $data['title'], + description: $data['description'], + tag: $data['tag'], + icon: $data['icon'], + url: $data['url'], + active: $data['active'], + external: $data['external'], + billingPlanId: $data['billingPlanId'] + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + '$id' => static::serializeValue($this->id), + 'title' => static::serializeValue($this->title), + 'description' => static::serializeValue($this->description), + 'tag' => static::serializeValue($this->tag), + 'icon' => static::serializeValue($this->icon), + 'url' => static::serializeValue($this->url), + 'active' => static::serializeValue($this->active), + 'external' => static::serializeValue($this->external), + 'billingPlanId' => static::serializeValue($this->billingPlanId) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/Project.php b/src/Appwrite/Models/Project.php index 700b7f6e..f2af24d4 100644 --- a/src/Appwrite/Models/Project.php +++ b/src/Appwrite/Models/Project.php @@ -33,6 +33,7 @@ * @param string $pingedAt last ping datetime in iso 8601 format. * @param array $labels labels for the project. * @param string $status project status + * @param array $onboarding stage progress (completed or skipped) with timestamps and actor types, keyed by stage id. * @param list $authMethods list of auth methods. * @param list $services list of services. * @param list $protocols list of protocols. @@ -42,6 +43,7 @@ * @param bool|null $oAuth2ServerEnabled oauth2 server status * @param string|null $oAuth2ServerAuthorizationUrl oauth2 server authorization url * @param array|null $oAuth2ServerScopes oauth2 server allowed scopes + * @param array|null $oAuth2ServerDefaultScopes oauth2 server scopes used when an authorization request omits the scope parameter * @param array|null $oAuth2ServerAuthorizationDetailsTypes oauth2 server accepted rfc 9396 authorization_details types * @param int|null $oAuth2ServerAccessTokenDuration oauth2 server access token duration in seconds for confidential clients * @param int|null $oAuth2ServerRefreshTokenDuration oauth2 server refresh token duration in seconds for confidential clients @@ -76,6 +78,7 @@ public function __construct( public string $pingedAt, public array $labels, public string $status, + public array $onboarding, public array $authMethods, public array $services, public array $protocols, @@ -85,6 +88,7 @@ public function __construct( public ?bool $oAuth2ServerEnabled = null, public ?string $oAuth2ServerAuthorizationUrl = null, public ?array $oAuth2ServerScopes = null, + public ?array $oAuth2ServerDefaultScopes = null, public ?array $oAuth2ServerAuthorizationDetailsTypes = null, public ?int $oAuth2ServerAccessTokenDuration = null, public ?int $oAuth2ServerRefreshTokenDuration = null, @@ -167,6 +171,9 @@ public static function from(array $data): static if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } + if (!array_key_exists('onboarding', $data)) { + throw new \InvalidArgumentException('Missing required field "onboarding" for ' . static::class . '.'); + } if (!array_key_exists('authMethods', $data)) { throw new \InvalidArgumentException('Missing required field "authMethods" for ' . static::class . '.'); } @@ -210,6 +217,7 @@ public static function from(array $data): static pingedAt: $data['pingedAt'], labels: $data['labels'], status: $data['status'], + onboarding: $data['onboarding'], authMethods: is_array($data['authMethods']) ? array_map( static fn (mixed $item): mixed => static::hydrateTypedValue(ProjectAuthMethod::class, $item), @@ -239,6 +247,7 @@ public static function from(array $data): static oAuth2ServerEnabled: array_key_exists('oAuth2ServerEnabled', $data) ? $data['oAuth2ServerEnabled'] : null, oAuth2ServerAuthorizationUrl: array_key_exists('oAuth2ServerAuthorizationUrl', $data) ? $data['oAuth2ServerAuthorizationUrl'] : null, oAuth2ServerScopes: array_key_exists('oAuth2ServerScopes', $data) ? $data['oAuth2ServerScopes'] : null, + oAuth2ServerDefaultScopes: array_key_exists('oAuth2ServerDefaultScopes', $data) ? $data['oAuth2ServerDefaultScopes'] : null, oAuth2ServerAuthorizationDetailsTypes: array_key_exists('oAuth2ServerAuthorizationDetailsTypes', $data) ? $data['oAuth2ServerAuthorizationDetailsTypes'] : null, oAuth2ServerAccessTokenDuration: array_key_exists('oAuth2ServerAccessTokenDuration', $data) ? $data['oAuth2ServerAccessTokenDuration'] : null, oAuth2ServerRefreshTokenDuration: array_key_exists('oAuth2ServerRefreshTokenDuration', $data) ? $data['oAuth2ServerRefreshTokenDuration'] : null, @@ -280,6 +289,7 @@ public function toArray(): array 'pingedAt' => static::serializeValue($this->pingedAt), 'labels' => static::serializeValue($this->labels), 'status' => static::serializeValue($this->status), + 'onboarding' => static::serializeValue($this->onboarding), 'authMethods' => static::serializeValue($this->authMethods), 'services' => static::serializeValue($this->services), 'protocols' => static::serializeValue($this->protocols), @@ -289,6 +299,7 @@ public function toArray(): array 'oAuth2ServerEnabled' => static::serializeValue($this->oAuth2ServerEnabled), 'oAuth2ServerAuthorizationUrl' => static::serializeValue($this->oAuth2ServerAuthorizationUrl), 'oAuth2ServerScopes' => static::serializeValue($this->oAuth2ServerScopes), + 'oAuth2ServerDefaultScopes' => static::serializeValue($this->oAuth2ServerDefaultScopes), 'oAuth2ServerAuthorizationDetailsTypes' => static::serializeValue($this->oAuth2ServerAuthorizationDetailsTypes), 'oAuth2ServerAccessTokenDuration' => static::serializeValue($this->oAuth2ServerAccessTokenDuration), 'oAuth2ServerRefreshTokenDuration' => static::serializeValue($this->oAuth2ServerRefreshTokenDuration), diff --git a/src/Appwrite/Models/UsageBillingPlan.php b/src/Appwrite/Models/UsageBillingPlan.php new file mode 100644 index 00000000..790e95f0 --- /dev/null +++ b/src/Appwrite/Models/UsageBillingPlan.php @@ -0,0 +1,117 @@ + $data + */ + public static function from(array $data): static + { + if (!array_key_exists('bandwidth', $data)) { + throw new \InvalidArgumentException('Missing required field "bandwidth" for ' . static::class . '.'); + } + if (!array_key_exists('executions', $data)) { + throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.'); + } + if (!array_key_exists('member', $data)) { + throw new \InvalidArgumentException('Missing required field "member" for ' . static::class . '.'); + } + if (!array_key_exists('realtime', $data)) { + throw new \InvalidArgumentException('Missing required field "realtime" for ' . static::class . '.'); + } + if (!array_key_exists('realtimeMessages', $data)) { + throw new \InvalidArgumentException('Missing required field "realtimeMessages" for ' . static::class . '.'); + } + if (!array_key_exists('realtimeBandwidth', $data)) { + throw new \InvalidArgumentException('Missing required field "realtimeBandwidth" for ' . static::class . '.'); + } + if (!array_key_exists('storage', $data)) { + throw new \InvalidArgumentException('Missing required field "storage" for ' . static::class . '.'); + } + if (!array_key_exists('users', $data)) { + throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); + } + if (!array_key_exists('GBHours', $data)) { + throw new \InvalidArgumentException('Missing required field "GBHours" for ' . static::class . '.'); + } + if (!array_key_exists('imageTransformations', $data)) { + throw new \InvalidArgumentException('Missing required field "imageTransformations" for ' . static::class . '.'); + } + if (!array_key_exists('credits', $data)) { + throw new \InvalidArgumentException('Missing required field "credits" for ' . static::class . '.'); + } + + return new static( + bandwidth: static::hydrateTypedValue(AdditionalResource::class, $data['bandwidth']), + executions: static::hydrateTypedValue(AdditionalResource::class, $data['executions']), + member: static::hydrateTypedValue(AdditionalResource::class, $data['member']), + realtime: static::hydrateTypedValue(AdditionalResource::class, $data['realtime']), + realtimeMessages: static::hydrateTypedValue(AdditionalResource::class, $data['realtimeMessages']), + realtimeBandwidth: static::hydrateTypedValue(AdditionalResource::class, $data['realtimeBandwidth']), + storage: static::hydrateTypedValue(AdditionalResource::class, $data['storage']), + users: static::hydrateTypedValue(AdditionalResource::class, $data['users']), + gBHours: static::hydrateTypedValue(AdditionalResource::class, $data['GBHours']), + imageTransformations: static::hydrateTypedValue(AdditionalResource::class, $data['imageTransformations']), + credits: static::hydrateTypedValue(AdditionalResource::class, $data['credits']) + ); + } + + /** + * @return array + */ + public function toArray(): array + { + $result = [ + 'bandwidth' => static::serializeValue($this->bandwidth), + 'executions' => static::serializeValue($this->executions), + 'member' => static::serializeValue($this->member), + 'realtime' => static::serializeValue($this->realtime), + 'realtimeMessages' => static::serializeValue($this->realtimeMessages), + 'realtimeBandwidth' => static::serializeValue($this->realtimeBandwidth), + 'storage' => static::serializeValue($this->storage), + 'users' => static::serializeValue($this->users), + 'GBHours' => static::serializeValue($this->gBHours), + 'imageTransformations' => static::serializeValue($this->imageTransformations), + 'credits' => static::serializeValue($this->credits) + ]; + + return $result; + } +} diff --git a/src/Appwrite/Models/UsageEventList.php b/src/Appwrite/Models/UsageEventList.php deleted file mode 100644 index c6fda5bd..00000000 --- a/src/Appwrite/Models/UsageEventList.php +++ /dev/null @@ -1,66 +0,0 @@ - $groups aggregated groups ordered by time ascending. - */ - public function __construct( - public string $metric, - public string $interval, - public array $groups - ) { - } - - /** - * @param array $data - */ - public static function from(array $data): static - { - if (!array_key_exists('metric', $data)) { - throw new \InvalidArgumentException('Missing required field "metric" for ' . static::class . '.'); - } - if (!array_key_exists('interval', $data)) { - throw new \InvalidArgumentException('Missing required field "interval" for ' . static::class . '.'); - } - if (!array_key_exists('groups', $data)) { - throw new \InvalidArgumentException('Missing required field "groups" for ' . static::class . '.'); - } - - return new static( - metric: $data['metric'], - interval: $data['interval'], - groups: is_array($data['groups']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(UsageGroup::class, $item), - $data['groups'] - ) - : $data['groups'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - $result = [ - 'metric' => static::serializeValue($this->metric), - 'interval' => static::serializeValue($this->interval), - 'groups' => static::serializeValue($this->groups) - ]; - - return $result; - } -} diff --git a/src/Appwrite/Models/UsageGaugeList.php b/src/Appwrite/Models/UsageGaugeList.php deleted file mode 100644 index d644dad6..00000000 --- a/src/Appwrite/Models/UsageGaugeList.php +++ /dev/null @@ -1,66 +0,0 @@ - $groups aggregated groups ordered by time ascending. each group carries the latest snapshot in its interval (argmax over time). - */ - public function __construct( - public string $metric, - public string $interval, - public array $groups - ) { - } - - /** - * @param array $data - */ - public static function from(array $data): static - { - if (!array_key_exists('metric', $data)) { - throw new \InvalidArgumentException('Missing required field "metric" for ' . static::class . '.'); - } - if (!array_key_exists('interval', $data)) { - throw new \InvalidArgumentException('Missing required field "interval" for ' . static::class . '.'); - } - if (!array_key_exists('groups', $data)) { - throw new \InvalidArgumentException('Missing required field "groups" for ' . static::class . '.'); - } - - return new static( - metric: $data['metric'], - interval: $data['interval'], - groups: is_array($data['groups']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(UsageGroup::class, $item), - $data['groups'] - ) - : $data['groups'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - $result = [ - 'metric' => static::serializeValue($this->metric), - 'interval' => static::serializeValue($this->interval), - 'groups' => static::serializeValue($this->groups) - ]; - - return $result; - } -} diff --git a/src/Appwrite/Models/UsageGroup.php b/src/Appwrite/Models/UsageGroup.php deleted file mode 100644 index 8518023c..00000000 --- a/src/Appwrite/Models/UsageGroup.php +++ /dev/null @@ -1,106 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('time', $data)) { - throw new \InvalidArgumentException('Missing required field "time" for ' . static::class . '.'); - } - if (!array_key_exists('value', $data)) { - throw new \InvalidArgumentException('Missing required field "value" for ' . static::class . '.'); - } - - return new static( - time: $data['time'], - value: $data['value'], - path: array_key_exists('path', $data) ? $data['path'] : null, - method: array_key_exists('method', $data) ? $data['method'] : null, - status: array_key_exists('status', $data) ? $data['status'] : null, - service: array_key_exists('service', $data) ? $data['service'] : null, - country: array_key_exists('country', $data) ? $data['country'] : null, - region: array_key_exists('region', $data) ? $data['region'] : null, - hostname: array_key_exists('hostname', $data) ? $data['hostname'] : null, - osName: array_key_exists('osName', $data) ? $data['osName'] : null, - clientType: array_key_exists('clientType', $data) ? $data['clientType'] : null, - clientName: array_key_exists('clientName', $data) ? $data['clientName'] : null, - deviceName: array_key_exists('deviceName', $data) ? $data['deviceName'] : null, - teamId: array_key_exists('teamId', $data) ? $data['teamId'] : null, - resourceId: array_key_exists('resourceId', $data) ? $data['resourceId'] : null - ); - } - - /** - * @return array - */ - public function toArray(): array - { - $result = [ - 'time' => static::serializeValue($this->time), - 'value' => static::serializeValue($this->value), - 'path' => static::serializeValue($this->path), - 'method' => static::serializeValue($this->method), - 'status' => static::serializeValue($this->status), - 'service' => static::serializeValue($this->service), - 'country' => static::serializeValue($this->country), - 'region' => static::serializeValue($this->region), - 'hostname' => static::serializeValue($this->hostname), - 'osName' => static::serializeValue($this->osName), - 'clientType' => static::serializeValue($this->clientType), - 'clientName' => static::serializeValue($this->clientName), - 'deviceName' => static::serializeValue($this->deviceName), - 'teamId' => static::serializeValue($this->teamId), - 'resourceId' => static::serializeValue($this->resourceId) - ]; - - return $result; - } -} diff --git a/src/Appwrite/Query.php b/src/Appwrite/Query.php index a4238640..da0abffa 100644 --- a/src/Appwrite/Query.php +++ b/src/Appwrite/Query.php @@ -573,6 +573,42 @@ public static function distanceLessThan(string $attribute, array $values, int|fl return (new Query('distanceLessThan', $attribute, [[$values, $distance, $meters]]))->__toString(); } + /** + * Vector Dot + * + * @param string $attribute + * @param array $vector + * @return string + */ + public static function vectorDot(string $attribute, array $vector): string + { + return (new Query('vectorDot', $attribute, [$vector]))->__toString(); + } + + /** + * Vector Cosine + * + * @param string $attribute + * @param array $vector + * @return string + */ + public static function vectorCosine(string $attribute, array $vector): string + { + return (new Query('vectorCosine', $attribute, [$vector]))->__toString(); + } + + /** + * Vector Euclidean + * + * @param string $attribute + * @param array $vector + * @return string + */ + public static function vectorEuclidean(string $attribute, array $vector): string + { + return (new Query('vectorEuclidean', $attribute, [$vector]))->__toString(); + } + /** * Intersects * diff --git a/src/Appwrite/Services/Backups.php b/src/Appwrite/Services/Backups.php index d490f2a3..c6cc9542 100644 --- a/src/Appwrite/Services/Backups.php +++ b/src/Appwrite/Services/Backups.php @@ -384,15 +384,26 @@ public function deletePolicy(string $policyId): string /** * Create and trigger a new restoration for a backup on a project. + * + * When restoring a DocumentsDB or VectorsDB database to a new resource, pass + * `newSpecification` to provision the restored database on a different + * specification than the archived one (for example, restoring onto a larger + * or smaller dedicated database). Use `serverless` to restore onto the shared + * pool, or a dedicated specification slug to restore onto a dedicated + * database of that size. The specification must be permitted by the + * organization's plan. `newSpecification` is not supported for + * legacy/TablesDB databases or for bucket restores. + * * * @param string $archiveId * @param array $services * @param ?string $newResourceId * @param ?string $newResourceName + * @param ?string $newSpecification * @throws AppwriteException * @return \Appwrite\Models\BackupRestoration */ - public function createRestoration(string $archiveId, array $services, ?string $newResourceId = null, ?string $newResourceName = null): \Appwrite\Models\BackupRestoration + public function createRestoration(string $archiveId, array $services, ?string $newResourceId = null, ?string $newResourceName = null, ?string $newSpecification = null): \Appwrite\Models\BackupRestoration { $apiPath = str_replace( [], @@ -412,6 +423,10 @@ public function createRestoration(string $archiveId, array $services, ?string $n $apiParams['newResourceName'] = $newResourceName; } + if (!is_null($newSpecification)) { + $apiParams['newSpecification'] = $newSpecification; + } + $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index a9e1e766..8c7d3a33 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -127,6 +127,9 @@ public function create(string $databaseId, string $name, ?bool $enabled = null): * @param ?array $queries * @throws AppwriteException * @return \Appwrite\Models\TransactionList + * + * @deprecated This API has been deprecated since 1.8.0. Please use `listTransactions` instead. + * @see TablesDB::listTransactions */ public function listTransactions(?array $queries = null): \Appwrite\Models\TransactionList { @@ -167,6 +170,9 @@ public function listTransactions(?array $queries = null): \Appwrite\Models\Trans * @param ?int $ttl * @throws AppwriteException * @return \Appwrite\Models\Transaction + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createTransaction` instead. + * @see TablesDB::createTransaction */ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transaction { @@ -208,6 +214,9 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio * @param string $transactionId * @throws AppwriteException * @return \Appwrite\Models\Transaction + * + * @deprecated This API has been deprecated since 1.8.0. Please use `getTransaction` instead. + * @see TablesDB::getTransaction */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { @@ -247,6 +256,9 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact * @param ?bool $rollback * @throws AppwriteException * @return \Appwrite\Models\Transaction + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateTransaction` instead. + * @see TablesDB::updateTransaction */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { @@ -293,6 +305,9 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? * @param string $transactionId * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteTransaction` instead. + * @see TablesDB::deleteTransaction */ public function deleteTransaction(string $transactionId): string { @@ -327,6 +342,9 @@ public function deleteTransaction(string $transactionId): string * @param ?array $operations * @throws AppwriteException * @return \Appwrite\Models\Transaction + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createOperations` instead. + * @see TablesDB::createOperations */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { @@ -1824,6 +1842,9 @@ public function updateLineAttribute(string $databaseId, string $collectionId, st * @param ?bool $encrypt * @throws AppwriteException * @return \Appwrite\Models\AttributeLongtext + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createLongtextColumn` instead. + * @see TablesDB::createLongtextColumn */ public function createLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeLongtext { @@ -1881,6 +1902,9 @@ public function createLongtextAttribute(string $databaseId, string $collectionId * @param ?string $newKey * @throws AppwriteException * @return \Appwrite\Models\AttributeLongtext + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateLongtextColumn` instead. + * @see TablesDB::updateLongtextColumn */ public function updateLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeLongtext { @@ -1931,6 +1955,9 @@ public function updateLongtextAttribute(string $databaseId, string $collectionId * @param ?bool $encrypt * @throws AppwriteException * @return \Appwrite\Models\AttributeMediumtext + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createMediumtextColumn` instead. + * @see TablesDB::createMediumtextColumn */ public function createMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeMediumtext { @@ -1988,6 +2015,9 @@ public function createMediumtextAttribute(string $databaseId, string $collection * @param ?string $newKey * @throws AppwriteException * @return \Appwrite\Models\AttributeMediumtext + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateMediumtextColumn` instead. + * @see TablesDB::updateMediumtextColumn */ public function updateMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeMediumtext { @@ -2474,6 +2504,9 @@ public function updateStringAttribute(string $databaseId, string $collectionId, * @param ?bool $encrypt * @throws AppwriteException * @return \Appwrite\Models\AttributeText + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createTextColumn` instead. + * @see TablesDB::createTextColumn */ public function createTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeText { @@ -2531,6 +2564,9 @@ public function createTextAttribute(string $databaseId, string $collectionId, st * @param ?string $newKey * @throws AppwriteException * @return \Appwrite\Models\AttributeText + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateTextColumn` instead. + * @see TablesDB::updateTextColumn */ public function updateTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeText { @@ -2690,6 +2726,9 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str * @param ?bool $encrypt * @throws AppwriteException * @return \Appwrite\Models\AttributeVarchar + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createVarcharColumn` instead. + * @see TablesDB::createVarcharColumn */ public function createVarcharAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeVarchar { @@ -2749,6 +2788,9 @@ public function createVarcharAttribute(string $databaseId, string $collectionId, * @param ?string $newKey * @throws AppwriteException * @return \Appwrite\Models\AttributeVarchar + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateVarcharColumn` instead. + * @see TablesDB::updateVarcharColumn */ public function updateVarcharAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\AttributeVarchar { diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index 21628d65..1db8154c 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -249,10 +249,11 @@ public function listRuntimes(): \Appwrite\Models\RuntimeList /** * List allowed function specifications for this instance. * + * @param ?string $type * @throws AppwriteException * @return \Appwrite\Models\SpecificationList */ - public function listSpecifications(): \Appwrite\Models\SpecificationList + public function listSpecifications(?string $type = null): \Appwrite\Models\SpecificationList { $apiPath = str_replace( [], @@ -262,6 +263,10 @@ public function listSpecifications(): \Appwrite\Models\SpecificationList $apiParams = []; + if (!is_null($type)) { + $apiParams['type'] = $type; + } + $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['accept'] = 'application/json'; @@ -416,10 +421,7 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul } $apiParams['providerBranches'] = $providerBranches; $apiParams['providerPaths'] = $providerPaths; - - if (!is_null($buildSpecification)) { - $apiParams['buildSpecification'] = $buildSpecification; - } + $apiParams['buildSpecification'] = $buildSpecification; if (!is_null($runtimeSpecification)) { $apiParams['runtimeSpecification'] = $runtimeSpecification; @@ -1111,10 +1113,11 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri * @param string $functionId * @param string $deploymentId * @param ?DeploymentDownloadType $type + * @param ?string $token * @throws AppwriteException * @return string */ - public function getDeploymentDownload(string $functionId, string $deploymentId, ?DeploymentDownloadType $type = null): string + public function getDeploymentDownload(string $functionId, string $deploymentId, ?DeploymentDownloadType $type = null, ?string $token = null): string { $apiPath = str_replace( ['{functionId}', '{deploymentId}'], @@ -1130,6 +1133,10 @@ public function getDeploymentDownload(string $functionId, string $deploymentId, $apiParams['type'] = $type; } + if (!is_null($token)) { + $apiParams['token'] = $token; + } + $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['accept'] = '*/*'; diff --git a/src/Appwrite/Services/Health.php b/src/Appwrite/Services/Health.php deleted file mode 100644 index 66ea3ea9..00000000 --- a/src/Appwrite/Services/Health.php +++ /dev/null @@ -1,1012 +0,0 @@ -client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthStatus::from($response); - - } - - /** - * Check the Appwrite Antivirus server is up and connection is successful. - * - * @throws AppwriteException - * @return \Appwrite\Models\HealthAntivirus - */ - public function getAntivirus(): \Appwrite\Models\HealthAntivirus - { - $apiPath = str_replace( - [], - [], - '/health/anti-virus' - ); - - $apiParams = []; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthAntivirus::from($response); - - } - - /** - * Check the database that backs the audit and activity store. When the - * connection is reachable the endpoint returns a passing status with its - * response time. - * - * - * @throws AppwriteException - * @return \Appwrite\Models\HealthStatusList - */ - public function getAuditsDB(): \Appwrite\Models\HealthStatusList - { - $apiPath = str_replace( - [], - [], - '/health/audits-db' - ); - - $apiParams = []; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthStatusList::from($response); - - } - - /** - * Check the Appwrite in-memory cache servers are up and connection is - * successful. - * - * @throws AppwriteException - * @return \Appwrite\Models\HealthStatusList - */ - public function getCache(): \Appwrite\Models\HealthStatusList - { - $apiPath = str_replace( - [], - [], - '/health/cache' - ); - - $apiParams = []; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthStatusList::from($response); - - } - - /** - * Get the SSL certificate for a domain - * - * @param ?string $domain - * @throws AppwriteException - * @return \Appwrite\Models\HealthCertificate - */ - public function getCertificate(?string $domain = null): \Appwrite\Models\HealthCertificate - { - $apiPath = str_replace( - [], - [], - '/health/certificate' - ); - - $apiParams = []; - - if (!is_null($domain)) { - $apiParams['domain'] = $domain; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthCertificate::from($response); - - } - - /** - * Get console pausing health status. Monitors projects approaching the pause - * threshold to detect potential issues with console access tracking. - * - * - * @param ?int $threshold - * @param ?int $inactivityDays - * @throws AppwriteException - * @return \Appwrite\Models\HealthStatus - */ - public function getConsolePausing(?int $threshold = null, ?int $inactivityDays = null): \Appwrite\Models\HealthStatus - { - $apiPath = str_replace( - [], - [], - '/health/console-pausing' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - if (!is_null($inactivityDays)) { - $apiParams['inactivityDays'] = $inactivityDays; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthStatus::from($response); - - } - - /** - * Check the Appwrite database servers are up and connection is successful. - * - * @throws AppwriteException - * @return \Appwrite\Models\HealthStatusList - */ - public function getDB(): \Appwrite\Models\HealthStatusList - { - $apiPath = str_replace( - [], - [], - '/health/db' - ); - - $apiParams = []; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthStatusList::from($response); - - } - - /** - * Check the Appwrite pub-sub servers are up and connection is successful. - * - * @throws AppwriteException - * @return \Appwrite\Models\HealthStatusList - */ - public function getPubSub(): \Appwrite\Models\HealthStatusList - { - $apiPath = str_replace( - [], - [], - '/health/pubsub' - ); - - $apiParams = []; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthStatusList::from($response); - - } - - /** - * Get the number of audit logs that are waiting to be processed in the - * Appwrite internal queue server. - * - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueAudits(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/audits' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of builds that are waiting to be processed in the Appwrite - * internal queue server. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueBuilds(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/builds' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of certificates that are waiting to be issued against - * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue - * server. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueCertificates(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/certificates' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of database changes that are waiting to be processed in the - * Appwrite internal queue server. - * - * @param ?string $name - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueDatabases(?string $name = null, ?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/databases' - ); - - $apiParams = []; - - if (!is_null($name)) { - $apiParams['name'] = $name; - } - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of background destructive changes that are waiting to be - * processed in the Appwrite internal queue server. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueDeletes(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/deletes' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Returns the amount of failed jobs in a given queue. - * - * - * @param HealthQueueName $name - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getFailedJobs(HealthQueueName $name, ?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - ['{name}'], - [$name], - '/health/queue/failed/{name}' - ); - - $apiParams = []; - $apiParams['name'] = $name; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of function executions that are waiting to be processed in - * the Appwrite internal queue server. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueFunctions(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/functions' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of logs that are waiting to be processed in the Appwrite - * internal queue server. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueLogs(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/logs' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of mails that are waiting to be processed in the Appwrite - * internal queue server. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueMails(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/mails' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of messages that are waiting to be processed in the Appwrite - * internal queue server. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueMessaging(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/messaging' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of migrations that are waiting to be processed in the - * Appwrite internal queue server. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueMigrations(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/migrations' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of metrics that are waiting to be processed in the Appwrite - * stats resources queue. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueStatsResources(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/stats-resources' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of metrics that are waiting to be processed in the Appwrite - * internal queue server. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueUsage(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/stats-usage' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Get the number of webhooks that are waiting to be processed in the Appwrite - * internal queue server. - * - * @param ?int $threshold - * @throws AppwriteException - * @return \Appwrite\Models\HealthQueue - */ - public function getQueueWebhooks(?int $threshold = null): \Appwrite\Models\HealthQueue - { - $apiPath = str_replace( - [], - [], - '/health/queue/webhooks' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthQueue::from($response); - - } - - /** - * Check the Appwrite storage device is up and connection is successful. - * - * @throws AppwriteException - * @return \Appwrite\Models\HealthStatus - */ - public function getStorage(): \Appwrite\Models\HealthStatus - { - $apiPath = str_replace( - [], - [], - '/health/storage' - ); - - $apiParams = []; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthStatus::from($response); - - } - - /** - * Check the Appwrite local storage device is up and connection is successful. - * - * @throws AppwriteException - * @return \Appwrite\Models\HealthStatus - */ - public function getStorageLocal(): \Appwrite\Models\HealthStatus - { - $apiPath = str_replace( - [], - [], - '/health/storage/local' - ); - - $apiParams = []; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthStatus::from($response); - - } - - /** - * Check the Appwrite server time is synced with Google remote NTP server. We - * use this technology to smoothly handle leap seconds with no disruptive - * events. The [Network Time - * Protocol](https://en.wikipedia.org/wiki/Network_Time_Protocol) (NTP) is - * used by hundreds of millions of computers and devices to synchronize their - * clocks over the Internet. If your computer sets its own clock, it likely - * uses NTP. - * - * @throws AppwriteException - * @return \Appwrite\Models\HealthTime - */ - public function getTime(): \Appwrite\Models\HealthTime - { - $apiPath = str_replace( - [], - [], - '/health/time' - ); - - $apiParams = []; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\HealthTime::from($response); - - } -} diff --git a/src/Appwrite/Services/Messaging.php b/src/Appwrite/Services/Messaging.php index 76801acf..ee68c3bc 100644 --- a/src/Appwrite/Services/Messaging.php +++ b/src/Appwrite/Services/Messaging.php @@ -599,53 +599,6 @@ public function delete(string $messageId): string } - /** - * Get the message activity logs listed by its unique ID. - * - * @param string $messageId - * @param ?array $queries - * @param ?bool $total - * @throws AppwriteException - * @return \Appwrite\Models\LogList - */ - public function listMessageLogs(string $messageId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - ['{messageId}'], - [$messageId], - '/messaging/messages/{messageId}/logs' - ); - - $apiParams = []; - $apiParams['messageId'] = $messageId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($total)) { - $apiParams['total'] = $total; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\LogList::from($response); - - } - /** * Get a list of the targets associated with a message. * @@ -2394,100 +2347,6 @@ public function deleteProvider(string $providerId): string } - /** - * Get the provider activity logs listed by its unique ID. - * - * @param string $providerId - * @param ?array $queries - * @param ?bool $total - * @throws AppwriteException - * @return \Appwrite\Models\LogList - */ - public function listProviderLogs(string $providerId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - ['{providerId}'], - [$providerId], - '/messaging/providers/{providerId}/logs' - ); - - $apiParams = []; - $apiParams['providerId'] = $providerId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($total)) { - $apiParams['total'] = $total; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\LogList::from($response); - - } - - /** - * Get the subscriber activity logs listed by its unique ID. - * - * @param string $subscriberId - * @param ?array $queries - * @param ?bool $total - * @throws AppwriteException - * @return \Appwrite\Models\LogList - */ - public function listSubscriberLogs(string $subscriberId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - ['{subscriberId}'], - [$subscriberId], - '/messaging/subscribers/{subscriberId}/logs' - ); - - $apiParams = []; - $apiParams['subscriberId'] = $subscriberId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($total)) { - $apiParams['total'] = $total; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\LogList::from($response); - - } - /** * Get a list of all topics from the current Appwrite project. * @@ -2697,53 +2556,6 @@ public function deleteTopic(string $topicId): string } - /** - * Get the topic activity logs listed by its unique ID. - * - * @param string $topicId - * @param ?array $queries - * @param ?bool $total - * @throws AppwriteException - * @return \Appwrite\Models\LogList - */ - public function listTopicLogs(string $topicId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - ['{topicId}'], - [$topicId], - '/messaging/topics/{topicId}/logs' - ); - - $apiParams = []; - $apiParams['topicId'] = $topicId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - if (!is_null($total)) { - $apiParams['total'] = $total; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\LogList::from($response); - - } - /** * Get a list of all subscribers from the current Appwrite project. * diff --git a/src/Appwrite/Services/Organization.php b/src/Appwrite/Services/Organization.php index d99efb5b..e50f89f5 100644 --- a/src/Appwrite/Services/Organization.php +++ b/src/Appwrite/Services/Organization.php @@ -16,6 +16,111 @@ public function __construct(Client $client) parent::__construct($client); } + /** + * Get the current organization. + * + * @throws AppwriteException + * @return \Appwrite\Models\Organization + */ + public function get(): \Appwrite\Models\Organization + { + $apiPath = str_replace( + [], + [], + '/organization' + ); + + $apiParams = []; + + $apiHeaders = []; + $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; + + $response = $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + + if (!is_array($response)) { + throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); + } + + return \Appwrite\Models\Organization::from($response); + + } + + /** + * Update the current organization's name. + * + * @param string $name + * @throws AppwriteException + * @return \Appwrite\Models\Organization + */ + public function update(string $name): \Appwrite\Models\Organization + { + $apiPath = str_replace( + [], + [], + '/organization' + ); + + $apiParams = []; + $apiParams['name'] = $name; + + $apiHeaders = []; + $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; + + $response = $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + + if (!is_array($response)) { + throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); + } + + return \Appwrite\Models\Organization::from($response); + + } + + /** + * Delete the current organization. All projects that belong to the + * organization are deleted as well. + * + * @throws AppwriteException + * @return string + */ + public function delete(): string + { + $apiPath = str_replace( + [], + [], + '/organization' + ); + + $apiParams = []; + + $apiHeaders = []; + $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['content-type'] = 'application/json'; + + $response = $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + + return $response; + + } + /** * Get a list of all API keys from the current organization. * @@ -222,6 +327,233 @@ public function deleteKey(string $keyId): string } + /** + * Get a list of all memberships from the current organization. + * + * @param ?array $queries + * @param ?string $search + * @param ?bool $total + * @throws AppwriteException + * @return \Appwrite\Models\MembershipList + */ + public function listMemberships(?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\MembershipList + { + $apiPath = str_replace( + [], + [], + '/organization/memberships' + ); + + $apiParams = []; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + if (!is_null($search)) { + $apiParams['search'] = $search; + } + + if (!is_null($total)) { + $apiParams['total'] = $total; + } + + $apiHeaders = []; + $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; + + $response = $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + + if (!is_array($response)) { + throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); + } + + return \Appwrite\Models\MembershipList::from($response); + + } + + /** + * Invite a new member to join the current organization. An email with a link + * to join the organization will be sent to the new member's email address. If + * member doesn't exist in the project it will be automatically created. + * + * @param array $roles + * @param ?string $email + * @param ?string $userId + * @param ?string $phone + * @param ?string $url + * @param ?string $name + * @throws AppwriteException + * @return \Appwrite\Models\Membership + */ + public function createMembership(array $roles, ?string $email = null, ?string $userId = null, ?string $phone = null, ?string $url = null, ?string $name = null): \Appwrite\Models\Membership + { + $apiPath = str_replace( + [], + [], + '/organization/memberships' + ); + + $apiParams = []; + $apiParams['roles'] = $roles; + + if (!is_null($email)) { + $apiParams['email'] = $email; + } + + if (!is_null($userId)) { + $apiParams['userId'] = $userId; + } + + if (!is_null($phone)) { + $apiParams['phone'] = $phone; + } + + if (!is_null($url)) { + $apiParams['url'] = $url; + } + + if (!is_null($name)) { + $apiParams['name'] = $name; + } + + $apiHeaders = []; + $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; + + $response = $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + + if (!is_array($response)) { + throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); + } + + return \Appwrite\Models\Membership::from($response); + + } + + /** + * Get a membership from the current organization by its unique ID. + * + * @param string $membershipId + * @throws AppwriteException + * @return \Appwrite\Models\Membership + */ + public function getMembership(string $membershipId): \Appwrite\Models\Membership + { + $apiPath = str_replace( + ['{membershipId}'], + [$membershipId], + '/organization/memberships/{membershipId}' + ); + + $apiParams = []; + $apiParams['membershipId'] = $membershipId; + + $apiHeaders = []; + $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; + + $response = $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + + if (!is_array($response)) { + throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); + } + + return \Appwrite\Models\Membership::from($response); + + } + + /** + * Modify the roles of a member in the current organization. + * + * @param string $membershipId + * @param array $roles + * @throws AppwriteException + * @return \Appwrite\Models\Membership + */ + public function updateMembership(string $membershipId, array $roles): \Appwrite\Models\Membership + { + $apiPath = str_replace( + ['{membershipId}'], + [$membershipId], + '/organization/memberships/{membershipId}' + ); + + $apiParams = []; + $apiParams['membershipId'] = $membershipId; + $apiParams['roles'] = $roles; + + $apiHeaders = []; + $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; + + $response = $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + + if (!is_array($response)) { + throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); + } + + return \Appwrite\Models\Membership::from($response); + + } + + /** + * Remove a member from the current organization. The member is removed + * whether they accepted the invitation or not; a pending invitation is + * revoked. + * + * @param string $membershipId + * @throws AppwriteException + * @return string + */ + public function deleteMembership(string $membershipId): string + { + $apiPath = str_replace( + ['{membershipId}'], + [$membershipId], + '/organization/memberships/{membershipId}' + ); + + $apiParams = []; + $apiParams['membershipId'] = $membershipId; + + $apiHeaders = []; + $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['content-type'] = 'application/json'; + + $response = $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + + return $response; + + } + /** * Get a list of all projects. You can use the query params to filter your * results. diff --git a/src/Appwrite/Services/Project.php b/src/Appwrite/Services/Project.php index 5e3ba5ac..475d5f8e 100644 --- a/src/Appwrite/Services/Project.php +++ b/src/Appwrite/Services/Project.php @@ -9,6 +9,7 @@ use Appwrite\Enums\ProjectAuthMethodId; use Appwrite\Enums\ProjectKeyScopes; use Appwrite\Enums\ProjectOAuth2GooglePrompt; +use Appwrite\Enums\ProjectOAuth2OidcPrompt; use Appwrite\Enums\ProjectOAuthProviderId; use Appwrite\Enums\ProjectPolicyId; use Appwrite\Enums\ProjectProtocolId; @@ -685,10 +686,11 @@ public function listOAuth2Providers(?array $queries = null, ?bool $total = null) * @param ?int $userCodeLength * @param ?string $userCodeFormat * @param ?int $deviceCodeDuration + * @param ?array $defaultScopes * @throws AppwriteException * @return \Appwrite\Models\Project */ - public function updateOAuth2Server(bool $enabled, string $authorizationUrl, ?array $scopes = null, ?array $authorizationDetailsTypes = null, ?int $accessTokenDuration = null, ?int $refreshTokenDuration = null, ?int $publicAccessTokenDuration = null, ?int $publicRefreshTokenDuration = null, ?bool $confidentialPkce = null, ?string $verificationUrl = null, ?int $userCodeLength = null, ?string $userCodeFormat = null, ?int $deviceCodeDuration = null): \Appwrite\Models\Project + public function updateOAuth2Server(bool $enabled, string $authorizationUrl, ?array $scopes = null, ?array $authorizationDetailsTypes = null, ?int $accessTokenDuration = null, ?int $refreshTokenDuration = null, ?int $publicAccessTokenDuration = null, ?int $publicRefreshTokenDuration = null, ?bool $confidentialPkce = null, ?string $verificationUrl = null, ?int $userCodeLength = null, ?string $userCodeFormat = null, ?int $deviceCodeDuration = null, ?array $defaultScopes = null): \Appwrite\Models\Project { $apiPath = str_replace( [], @@ -723,6 +725,10 @@ public function updateOAuth2Server(bool $enabled, string $authorizationUrl, ?arr } $apiParams['deviceCodeDuration'] = $deviceCodeDuration; + if (!is_null($defaultScopes)) { + $apiParams['defaultScopes'] = $defaultScopes; + } + $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; @@ -831,6 +837,48 @@ public function updateOAuth2Apple(?string $serviceId = null, ?string $keyId = nu } + /** + * Update the project OAuth2 Appwrite configuration. + * + * @param ?string $clientId + * @param ?string $clientSecret + * @param ?bool $enabled + * @throws AppwriteException + * @return \Appwrite\Models\OAuth2Appwrite + */ + public function updateOAuth2Appwrite(?string $clientId = null, ?string $clientSecret = null, ?bool $enabled = null): \Appwrite\Models\OAuth2Appwrite + { + $apiPath = str_replace( + [], + [], + '/project/oauth2/appwrite' + ); + + $apiParams = []; + $apiParams['clientId'] = $clientId; + $apiParams['clientSecret'] = $clientSecret; + $apiParams['enabled'] = $enabled; + + $apiHeaders = []; + $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; + + $response = $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + + if (!is_array($response)) { + throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); + } + + return \Appwrite\Models\OAuth2Appwrite::from($response); + + } + /** * Update the project OAuth2 Auth0 configuration. * @@ -1780,11 +1828,13 @@ public function updateOAuth2Notion(?string $oauthClientId = null, ?string $oauth * @param ?string $authorizationURL * @param ?string $tokenURL * @param ?string $userInfoURL + * @param ?array $prompt + * @param ?int $maxAge * @param ?bool $enabled * @throws AppwriteException * @return \Appwrite\Models\OAuth2Oidc */ - public function updateOAuth2Oidc(?string $clientId = null, ?string $clientSecret = null, ?string $wellKnownURL = null, ?string $authorizationURL = null, ?string $tokenURL = null, ?string $userInfoURL = null, ?bool $enabled = null): \Appwrite\Models\OAuth2Oidc + public function updateOAuth2Oidc(?string $clientId = null, ?string $clientSecret = null, ?string $wellKnownURL = null, ?string $authorizationURL = null, ?string $tokenURL = null, ?string $userInfoURL = null, ?array $prompt = null, ?int $maxAge = null, ?bool $enabled = null): \Appwrite\Models\OAuth2Oidc { $apiPath = str_replace( [], @@ -1799,6 +1849,8 @@ public function updateOAuth2Oidc(?string $clientId = null, ?string $clientSecret $apiParams['authorizationURL'] = $authorizationURL; $apiParams['tokenURL'] = $tokenURL; $apiParams['userInfoURL'] = $userInfoURL; + $apiParams['prompt'] = $prompt; + $apiParams['maxAge'] = $maxAge; $apiParams['enabled'] = $enabled; $apiHeaders = []; diff --git a/src/Appwrite/Services/Sites.php b/src/Appwrite/Services/Sites.php index 6c2c25e3..b7e44fdb 100644 --- a/src/Appwrite/Services/Sites.php +++ b/src/Appwrite/Services/Sites.php @@ -249,10 +249,11 @@ public function listFrameworks(): \Appwrite\Models\FrameworkList /** * List allowed site specifications for this instance. * + * @param ?string $type * @throws AppwriteException * @return \Appwrite\Models\SpecificationList */ - public function listSpecifications(): \Appwrite\Models\SpecificationList + public function listSpecifications(?string $type = null): \Appwrite\Models\SpecificationList { $apiPath = str_replace( [], @@ -262,6 +263,10 @@ public function listSpecifications(): \Appwrite\Models\SpecificationList $apiParams = []; + if (!is_null($type)) { + $apiParams['type'] = $type; + } + $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['accept'] = 'application/json'; @@ -421,10 +426,7 @@ public function update(string $siteId, string $name, Framework $framework, ?bool } $apiParams['providerBranches'] = $providerBranches; $apiParams['providerPaths'] = $providerPaths; - - if (!is_null($buildSpecification)) { - $apiParams['buildSpecification'] = $buildSpecification; - } + $apiParams['buildSpecification'] = $buildSpecification; if (!is_null($runtimeSpecification)) { $apiParams['runtimeSpecification'] = $runtimeSpecification; diff --git a/src/Appwrite/Services/TablesDB.php b/src/Appwrite/Services/TablesDB.php index 4834e5f2..bff7d67b 100644 --- a/src/Appwrite/Services/TablesDB.php +++ b/src/Appwrite/Services/TablesDB.php @@ -76,11 +76,11 @@ public function list(?array $queries = null, ?string $search = null, ?bool $tota * @param string $databaseId * @param string $name * @param ?bool $enabled - * @param ?string $dedicatedDatabaseId + * @param ?string $specification * @throws AppwriteException * @return \Appwrite\Models\Database */ - public function create(string $databaseId, string $name, ?bool $enabled = null, ?string $dedicatedDatabaseId = null): \Appwrite\Models\Database + public function create(string $databaseId, string $name, ?bool $enabled = null, ?string $specification = null): \Appwrite\Models\Database { $apiPath = str_replace( [], @@ -96,8 +96,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, $apiParams['enabled'] = $enabled; } - if (!is_null($dedicatedDatabaseId)) { - $apiParams['dedicatedDatabaseId'] = $dedicatedDatabaseId; + if (!is_null($specification)) { + $apiParams['specification'] = $specification; } $apiHeaders = []; diff --git a/src/Appwrite/Services/Usage.php b/src/Appwrite/Services/Usage.php deleted file mode 100644 index 5da84817..00000000 --- a/src/Appwrite/Services/Usage.php +++ /dev/null @@ -1,218 +0,0 @@ -client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\UsageEventList::from($response); - - } - - /** - * Aggregate usage gauge snapshots. Gauges are point-in-time values (storage - * totals, resource counts, …); each group carries the latest snapshot in - * its interval via `argMax(value, time)`. `metric` is required. - * - * **Two response shapes**: - * - Omit `interval` for a flat top-N table — `argMax(value, time)` per - * dimension combination over the whole window, no time axis. Useful for "top - * 10 resources by current storage". - * - Pass `interval` (`1m`, `15m`, `30m`, `1h`, `1d`) for a time series — - * one snapshot per (time bucket × dimension combination). - * - * `dimensions[]` breaks each row down further — only `resourceId` and - * `teamId` are supported on gauges. `resourceId` and `teamId` parameters - * filter the underlying rows. `orderBy=value`+`orderDir=desc`+`limit=N` - * returns the top-N. When `startAt` is omitted, the default window adapts to - * interval (or 7d when interval is omitted). - * - * @param string $metric - * @param ?string $resourceId - * @param ?string $teamId - * @param ?string $interval - * @param ?array $dimensions - * @param ?string $startAt - * @param ?string $endAt - * @param ?string $orderBy - * @param ?string $orderDir - * @param ?int $limit - * @param ?int $offset - * @throws AppwriteException - * @return \Appwrite\Models\UsageGaugeList - */ - public function listGauges(string $metric, ?string $resourceId = null, ?string $teamId = null, ?string $interval = null, ?array $dimensions = null, ?string $startAt = null, ?string $endAt = null, ?string $orderBy = null, ?string $orderDir = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\UsageGaugeList - { - $apiPath = str_replace( - [], - [], - '/usage/gauges' - ); - - $apiParams = []; - $apiParams['metric'] = $metric; - - if (!is_null($resourceId)) { - $apiParams['resourceId'] = $resourceId; - } - - if (!is_null($teamId)) { - $apiParams['teamId'] = $teamId; - } - - if (!is_null($interval)) { - $apiParams['interval'] = $interval; - } - - if (!is_null($dimensions)) { - $apiParams['dimensions'] = $dimensions; - } - - if (!is_null($startAt)) { - $apiParams['startAt'] = $startAt; - } - - if (!is_null($endAt)) { - $apiParams['endAt'] = $endAt; - } - - if (!is_null($orderBy)) { - $apiParams['orderBy'] = $orderBy; - } - - if (!is_null($orderDir)) { - $apiParams['orderDir'] = $orderDir; - } - - if (!is_null($limit)) { - $apiParams['limit'] = $limit; - } - - if (!is_null($offset)) { - $apiParams['offset'] = $offset; - } - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['accept'] = 'application/json'; - - $response = $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\UsageGaugeList::from($response); - - } -} diff --git a/tests/Appwrite/Services/ActivitiesTest.php b/tests/Appwrite/Services/ActivitiesTest.php index 4f705395..f4daf521 100644 --- a/tests/Appwrite/Services/ActivitiesTest.php +++ b/tests/Appwrite/Services/ActivitiesTest.php @@ -41,9 +41,7 @@ public function testMethodListEvents(): void "time" => "2020-10-15T06:38:00.000+00:00", "projectId" => "610fc2f985ee0", "teamId" => "610fc2f985ee0", - "hostname" => "appwrite.io", - "countryCode" => "US", - "countryName" => "United States" + "hostname" => "appwrite.io" ) ) ); @@ -80,9 +78,7 @@ public function testMethodGetEvent(): void "time" => "2020-10-15T06:38:00.000+00:00", "projectId" => "610fc2f985ee0", "teamId" => "610fc2f985ee0", - "hostname" => "appwrite.io", - "countryCode" => "US", - "countryName" => "United States" + "hostname" => "appwrite.io" ); $this->client diff --git a/tests/Appwrite/Services/BackupsTest.php b/tests/Appwrite/Services/BackupsTest.php index ee9d09d4..da100a87 100644 --- a/tests/Appwrite/Services/BackupsTest.php +++ b/tests/Appwrite/Services/BackupsTest.php @@ -280,7 +280,7 @@ public function testMethodCreateRestoration(): void "migrationId" => "did8jx6ws45jana098ab7", "services" => array(), "resources" => array(), - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => "{databases.database[{oldId, newId, newName, newSpecification}]}" ); $this->client @@ -314,7 +314,7 @@ public function testMethodListRestorations(): void "migrationId" => "did8jx6ws45jana098ab7", "services" => array(), "resources" => array(), - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => "{databases.database[{oldId, newId, newName, newSpecification}]}" ) ) ); @@ -344,7 +344,7 @@ public function testMethodGetRestoration(): void "migrationId" => "did8jx6ws45jana098ab7", "services" => array(), "resources" => array(), - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => "{databases.database[{oldId, newId, newName, newSpecification}]}" ); $this->client diff --git a/tests/Appwrite/Services/HealthTest.php b/tests/Appwrite/Services/HealthTest.php deleted file mode 100644 index 7f76bbb3..00000000 --- a/tests/Appwrite/Services/HealthTest.php +++ /dev/null @@ -1,518 +0,0 @@ -client = Mockery::mock(Client::class); - $this->health = new Health($this->client); - } - - public function testMethodGet(): void - { - $data = array( - "name" => "database", - "ping" => 128, - "status" => "pass" - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->get(); - - $this->assertInstanceOf(\Appwrite\Models\HealthStatus::class, $response); - } - - public function testMethodGetAntivirus(): void - { - $data = array( - "version" => "1.0.0", - "status" => "disabled" - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getAntivirus(); - - $this->assertInstanceOf(\Appwrite\Models\HealthAntivirus::class, $response); - } - - public function testMethodGetAuditsDB(): void - { - $data = array( - "total" => 5, - "statuses" => array( - array( - "name" => "database", - "ping" => 128, - "status" => "pass" - ) - ) - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getAuditsDB(); - - $this->assertInstanceOf(\Appwrite\Models\HealthStatusList::class, $response); - } - - public function testMethodGetCache(): void - { - $data = array( - "total" => 5, - "statuses" => array( - array( - "name" => "database", - "ping" => 128, - "status" => "pass" - ) - ) - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getCache(); - - $this->assertInstanceOf(\Appwrite\Models\HealthStatusList::class, $response); - } - - public function testMethodGetCertificate(): void - { - $data = array( - "name" => "/CN=www.google.com", - "subjectSN" => "[SUBJECTSN]", - "issuerOrganisation" => "[ISSUERORGANISATION]", - "validFrom" => "1704200998", - "validTo" => "1711458597", - "signatureTypeSN" => "RSA-SHA256" - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getCertificate(); - - $this->assertInstanceOf(\Appwrite\Models\HealthCertificate::class, $response); - } - - public function testMethodGetConsolePausing(): void - { - $data = array( - "name" => "database", - "ping" => 128, - "status" => "pass" - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getConsolePausing(); - - $this->assertInstanceOf(\Appwrite\Models\HealthStatus::class, $response); - } - - public function testMethodGetDB(): void - { - $data = array( - "total" => 5, - "statuses" => array( - array( - "name" => "database", - "ping" => 128, - "status" => "pass" - ) - ) - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getDB(); - - $this->assertInstanceOf(\Appwrite\Models\HealthStatusList::class, $response); - } - - public function testMethodGetPubSub(): void - { - $data = array( - "total" => 5, - "statuses" => array( - array( - "name" => "database", - "ping" => 128, - "status" => "pass" - ) - ) - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getPubSub(); - - $this->assertInstanceOf(\Appwrite\Models\HealthStatusList::class, $response); - } - - public function testMethodGetQueueAudits(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueAudits(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueBuilds(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueBuilds(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueCertificates(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueCertificates(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueDatabases(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueDatabases(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueDeletes(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueDeletes(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetFailedJobs(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getFailedJobs( - HealthQueueName::V1DATABASE() - ); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueFunctions(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueFunctions(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueLogs(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueLogs(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueMails(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueMails(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueMessaging(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueMessaging(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueMigrations(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueMigrations(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueStatsResources(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueStatsResources(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueUsage(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueUsage(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetQueueWebhooks(): void - { - $data = array( - "size" => 8 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getQueueWebhooks(); - - $this->assertInstanceOf(\Appwrite\Models\HealthQueue::class, $response); - } - - public function testMethodGetStorage(): void - { - $data = array( - "name" => "database", - "ping" => 128, - "status" => "pass" - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getStorage(); - - $this->assertInstanceOf(\Appwrite\Models\HealthStatus::class, $response); - } - - public function testMethodGetStorageLocal(): void - { - $data = array( - "name" => "database", - "ping" => 128, - "status" => "pass" - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getStorageLocal(); - - $this->assertInstanceOf(\Appwrite\Models\HealthStatus::class, $response); - } - - public function testMethodGetTime(): void - { - $data = array( - "remoteTime" => 1639490751, - "localTime" => 1639490844, - "diff" => 93 - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->health->getTime(); - - $this->assertInstanceOf(\Appwrite\Models\HealthTime::class, $response); - } - -} diff --git a/tests/Appwrite/Services/MessagingTest.php b/tests/Appwrite/Services/MessagingTest.php index 7b5a974c..2c51919a 100644 --- a/tests/Appwrite/Services/MessagingTest.php +++ b/tests/Appwrite/Services/MessagingTest.php @@ -276,52 +276,6 @@ public function testMethodDelete(): void $this->assertSame($data, $response); } - public function testMethodListMessageLogs(): void - { - $data = array( - "total" => 5, - "logs" => array( - array( - "event" => "account.sessions.create", - "userId" => "610fc2f985ee0", - "userEmail" => "john@appwrite.io", - "userName" => "John Doe", - "mode" => "admin", - "userType" => "user", - "ip" => "127.0.0.1", - "time" => "2020-10-15T06:38:00.000+00:00", - "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" - ) - ) - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->messaging->listMessageLogs( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } - public function testMethodListTargets(): void { $data = array( @@ -1090,98 +1044,6 @@ public function testMethodDeleteProvider(): void $this->assertSame($data, $response); } - public function testMethodListProviderLogs(): void - { - $data = array( - "total" => 5, - "logs" => array( - array( - "event" => "account.sessions.create", - "userId" => "610fc2f985ee0", - "userEmail" => "john@appwrite.io", - "userName" => "John Doe", - "mode" => "admin", - "userType" => "user", - "ip" => "127.0.0.1", - "time" => "2020-10-15T06:38:00.000+00:00", - "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" - ) - ) - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->messaging->listProviderLogs( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } - - public function testMethodListSubscriberLogs(): void - { - $data = array( - "total" => 5, - "logs" => array( - array( - "event" => "account.sessions.create", - "userId" => "610fc2f985ee0", - "userEmail" => "john@appwrite.io", - "userName" => "John Doe", - "mode" => "admin", - "userType" => "user", - "ip" => "127.0.0.1", - "time" => "2020-10-15T06:38:00.000+00:00", - "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" - ) - ) - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->messaging->listSubscriberLogs( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } - public function testMethodListTopics(): void { $data = array( @@ -1312,52 +1174,6 @@ public function testMethodDeleteTopic(): void $this->assertSame($data, $response); } - public function testMethodListTopicLogs(): void - { - $data = array( - "total" => 5, - "logs" => array( - array( - "event" => "account.sessions.create", - "userId" => "610fc2f985ee0", - "userEmail" => "john@appwrite.io", - "userName" => "John Doe", - "mode" => "admin", - "userType" => "user", - "ip" => "127.0.0.1", - "time" => "2020-10-15T06:38:00.000+00:00", - "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" - ) - ) - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->messaging->listTopicLogs( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } - public function testMethodListSubscribers(): void { $data = array( diff --git a/tests/Appwrite/Services/OrganizationTest.php b/tests/Appwrite/Services/OrganizationTest.php index 4b573c1b..237ef05f 100644 --- a/tests/Appwrite/Services/OrganizationTest.php +++ b/tests/Appwrite/Services/OrganizationTest.php @@ -20,6 +20,484 @@ protected function setUp(): void $this->organization = new Organization($this->client); } + public function testMethodGet(): void + { + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "VIP", + "total" => 7, + "prefs" => array(), + "billingBudget" => 50, + "budgetAlerts" => array(), + "billingPlan" => "tier-1", + "billingPlanId" => "tier-1", + "billingPlanDetails" => array( + "\$id" => "tier-0", + "name" => "Hobby", + "desc" => "Hobby plan", + "order" => 0, + "price" => 25, + "trial" => 14, + "bandwidth" => 25, + "storage" => 25, + "imageTransformations" => 100, + "screenshotsGenerated" => 50, + "members" => 25, + "webhooks" => 25, + "projects" => 2, + "platforms" => 3, + "users" => 25, + "teams" => 25, + "databases" => 25, + "databasesReads" => 500000, + "databasesWrites" => 250000, + "databasesBatchSize" => 100, + "buckets" => 25, + "fileSize" => 25, + "functions" => 25, + "sites" => 1, + "executions" => 25, + "executionsRetentionCount" => 10000, + "GBHours" => 100, + "realtime" => 25, + "realtimeMessages" => 100000, + "messages" => 1000, + "topics" => 1, + "authPhone" => 10, + "domains" => 5, + "activityLogs" => 7, + "usageLogs" => 30, + "projectInactivityDays" => 7, + "alertLimit" => 80, + "usage" => array( + "bandwidth" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "executions" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "member" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "realtime" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "realtimeMessages" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "realtimeBandwidth" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "storage" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "users" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "GBHours" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "imageTransformations" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "credits" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ) + ), + "addons" => array( + "seats" => array( + "supported" => true, + "planIncluded" => 1, + "limit" => 5, + "type" => "numeric", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "projects" => array( + "supported" => true, + "planIncluded" => 1, + "limit" => 5, + "type" => "numeric", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ) + ), + "budgetCapEnabled" => true, + "customSmtp" => true, + "emailBranding" => true, + "requiresPaymentMethod" => true, + "requiresBillingAddress" => true, + "isAvailable" => true, + "selfService" => true, + "premiumSupport" => true, + "budgeting" => true, + "supportsMockNumbers" => true, + "supportsOrganizationRoles" => true, + "supportsCredits" => true, + "supportsDisposableEmailValidation" => true, + "supportsCanonicalEmailValidation" => true, + "supportsFreeEmailValidation" => true, + "supportsCorporateEmailValidation" => true, + "supportsProjectSpecificRoles" => true, + "backupsEnabled" => true, + "usagePerProject" => true, + "supportedAddons" => array( + "baa" => true, + "premiumGeoDB" => true, + "premiumGeoDBOrg" => true + ), + "backupPolicies" => true, + "deploymentSize" => 30, + "buildSize" => 2000, + "databasesAllowEncrypt" => true, + "group" => "starter" + ), + "billingEmail" => "billing@org.example", + "billingStartDate" => "2020-10-15T06:38:00.000+00:00", + "billingCurrentInvoiceDate" => "2020-10-15T06:38:00.000+00:00", + "billingNextInvoiceDate" => "2020-10-15T06:38:00.000+00:00", + "billingTrialStartDate" => "2020-10-15T06:38:00.000+00:00", + "billingTrialDays" => 14, + "billingAggregationId" => "adbc3de4rddfsd", + "billingInvoiceId" => "adbc3de4rddfsd", + "paymentMethodId" => "adbc3de4rddfsd", + "billingAddressId" => "adbc3de4rddfsd", + "backupPaymentMethodId" => "adbc3de4rddfsd", + "status" => "active", + "remarks" => "Pending initial payment", + "agreementBAA" => "[AGREEMENTBAA]", + "programManagerName" => "[PROGRAMMANAGERNAME]", + "programManagerCalendar" => "[PROGRAMMANAGERCALENDAR]", + "programDiscordChannelName" => "[PROGRAMDISCORDCHANNELNAME]", + "programDiscordChannelUrl" => "[PROGRAMDISCORDCHANNELURL]", + "billingPlanDowngrade" => "tier-1", + "billingTaxId" => "[BILLINGTAXID]", + "markedForDeletion" => true, + "platform" => "imagine", + "projects" => array() + ); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->organization->get(); + + $this->assertInstanceOf(\Appwrite\Models\Organization::class, $response); + } + + public function testMethodUpdate(): void + { + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "name" => "VIP", + "total" => 7, + "prefs" => array(), + "billingBudget" => 50, + "budgetAlerts" => array(), + "billingPlan" => "tier-1", + "billingPlanId" => "tier-1", + "billingPlanDetails" => array( + "\$id" => "tier-0", + "name" => "Hobby", + "desc" => "Hobby plan", + "order" => 0, + "price" => 25, + "trial" => 14, + "bandwidth" => 25, + "storage" => 25, + "imageTransformations" => 100, + "screenshotsGenerated" => 50, + "members" => 25, + "webhooks" => 25, + "projects" => 2, + "platforms" => 3, + "users" => 25, + "teams" => 25, + "databases" => 25, + "databasesReads" => 500000, + "databasesWrites" => 250000, + "databasesBatchSize" => 100, + "buckets" => 25, + "fileSize" => 25, + "functions" => 25, + "sites" => 1, + "executions" => 25, + "executionsRetentionCount" => 10000, + "GBHours" => 100, + "realtime" => 25, + "realtimeMessages" => 100000, + "messages" => 1000, + "topics" => 1, + "authPhone" => 10, + "domains" => 5, + "activityLogs" => 7, + "usageLogs" => 30, + "projectInactivityDays" => 7, + "alertLimit" => 80, + "usage" => array( + "bandwidth" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "executions" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "member" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "realtime" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "realtimeMessages" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "realtimeBandwidth" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "storage" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "users" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "GBHours" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "imageTransformations" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "credits" => array( + "name" => "[NAME]", + "unit" => "GB", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ) + ), + "addons" => array( + "seats" => array( + "supported" => true, + "planIncluded" => 1, + "limit" => 5, + "type" => "numeric", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ), + "projects" => array( + "supported" => true, + "planIncluded" => 1, + "limit" => 5, + "type" => "numeric", + "currency" => "USD", + "price" => 5, + "value" => 25, + "invoiceDesc" => "[INVOICEDESC]" + ) + ), + "budgetCapEnabled" => true, + "customSmtp" => true, + "emailBranding" => true, + "requiresPaymentMethod" => true, + "requiresBillingAddress" => true, + "isAvailable" => true, + "selfService" => true, + "premiumSupport" => true, + "budgeting" => true, + "supportsMockNumbers" => true, + "supportsOrganizationRoles" => true, + "supportsCredits" => true, + "supportsDisposableEmailValidation" => true, + "supportsCanonicalEmailValidation" => true, + "supportsFreeEmailValidation" => true, + "supportsCorporateEmailValidation" => true, + "supportsProjectSpecificRoles" => true, + "backupsEnabled" => true, + "usagePerProject" => true, + "supportedAddons" => array( + "baa" => true, + "premiumGeoDB" => true, + "premiumGeoDBOrg" => true + ), + "backupPolicies" => true, + "deploymentSize" => 30, + "buildSize" => 2000, + "databasesAllowEncrypt" => true, + "group" => "starter" + ), + "billingEmail" => "billing@org.example", + "billingStartDate" => "2020-10-15T06:38:00.000+00:00", + "billingCurrentInvoiceDate" => "2020-10-15T06:38:00.000+00:00", + "billingNextInvoiceDate" => "2020-10-15T06:38:00.000+00:00", + "billingTrialStartDate" => "2020-10-15T06:38:00.000+00:00", + "billingTrialDays" => 14, + "billingAggregationId" => "adbc3de4rddfsd", + "billingInvoiceId" => "adbc3de4rddfsd", + "paymentMethodId" => "adbc3de4rddfsd", + "billingAddressId" => "adbc3de4rddfsd", + "backupPaymentMethodId" => "adbc3de4rddfsd", + "status" => "active", + "remarks" => "Pending initial payment", + "agreementBAA" => "[AGREEMENTBAA]", + "programManagerName" => "[PROGRAMMANAGERNAME]", + "programManagerCalendar" => "[PROGRAMMANAGERCALENDAR]", + "programDiscordChannelName" => "[PROGRAMDISCORDCHANNELNAME]", + "programDiscordChannelUrl" => "[PROGRAMDISCORDCHANNELURL]", + "billingPlanDowngrade" => "tier-1", + "billingTaxId" => "[BILLINGTAXID]", + "markedForDeletion" => true, + "platform" => "imagine", + "projects" => array() + ); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->organization->update( + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\Organization::class, $response); + } + + public function testMethodDelete(): void + { + $data = ''; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->organization->delete(); + + $this->assertSame($data, $response); + } + public function testMethodListKeys(): void { $data = array( @@ -157,6 +635,164 @@ public function testMethodDeleteKey(): void $this->assertSame($data, $response); } + public function testMethodListMemberships(): void + { + $data = array( + "total" => 5, + "memberships" => array( + array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c16897e", + "userName" => "John Doe", + "userEmail" => "john@appwrite.io", + "userPhone" => "+1 555 555 5555", + "teamId" => "5e5ea5c16897e", + "teamName" => "VIP", + "invited" => "2020-10-15T06:38:00.000+00:00", + "joined" => "2020-10-15T06:38:00.000+00:00", + "confirm" => true, + "mfa" => true, + "userAccessedAt" => "2020-10-15T06:38:00.000+00:00", + "roles" => array() + ) + ) + ); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->organization->listMemberships(); + + $this->assertInstanceOf(\Appwrite\Models\MembershipList::class, $response); + } + + public function testMethodCreateMembership(): void + { + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c16897e", + "userName" => "John Doe", + "userEmail" => "john@appwrite.io", + "userPhone" => "+1 555 555 5555", + "teamId" => "5e5ea5c16897e", + "teamName" => "VIP", + "invited" => "2020-10-15T06:38:00.000+00:00", + "joined" => "2020-10-15T06:38:00.000+00:00", + "confirm" => true, + "mfa" => true, + "userAccessedAt" => "2020-10-15T06:38:00.000+00:00", + "roles" => array() + ); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->organization->createMembership( + array() + ); + + $this->assertInstanceOf(\Appwrite\Models\Membership::class, $response); + } + + public function testMethodGetMembership(): void + { + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c16897e", + "userName" => "John Doe", + "userEmail" => "john@appwrite.io", + "userPhone" => "+1 555 555 5555", + "teamId" => "5e5ea5c16897e", + "teamName" => "VIP", + "invited" => "2020-10-15T06:38:00.000+00:00", + "joined" => "2020-10-15T06:38:00.000+00:00", + "confirm" => true, + "mfa" => true, + "userAccessedAt" => "2020-10-15T06:38:00.000+00:00", + "roles" => array() + ); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->organization->getMembership( + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\Membership::class, $response); + } + + public function testMethodUpdateMembership(): void + { + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "userId" => "5e5ea5c16897e", + "userName" => "John Doe", + "userEmail" => "john@appwrite.io", + "userPhone" => "+1 555 555 5555", + "teamId" => "5e5ea5c16897e", + "teamName" => "VIP", + "invited" => "2020-10-15T06:38:00.000+00:00", + "joined" => "2020-10-15T06:38:00.000+00:00", + "confirm" => true, + "mfa" => true, + "userAccessedAt" => "2020-10-15T06:38:00.000+00:00", + "roles" => array() + ); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->organization->updateMembership( + "", + array() + ); + + $this->assertInstanceOf(\Appwrite\Models\Membership::class, $response); + } + + public function testMethodDeleteMembership(): void + { + $data = ''; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->organization->deleteMembership( + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodListProjects(): void { $data = array( @@ -195,6 +831,7 @@ public function testMethodListProjects(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -218,6 +855,7 @@ public function testMethodListProjects(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -277,6 +915,7 @@ public function testMethodCreateProject(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -300,6 +939,7 @@ public function testMethodCreateProject(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -360,6 +1000,7 @@ public function testMethodGetProject(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -383,6 +1024,7 @@ public function testMethodGetProject(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -442,6 +1084,7 @@ public function testMethodUpdateProject(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -465,6 +1108,7 @@ public function testMethodUpdateProject(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", diff --git a/tests/Appwrite/Services/ProjectTest.php b/tests/Appwrite/Services/ProjectTest.php index 104c8232..6cf56662 100644 --- a/tests/Appwrite/Services/ProjectTest.php +++ b/tests/Appwrite/Services/ProjectTest.php @@ -9,6 +9,7 @@ use Appwrite\Enums\ProjectAuthMethodId; use Appwrite\Enums\ProjectKeyScopes; use Appwrite\Enums\ProjectOAuth2GooglePrompt; +use Appwrite\Enums\ProjectOAuth2OidcPrompt; use Appwrite\Enums\ProjectOAuthProviderId; use Appwrite\Enums\ProjectPolicyId; use Appwrite\Enums\ProjectProtocolId; @@ -63,6 +64,7 @@ public function testMethodGet(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -86,6 +88,7 @@ public function testMethodGet(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -159,6 +162,7 @@ public function testMethodUpdateAuthMethod(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -182,6 +186,7 @@ public function testMethodUpdateAuthMethod(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -408,6 +413,7 @@ public function testMethodUpdateLabels(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -431,6 +437,7 @@ public function testMethodUpdateLabels(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -624,6 +631,7 @@ public function testMethodUpdateOAuth2Server(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -647,6 +655,7 @@ public function testMethodUpdateOAuth2Server(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -716,6 +725,27 @@ public function testMethodUpdateOAuth2Apple(): void $this->assertInstanceOf(\Appwrite\Models\OAuth2Apple::class, $response); } + public function testMethodUpdateOAuth2Appwrite(): void + { + $data = array( + "\$id" => "github", + "enabled" => true, + "clientId" => "6a42000000000000b5a0", + "clientSecret" => "b86afd000000000000000000000000000000000000000000000000000ced5f93" + ); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->project->updateOAuth2Appwrite(); + + $this->assertInstanceOf(\Appwrite\Models\OAuth2Appwrite::class, $response); + } + public function testMethodUpdateOAuth2Auth0(): void { $data = array( @@ -1196,7 +1226,8 @@ public function testMethodUpdateOAuth2Oidc(): void "wellKnownURL" => "https://myoauth.com/.well-known/openid-configuration", "authorizationURL" => "https://myoauth.com/oauth2/authorize", "tokenURL" => "https://myoauth.com/oauth2/token", - "userInfoURL" => "https://myoauth.com/oauth2/userinfo" + "userInfoURL" => "https://myoauth.com/oauth2/userinfo", + "prompt" => array() ); $this->client @@ -1990,6 +2021,7 @@ public function testMethodUpdateDenyAliasedEmailPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2013,6 +2045,7 @@ public function testMethodUpdateDenyAliasedEmailPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2072,6 +2105,7 @@ public function testMethodUpdateDenyCorporateEmailPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2095,6 +2129,7 @@ public function testMethodUpdateDenyCorporateEmailPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2154,6 +2189,7 @@ public function testMethodUpdateDenyDisposableEmailPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2177,6 +2213,7 @@ public function testMethodUpdateDenyDisposableEmailPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2236,6 +2273,7 @@ public function testMethodUpdateDenyFreeEmailPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2259,6 +2297,7 @@ public function testMethodUpdateDenyFreeEmailPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2318,6 +2357,7 @@ public function testMethodUpdateMembershipPrivacyPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2341,6 +2381,7 @@ public function testMethodUpdateMembershipPrivacyPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2398,6 +2439,7 @@ public function testMethodUpdatePasswordDictionaryPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2421,6 +2463,7 @@ public function testMethodUpdatePasswordDictionaryPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2480,6 +2523,7 @@ public function testMethodUpdatePasswordHistoryPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2503,6 +2547,7 @@ public function testMethodUpdatePasswordHistoryPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2562,6 +2607,7 @@ public function testMethodUpdatePasswordPersonalDataPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2585,6 +2631,7 @@ public function testMethodUpdatePasswordPersonalDataPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2667,6 +2714,7 @@ public function testMethodUpdateSessionAlertPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2690,6 +2738,7 @@ public function testMethodUpdateSessionAlertPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2749,6 +2798,7 @@ public function testMethodUpdateSessionDurationPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2772,6 +2822,7 @@ public function testMethodUpdateSessionDurationPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2831,6 +2882,7 @@ public function testMethodUpdateSessionInvalidationPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2854,6 +2906,7 @@ public function testMethodUpdateSessionInvalidationPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2913,6 +2966,7 @@ public function testMethodUpdateSessionLimitPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -2936,6 +2990,7 @@ public function testMethodUpdateSessionLimitPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -2995,6 +3050,7 @@ public function testMethodUpdateUserLimitPolicy(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -3018,6 +3074,7 @@ public function testMethodUpdateUserLimitPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -3103,6 +3160,7 @@ public function testMethodUpdateProtocol(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -3126,6 +3184,7 @@ public function testMethodUpdateProtocol(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -3186,6 +3245,7 @@ public function testMethodUpdateService(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -3209,6 +3269,7 @@ public function testMethodUpdateService(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", @@ -3269,6 +3330,7 @@ public function testMethodUpdateSMTP(): void "pingedAt" => "2020-10-15T06:38:00.000+00:00", "labels" => array(), "status" => "active", + "onboarding" => array(), "authMethods" => array( array( "\$id" => "email-password", @@ -3292,6 +3354,7 @@ public function testMethodUpdateSMTP(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", + "mode" => "readOnly", "projectName" => "My Project", "region" => "fra", "organizationName" => "Acme Inc.", diff --git a/tests/Appwrite/Services/UsageTest.php b/tests/Appwrite/Services/UsageTest.php deleted file mode 100644 index c7ce46cf..00000000 --- a/tests/Appwrite/Services/UsageTest.php +++ /dev/null @@ -1,75 +0,0 @@ -client = Mockery::mock(Client::class); - $this->usage = new Usage($this->client); - } - - public function testMethodListEvents(): void - { - $data = array( - "metric" => "executions", - "interval" => "1d", - "groups" => array( - array( - "time" => "2026-04-09T12:00:00.000+00:00", - "value" => 5000 - ) - ) - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->usage->listEvents( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\UsageEventList::class, $response); - } - - public function testMethodListGauges(): void - { - $data = array( - "metric" => "files.storage", - "interval" => "1d", - "groups" => array( - array( - "time" => "2026-04-09T12:00:00.000+00:00", - "value" => 5000 - ) - ) - ); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->usage->listGauges( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\UsageGaugeList::class, $response); - } - -}