From f2e5a9eb6d842135a175081107c3f41b5ea56aa9 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 16:36:51 +0100 Subject: [PATCH 1/4] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 14 + README.md | 31 +- composer.json | 1 + docs/account.md | 22 +- docs/apps.md | 2 +- docs/avatars.md | 4 +- docs/databases.md | 4 +- docs/documentsdb.md | 2 +- docs/examples/account/list-logs.md | 18 - docs/examples/avatars/get-screenshot.md | 3 +- docs/examples/databases/create-documents.md | 11 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/upsert-documents.md | 11 +- docs/examples/documentsdb/create-documents.md | 11 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 2 +- docs/examples/documentsdb/upsert-documents.md | 11 +- .../embeddings/create-text-embeddings.md | 2 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/oauth2/approve.md | 4 +- docs/examples/oauth2/authorize-post.md | 6 +- docs/examples/oauth2/authorize.md | 6 +- .../oauth2/create-device-authorization.md | 6 +- docs/examples/oauth2/create-grant.md | 4 +- docs/examples/oauth2/create-par.md | 6 +- docs/examples/oauth2/create-token.md | 6 +- docs/examples/oauth2/get-grant.md | 4 +- docs/examples/oauth2/list-organizations.md | 4 +- docs/examples/oauth2/list-projects.md | 4 +- docs/examples/oauth2/reject.md | 4 +- docs/examples/oauth2/revoke.md | 4 +- docs/examples/organization/create-key.md | 21 - docs/examples/organization/delete-key.md | 17 - docs/examples/organization/get-key.md | 17 - docs/examples/organization/list-keys.md | 18 - docs/examples/organization/update-key.md | 21 - docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-rows.md | 11 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 11 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/list-logs.md | 19 - docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-documents.md | 15 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 10 +- docs/examples/vectorsdb/delete-documents.md | 2 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 15 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- docs/messaging.md | 14 +- docs/mongo.md | 6 +- docs/mysql.md | 6 +- docs/oauth2.md | 10 +- docs/organization.md | 74 +- docs/postgresql.md | 6 +- docs/project.md | 12 +- docs/proxy.md | 4 +- docs/storage.md | 2 +- docs/tablesdb.md | 42 +- docs/teams.md | 2 +- docs/users.md | 19 +- docs/vectorsdb.md | 2 +- docs/webhooks.md | 8 +- src/Appwrite/Client.php | 33 +- src/Appwrite/Enums/BillingPlanGroup.php | 8 - src/Appwrite/Enums/OrganizationKeyScopes.php | 162 ---- src/Appwrite/Models/ActivityEventList.php | 5 +- src/Appwrite/Models/App.php | 5 +- src/Appwrite/Models/AppInstallationList.php | 5 +- src/Appwrite/Models/AppKeyList.php | 5 +- src/Appwrite/Models/AppScopeList.php | 5 +- src/Appwrite/Models/AppSecretList.php | 5 +- src/Appwrite/Models/AppsList.php | 5 +- src/Appwrite/Models/AttributeEnum.php | 4 +- src/Appwrite/Models/AttributeList.php | 5 +- src/Appwrite/Models/BackupArchive.php | 27 +- src/Appwrite/Models/BackupArchiveList.php | 5 +- src/Appwrite/Models/BackupPolicy.php | 9 +- src/Appwrite/Models/BackupPolicyList.php | 5 +- src/Appwrite/Models/BackupRestoration.php | 24 +- src/Appwrite/Models/BackupRestorationList.php | 5 +- src/Appwrite/Models/BillingPlan.php | 16 +- src/Appwrite/Models/Block.php | 42 +- src/Appwrite/Models/BucketList.php | 5 +- src/Appwrite/Models/Collection.php | 13 +- src/Appwrite/Models/CollectionList.php | 5 +- src/Appwrite/Models/ColumnEnum.php | 4 +- src/Appwrite/Models/ColumnIndexList.php | 5 +- src/Appwrite/Models/ColumnList.php | 5 +- src/Appwrite/Models/ContinentList.php | 5 +- src/Appwrite/Models/CountryList.php | 5 +- src/Appwrite/Models/CurrencyList.php | 5 +- src/Appwrite/Models/Database.php | 2 +- src/Appwrite/Models/DatabaseList.php | 5 +- src/Appwrite/Models/DatabaseMigrationList.php | 5 +- src/Appwrite/Models/DatabaseStatus.php | 18 +- src/Appwrite/Models/DedicatedDatabase.php | 55 +- .../Models/DedicatedDatabaseBackupList.php | 5 +- .../Models/DedicatedDatabaseBranch.php | 14 +- .../Models/DedicatedDatabaseBranchList.php | 5 +- .../Models/DedicatedDatabaseExecution.php | 5 +- .../Models/DedicatedDatabaseExtensions.php | 5 +- src/Appwrite/Models/DedicatedDatabaseList.php | 5 +- .../Models/DedicatedDatabaseOperationList.php | 5 +- .../Models/DedicatedDatabaseReplicas.php | 5 +- .../Models/DedicatedDatabaseRestoration.php | 50 +- .../DedicatedDatabaseRestorationList.php | 5 +- .../Models/DedicatedDatabaseSpecification.php | 32 +- .../DedicatedDatabaseSpecificationList.php | 18 +- .../DedicatedDatabaseSpecificationPricing.php | 70 -- src/Appwrite/Models/DeploymentList.php | 5 +- src/Appwrite/Models/DevKey.php | 98 --- src/Appwrite/Models/Document.php | 5 +- src/Appwrite/Models/DocumentList.php | 5 +- src/Appwrite/Models/EmailTemplateList.php | 5 +- src/Appwrite/Models/EmbeddingList.php | 5 +- src/Appwrite/Models/EphemeralKey.php | 5 +- src/Appwrite/Models/Execution.php | 14 +- src/Appwrite/Models/ExecutionList.php | 5 +- src/Appwrite/Models/FileList.php | 5 +- src/Appwrite/Models/Framework.php | 9 +- src/Appwrite/Models/FrameworkList.php | 5 +- src/Appwrite/Models/FunctionList.php | 5 +- src/Appwrite/Models/FunctionModel.php | 5 +- src/Appwrite/Models/Identity.php | 7 +- src/Appwrite/Models/IdentityList.php | 5 +- src/Appwrite/Models/IndexList.php | 5 +- src/Appwrite/Models/Insight.php | 5 +- src/Appwrite/Models/InsightList.php | 5 +- src/Appwrite/Models/Key.php | 5 +- src/Appwrite/Models/KeyList.php | 5 +- src/Appwrite/Models/LanguageList.php | 5 +- src/Appwrite/Models/LocaleCodeList.php | 5 +- src/Appwrite/Models/Log.php | 196 ----- src/Appwrite/Models/LogList.php | 61 -- src/Appwrite/Models/MembershipList.php | 5 +- src/Appwrite/Models/Message.php | 13 +- src/Appwrite/Models/MessageList.php | 5 +- src/Appwrite/Models/MockNumberList.php | 5 +- src/Appwrite/Models/OAuth2Apple.php | 14 +- src/Appwrite/Models/OAuth2Auth0.php | 23 +- src/Appwrite/Models/OAuth2Discord.php | 19 +- src/Appwrite/Models/OAuth2Github.php | 19 +- src/Appwrite/Models/OAuth2Google.php | 14 +- src/Appwrite/Models/OAuth2Microsoft.php | 23 +- src/Appwrite/Models/OAuth2Oidc.php | 16 +- src/Appwrite/Models/OAuth2Okta.php | 25 +- src/Appwrite/Models/OAuth2ProviderList.php | 5 +- src/Appwrite/Models/OAuth2Salesforce.php | 19 +- src/Appwrite/Models/OAuth2Zoho.php | 19 +- src/Appwrite/Models/Oauth2ConsentList.php | 5 +- .../Models/Oauth2ConsentTokenList.php | 5 +- .../Models/Oauth2OrganizationList.php | 5 +- src/Appwrite/Models/Oauth2ProjectList.php | 5 +- src/Appwrite/Models/Organization.php | 63 +- src/Appwrite/Models/Passkey.php | 22 +- src/Appwrite/Models/PasskeyChallenge.php | 22 +- src/Appwrite/Models/PasskeyList.php | 10 +- src/Appwrite/Models/PhoneList.php | 5 +- src/Appwrite/Models/PlatformAndroid.php | 7 +- src/Appwrite/Models/PlatformList.php | 5 +- src/Appwrite/Models/PolicyList.php | 5 +- src/Appwrite/Models/PolicyPasskey.php | 14 +- src/Appwrite/Models/Presence.php | 5 +- src/Appwrite/Models/PresenceList.php | 5 +- src/Appwrite/Models/Project.php | 29 +- src/Appwrite/Models/ProjectList.php | 5 +- src/Appwrite/Models/ProviderList.php | 5 +- src/Appwrite/Models/ProxyRule.php | 2 +- src/Appwrite/Models/ProxyRuleList.php | 5 +- src/Appwrite/Models/Report.php | 5 +- src/Appwrite/Models/ReportList.php | 5 +- src/Appwrite/Models/ResourceTokenList.php | 5 +- src/Appwrite/Models/Row.php | 5 +- src/Appwrite/Models/RowList.php | 5 +- src/Appwrite/Models/Runtime.php | 5 +- src/Appwrite/Models/RuntimeList.php | 5 +- src/Appwrite/Models/SessionList.php | 5 +- src/Appwrite/Models/Site.php | 4 +- src/Appwrite/Models/SiteList.php | 5 +- src/Appwrite/Models/SpecificationList.php | 5 +- src/Appwrite/Models/SubscriberList.php | 5 +- src/Appwrite/Models/Table.php | 13 +- src/Appwrite/Models/TableList.php | 5 +- src/Appwrite/Models/TargetList.php | 5 +- src/Appwrite/Models/TeamList.php | 5 +- src/Appwrite/Models/TokenSecret.php | 26 +- src/Appwrite/Models/Topic.php | 2 +- src/Appwrite/Models/TopicList.php | 5 +- src/Appwrite/Models/TransactionList.php | 5 +- src/Appwrite/Models/UsageBillingPlan.php | 72 +- src/Appwrite/Models/User.php | 4 +- src/Appwrite/Models/UserList.php | 5 +- src/Appwrite/Models/VariableList.php | 5 +- src/Appwrite/Models/VectorsdbCollection.php | 13 +- .../Models/VectorsdbCollectionList.php | 5 +- src/Appwrite/Models/Webhook.php | 2 +- src/Appwrite/Models/WebhookList.php | 5 +- src/Appwrite/Services/Account.php | 100 ++- src/Appwrite/Services/Activities.php | 4 + src/Appwrite/Services/Advisor.php | 21 + src/Appwrite/Services/Apps.php | 100 +++ src/Appwrite/Services/Avatars.php | 6 +- src/Appwrite/Services/Backups.php | 24 + src/Appwrite/Services/Databases.php | 664 ++++++++++++++- src/Appwrite/Services/DocumentsDB.php | 253 +++++- src/Appwrite/Services/Functions.php | 131 ++- src/Appwrite/Services/Messaging.php | 125 ++- src/Appwrite/Services/Mongo.php | 149 +++- src/Appwrite/Services/Mysql.php | 161 +++- src/Appwrite/Services/Oauth2.php | 14 +- src/Appwrite/Services/Organization.php | 222 +---- src/Appwrite/Services/Postgresql.php | 177 +++- src/Appwrite/Services/Presences.php | 17 + src/Appwrite/Services/Project.php | 77 +- src/Appwrite/Services/Proxy.php | 15 + src/Appwrite/Services/Sites.php | 131 ++- src/Appwrite/Services/Storage.php | 88 +- src/Appwrite/Services/TablesDB.php | 794 +++++++++++++++++- src/Appwrite/Services/Teams.php | 94 +++ src/Appwrite/Services/Tokens.php | 29 + src/Appwrite/Services/Users.php | 210 +++-- src/Appwrite/Services/VectorsDB.php | 234 +++++- src/Appwrite/Services/Webhooks.php | 22 +- tests/Appwrite/ClientTest.php | 83 +- tests/Appwrite/Services/AccountTest.php | 46 +- tests/Appwrite/Services/BackupsTest.php | 17 +- tests/Appwrite/Services/DocumentsDBTest.php | 24 +- tests/Appwrite/Services/FunctionsTest.php | 6 +- tests/Appwrite/Services/MongoTest.php | 114 +-- tests/Appwrite/Services/MysqlTest.php | 114 +-- tests/Appwrite/Services/Oauth2Test.php | 4 +- tests/Appwrite/Services/OrganizationTest.php | 361 +------- tests/Appwrite/Services/PostgresqlTest.php | 130 +-- tests/Appwrite/Services/ProjectTest.php | 499 ++--------- tests/Appwrite/Services/SitesTest.php | 4 +- tests/Appwrite/Services/TablesDBTest.php | 90 +- tests/Appwrite/Services/UsersTest.php | 48 +- tests/Appwrite/Services/VectorsDBTest.php | 24 +- 251 files changed, 4460 insertions(+), 3515 deletions(-) delete mode 100644 docs/examples/account/list-logs.md delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/delete-key.md delete mode 100644 docs/examples/organization/get-key.md delete mode 100644 docs/examples/organization/list-keys.md delete mode 100644 docs/examples/organization/update-key.md delete mode 100644 docs/examples/users/list-logs.md delete mode 100644 src/Appwrite/Enums/OrganizationKeyScopes.php delete mode 100644 src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php delete mode 100644 src/Appwrite/Models/DevKey.php delete mode 100644 src/Appwrite/Models/Log.php delete mode 100644 src/Appwrite/Models/LogList.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 7353dbb9..82d2109e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Change Log +## 31.0.0 + +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `Account::listLogs`, `Users::listLogs` and the `Log`/`LogList` models +* Breaking: removed `Organization::createKey`, `listKeys`, `updateKey` and `OrganizationKeyScopes`; use project keys +* Breaking: removed `Client::setDevKey`, the `DevKey` model and `Project::$devKeys` +* Breaking: removed `BillingPlanGroup::STARTER()` +* Breaking: removed the `DedicatedDatabaseSpecificationPricing` model and `DedicatedDatabaseSpecificationList::$pricing` +* Breaking: removed `Block` fields `reason`, `projectName`, `region`, `organizationName`, `organizationId` and `billingPlan` +* Breaking: OAuth2 `resource` params now take `?array` +* Breaking: `Project::updateOAuth2Kakao` takes `$enabled` before `$prompt` +* Breaking: `BackupRestoration::$options` is now an array +* Breaking: some response fields became nullable, such as `BillingPlan::$usage` and `DedicatedDatabase::$engine` + ## 30.4.0 * Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones diff --git a/README.md b/README.md index bd76997b..b1df143c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square&v=1) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 1.9.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-php/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-php/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -22,6 +22,33 @@ composer require appwrite/appwrite Requires PHP 8.5 or later. +### Custom HTTP transport + +For applications that configure their own HTTP transport, pass any PSR-18 client to the constructor. Hosts that run SDK calls concurrently, such as Swoole coroutines, should pass a pooled client so no cURL handle is shared between coroutines: + +```php +use Appwrite\Client; +use Utopia\Client\Adapter\SwooleCoroutine\Client as SwooleAdapter; +use Utopia\Client\Client as HttpClient; +use Utopia\Client\Pool as PooledClient; +use Utopia\Pools\Adapter\Swoole as SwoolePool; +use Utopia\Pools\Pool; + +$client = new Client(new PooledClient(new Pool( + new SwoolePool(), + 'appwrite', + 128, + fn (): HttpClient => new HttpClient(new SwooleAdapter()) + ->withConnectionReuse() + ->withTimeout(5) + ->withConnectTimeout(2), + timeout: 3.0, +))); +$client->setEndpoint('https://cloud.appwrite.io/v1'); +``` + +Configure timeouts, TLS, redirects, and connection reuse on the injected transport. The SDK's `setTimeout()`, `setConnectTimeout()`, and `setSelfSigned()` methods only configure the default cURL transport. Endpoint, authentication, headers, request encoding, and response handling remain the SDK's responsibility. A transport used with `responseType: 'location'` must have redirect following disabled. + ## Getting Started diff --git a/composer.json b/composer.json index 21faff5f..135f6928 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "php": ">=8.5", "ext-curl": "*", "ext-json": "*", + "psr/http-client": "^1.0", "utopia-php/client": "^0.6", "adhocore/jwt": "^1.1" }, diff --git a/docs/account.md b/docs/account.md index 80e592a5..efbee573 100644 --- a/docs/account.md +++ b/docs/account.md @@ -150,20 +150,6 @@ DELETE https://cloud.appwrite.io/v1/account/identities/{identityId} | identityId | string | **Required** Identity ID. | | -```http request -GET https://cloud.appwrite.io/v1/account/logs -``` - -** Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. ** - -### 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). 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 PATCH https://cloud.appwrite.io/v1/account/mfa ``` @@ -591,7 +577,7 @@ GET https://cloud.appwrite.io/v1/account/sessions DELETE https://cloud.appwrite.io/v1/account/sessions ``` -** Delete all sessions from the user account and remove any sessions cookies from the end client. ** +** Delete all sessions from the user account and remove any sessions cookies from the end client. Pass `current` as false to keep the session making the request and sign out of every other session. ** ### Parameters @@ -611,7 +597,7 @@ POST https://cloud.appwrite.io/v1/account/sessions/anonymous POST https://cloud.appwrite.io/v1/account/sessions/email ``` -** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. +** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. Use the optional `duration` parameter to create a shorter session, for example when the user doesn't choose "remember me". It must be at least 60 seconds and cannot exceed the project maximum session length. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). ** @@ -786,13 +772,15 @@ GET https://cloud.appwrite.io/v1/account/tokens/oauth2/{provider} If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. +If there is already an active session, the OAuth2 identity is attached to the logged-in account and that session stays active until the token is exchanged for a new one. + A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). ** ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| provider | string | **Required** OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, 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, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, 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/apps.md b/docs/apps.md index fde01429..60c5d7f5 100644 --- a/docs/apps.md +++ b/docs/apps.md @@ -242,7 +242,7 @@ PUT https://cloud.appwrite.io/v1/apps/{appId}/labels | Field Name | Type | Description | Default | | --- | --- | --- | --- | | appId | string | **Required** Application unique ID. | | -| labels | array | Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | | +| labels | array | Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. Reserved labels are rejected. | | ```http request diff --git a/docs/avatars.md b/docs/avatars.md index 7b9377d2..d5713014 100644 --- a/docs/avatars.md +++ b/docs/avatars.md @@ -116,7 +116,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre GET https://cloud.appwrite.io/v1/avatars/photo ``` -** Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. +** Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: a custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. Passing `userId` — `current()` for the authenticated user — resolves the photo from everything known about that user: identity photos, email, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. ** @@ -186,7 +186,7 @@ When width and height are specified, the image is resized accordingly. If both d | Field Name | Type | Description | Default | | --- | --- | --- | --- | | url | string | **Required** Website URL which you want to capture. | | -| headers | object | HTTP headers to send with the browser request. Defaults to empty. | {} | +| headers | object | HTTP headers to send with the browser request. Only Accept and Accept-Language are allowed. Defaults to empty. | {} | | viewportWidth | integer | Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. | 1280 | | viewportHeight | integer | Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. | 720 | | scale | number | Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. | 1 | diff --git a/docs/databases.md b/docs/databases.md index 1b1f7bf6..042e19e4 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -188,7 +188,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections | documentSecurity | boolean | Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. | 1 | | attributes | array | Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. | [] | -| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | +| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | ```http request @@ -1210,7 +1210,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection ``` ** Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. -Attributes can be `key`, `fulltext`, and `unique`. ** +Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use an index. ** ### Parameters diff --git a/docs/documentsdb.md b/docs/documentsdb.md index 4f650b12..24756cc1 100644 --- a/docs/documentsdb.md +++ b/docs/documentsdb.md @@ -38,7 +38,7 @@ POST https://cloud.appwrite.io/v1/documentsdb GET https://cloud.appwrite.io/v1/documentsdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 17e51352..00000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,18 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with - -$account = new Account($client); - -$result = $account->listLogs( - queries: [], // optional - total: false // optional -); -``` diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 59fbd663..a5eb5e99 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -18,8 +18,7 @@ $avatars = new Avatars($client); $result = $avatars->getScreenshot( url: 'https://example.com', headers: [ - 'Authorization' => 'Bearer token123', - 'X-Custom-Header' => 'value' + 'Accept-Language' => 'en-US,en;q=0.9' ], // optional viewportWidth: 1920, // optional viewportHeight: 1080, // optional diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 1f64387b..de0fae2b 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -14,7 +14,16 @@ $databases = new Databases($client); $result = $databases->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 1005239e..cd5e8c0c 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -18,7 +18,7 @@ $result = $databases->createIndex( collectionId: '', key: '', type: DatabasesIndexType::KEY(), - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index f39cbfe0..5d586039 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -14,7 +14,7 @@ $databases = new Databases($client); $result = $databases->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 0049fdc6..60877dc3 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -14,7 +14,16 @@ $databases = new Databases($client); $result = $databases->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index ec6a4355..ce85177c 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -14,7 +14,16 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index b64d1f8a..68506db4 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -18,7 +18,7 @@ $result = $documentsDB->createIndex( collectionId: '', key: '', type: DocumentsDBIndexType::KEY(), - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index b77b3756..f005fea3 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -14,7 +14,7 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index 09021e0a..95ed28a7 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -14,7 +14,16 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 70f0f7e1..476f9741 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -13,7 +13,7 @@ $client = (new Client()) $embeddings = new Embeddings($client); $result = $embeddings->createTextEmbeddings( - texts: [], + texts: ["Appwrite helps developers build applications.", "Find documents with semantic search."], model: EmbeddingModel::NOMICEMBEDTEXT() // optional ); ``` diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index c2f1b989..26792681 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -12,6 +12,8 @@ $client = (new Client()) $graphql = new Graphql($client); $result = $graphql->mutation( - query: [] + query: [ + 'query' => 'mutation { accountUpdateName(name: "Walter") { name } }' + ] ); ``` diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 9731e998..f5e562c1 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -12,6 +12,8 @@ $client = (new Client()) $graphql = new Graphql($client); $result = $graphql->query( - query: [] + query: [ + 'query' => 'query { localeGet { ip } }' + ] ); ``` diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 568d28d9..4f96e8ac 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -14,7 +14,7 @@ $messaging = new Messaging($client); $result = $messaging->createTwilioProvider( providerId: '', name: '', - from: '+12065550100', // optional + from: '', // optional accountSid: '', // optional authToken: '', // optional enabled: false // optional diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 5540b110..2a9f07aa 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index d7a465ad..a99f3604 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->authorizePost( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '' // optional ); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index ad373715..3765b5a3 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->authorize( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '' // optional ); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index 00358d8a..6385a1a1 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -15,7 +15,7 @@ $result = $oauth2->createDeviceAuthorization( clientId: '', // optional scope: '', // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 95467652..a0328e69 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index ddb3d7d6..9c57b1df 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->createPAR( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index a4be2d6f..8ec9d22f 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -20,7 +20,7 @@ $result = $oauth2->createToken( clientSecret: '', // optional codeVerifier: '', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index a6469c30..d83efe8f 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index 49c1f499..7237c3f8 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 3bbcf901..9abc1548 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index bd98d721..0cc9cf7f 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 7122ed7f..1e823003 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index c7cb7dde..00000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,21 +0,0 @@ -```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->createKey( - keyId: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTSREAD()], - expire: '2020-10-15T06:38:00.000+00:00' // optional -); -``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/organization/delete-key.md deleted file mode 100644 index ca72f3dd..00000000 --- a/docs/examples/organization/delete-key.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 - -$organization = new Organization($client); - -$result = $organization->deleteKey( - keyId: '' -); -``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/organization/get-key.md deleted file mode 100644 index bf651e9e..00000000 --- a/docs/examples/organization/get-key.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 - -$organization = new Organization($client); - -$result = $organization->getKey( - keyId: '' -); -``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/organization/list-keys.md deleted file mode 100644 index dbe27502..00000000 --- a/docs/examples/organization/list-keys.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 - -$organization = new Organization($client); - -$result = $organization->listKeys( - queries: [], // optional - total: false // optional -); -``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index 575e6119..00000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,21 +0,0 @@ -```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->updateKey( - keyId: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTSREAD()], - expire: '2020-10-15T06:38:00.000+00:00' // optional -); -``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 224dc841..763800e6 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -13,7 +13,7 @@ $client = (new Client()) $project = new Project($client); $result = $project->createEphemeralKey( - scopes: [ProjectKeyScopes::PROJECTREAD()], + scopes: [ProjectKeyScopes::USERSREAD()], duration: 600 ); ``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index a16026a8..e0045750 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -12,6 +12,6 @@ $client = (new Client()) $project = new Project($client); $result = $project->createSMTPTest( - emails: [] + emails: ["recipient@example.com"] ); ``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index db883945..ae2996b7 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -15,7 +15,7 @@ $project = new Project($client); $result = $project->updateKey( keyId: '', name: '', - scopes: [ProjectKeyScopes::PROJECTREAD()], + scopes: [ProjectKeyScopes::USERSREAD()], expire: '2020-10-15T06:38:00.000+00:00' // optional ); ``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index aace3165..1aba5430 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -12,6 +12,6 @@ $client = (new Client()) $project = new Project($client); $result = $project->updateLabels( - labels: [] + labels: ["production"] ); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index 78fe1cbd..7f88288e 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -15,7 +15,7 @@ $project = new Project($client); $result = $project->updateOAuth2Kakao( clientId: '', // optional clientSecret: '', // optional - prompt: [ProjectOAuth2KakaoPrompt::NONE()], // optional - enabled: false // optional + enabled: false, // optional + prompt: [ProjectOAuth2KakaoPrompt::NONE()] // optional ); ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 2b840eb3..89e4650c 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -18,7 +18,7 @@ $result = $tablesDB->createIndex( tableId: '', key: '', type: TablesDBIndexType::KEY(), - columns: [], + columns: ["username"], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 6ae0f802..240ddc08 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -14,7 +14,16 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->createRows( databaseId: '', tableId: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 2b13b6c7..192f5276 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -14,7 +14,7 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->deleteRows( databaseId: '', tableId: '', - queries: [], // optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index 56aa2657..6150f35e 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -14,7 +14,16 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->upsertRows( databaseId: '', tableId: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index cd9524a7..01879bde 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -13,7 +13,7 @@ $teams = new Teams($client); $result = $teams->createMembership( teamId: '', - roles: [], + roles: ["editor"], email: 'email@example.com', // optional userId: '', // optional phone: '+12065550100', // optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 87741774..3cdab5a0 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -14,6 +14,6 @@ $teams = new Teams($client); $result = $teams->updateMembership( teamId: '', membershipId: '', - roles: [] + roles: ["editor"] ); ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md deleted file mode 100644 index b050bab0..00000000 --- a/docs/examples/users/list-logs.md +++ /dev/null @@ -1,19 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$users = new Users($client); - -$result = $users->listLogs( - userId: '', - queries: [], // optional - total: false // optional -); -``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 7ac457f5..b8e573c1 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -13,6 +13,6 @@ $users = new Users($client); $result = $users->updateLabels( userId: '', - labels: [] + labels: ["subscriber"] ); ``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index c3ed6628..3bbdb076 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -17,7 +17,7 @@ $result = $vectorsDB->createCollection( databaseId: '', collectionId: '', name: '', - dimension: 1, + dimension: 4, permissions: [Permission::read(Role::any())], // optional documentSecurity: false, // optional enabled: false // optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 2d1c9c2f..054d3b35 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -14,7 +14,20 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index d3e699cb..369f018b 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -18,7 +18,7 @@ $result = $vectorsDB->createIndex( collectionId: '', key: '', type: VectorsDBIndexType::HNSWEUCLIDEAN(), - attributes: [], + attributes: ["embeddings"], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index c311d5e4..fa3d9769 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -20,7 +20,15 @@ $result = $vectorsDB->createOperations( "collectionId": "", "documentId": "", "data": { - "name": "Walter O'Brien" + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } } } ] // optional diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index 17b0831d..fbca7fd4 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -14,7 +14,7 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 7898ee03..d9815b61 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -17,7 +17,7 @@ $result = $vectorsDB->updateCollection( databaseId: '', collectionId: '', name: '', - dimension: 1, // optional + dimension: 4, // optional permissions: [Permission::read(Role::any())], // optional documentSecurity: false, // optional enabled: false // optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index 11e5d31f..516b6878 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -14,7 +14,20 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 2b437a54..536657d0 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -15,7 +15,7 @@ $result = $webhooks->create( webhookId: '', url: 'https://example.com/webhook', name: '', - events: [], + events: ["users.*.create"], enabled: false, // optional tls: false, // optional authUsername: '', // optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 95dafcf0..7ea370e9 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -15,7 +15,7 @@ $result = $webhooks->update( webhookId: '', name: '', url: 'https://example.com/webhook', - events: [], + events: ["users.*.create"], enabled: false, // optional tls: false, // optional authUsername: '', // optional diff --git a/docs/messaging.md b/docs/messaging.md index e2d897da..5dbed35d 100644 --- a/docs/messaging.md +++ b/docs/messaging.md @@ -11,7 +11,7 @@ GET https://cloud.appwrite.io/v1/messaging/messages | 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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType | [] | +| 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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType, users, targets | [] | | 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 | @@ -363,7 +363,7 @@ POST https://cloud.appwrite.io/v1/messaging/providers/appwrite | name | string | Provider name. | | | enabled | boolean | Set as enabled. | | | qos | integer | Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. | | -| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. | | ```http request @@ -380,7 +380,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/providers/appwrite/{providerId} | name | string | Provider name. | | | enabled | boolean | Set as enabled. | | | qos | integer | Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. | | -| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. | | ```http request @@ -839,7 +839,7 @@ POST https://cloud.appwrite.io/v1/messaging/providers/twilio | --- | --- | --- | --- | | providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | name | string | Provider name. | | -| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| from | string | Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. | | | accountSid | string | Twilio account secret ID. | | | authToken | string | Twilio authentication token. | | | enabled | boolean | Set as enabled. | | @@ -860,7 +860,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/providers/twilio/{providerId} | enabled | boolean | Set as enabled. | | | accountSid | string | Twilio account secret ID. | | | authToken | string | Twilio authentication token. | | -| from | string | Sender number. | | +| from | string | Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. | | ```http request @@ -955,7 +955,7 @@ POST https://cloud.appwrite.io/v1/messaging/topics | name | string | Topic Name. | | | subscribe | array | An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | ["users"] | | qos | integer | MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. | | -| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. | | ```http request @@ -987,7 +987,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/topics/{topicId} | name | string | Topic Name. | | | subscribe | array | An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | | | qos | integer | MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. | | -| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. | | ```http request diff --git a/docs/mongo.md b/docs/mongo.md index 084c9fca..b1b6fcec 100644 --- a/docs/mongo.md +++ b/docs/mongo.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/mongo | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/mongo/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/mysql.md b/docs/mysql.md index ced7ecea..ceee8070 100644 --- a/docs/mysql.md +++ b/docs/mysql.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/mysql | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/mysql/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/oauth2.md b/docs/oauth2.md index 46c3bc67..e9928cbf 100644 --- a/docs/oauth2.md +++ b/docs/oauth2.md @@ -39,7 +39,7 @@ GET https://cloud.appwrite.io/v1/oauth2/{project_id}/authorize | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | | request_uri | string | OAuth2 authorization request handle returned by the pushed authorization request endpoint. | | @@ -66,7 +66,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/authorize | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | | request_uri | string | OAuth2 authorization request handle returned by the pushed authorization request endpoint. | | @@ -85,7 +85,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/device_authorization | client_id | string | OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. | | | scope | string | Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | @@ -172,7 +172,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/par | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age parameter for customization of consent screen. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | @@ -242,6 +242,6 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/token | client_secret | string | OAuth2 client secret. Required for confidential apps. | | | code_verifier | string | PKCE code verifier. Required for public apps. | | | redirect_uri | string | Redirect URI. Required for `authorization_code` grant type. | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | diff --git a/docs/organization.md b/docs/organization.md index dc3895c1..350a7d14 100644 --- a/docs/organization.md +++ b/docs/organization.md @@ -96,78 +96,6 @@ DELETE https://cloud.appwrite.io/v1/organization/installations/{installationId} | installationId | string | **Required** Installation unique ID. | | -```http request -GET https://cloud.appwrite.io/v1/organization/keys -``` - -** Get a list of all API keys 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: expire, accessedAt, name, scopes | [] | -| 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/keys -``` - -** Create a new organization API key. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| 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 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. | | - - -```http request -GET https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including its scopes. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | - - -```http request -PUT https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | -| name | string | Key name. Max length: 128 chars. | | -| 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. | | - - -```http request -DELETE https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | - - ```http request GET https://cloud.appwrite.io/v1/organization/memberships ``` @@ -268,7 +196,7 @@ POST https://cloud.appwrite.io/v1/organization/projects | --- | --- | --- | --- | | projectId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. | | | name | string | Project name. Max length: 128 chars. | | -| region | string | Project Region. | default | +| region | string | Project Region. | | ```http request diff --git a/docs/postgresql.md b/docs/postgresql.md index d1af41f3..e3551c8c 100644 --- a/docs/postgresql.md +++ b/docs/postgresql.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/postgresql | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/postgresql/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/project.md b/docs/project.md index add475e8..df5337f8 100644 --- a/docs/project.md +++ b/docs/project.md @@ -25,7 +25,7 @@ PATCH https://cloud.appwrite.io/v1/project/auth-methods/{methodId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| methodId | string | **Required** Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone | | +| methodId | string | **Required** Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey | | | enabled | boolean | Auth method status. | | @@ -648,8 +648,8 @@ PATCH https://cloud.appwrite.io/v1/project/oauth2/kakao | --- | --- | --- | --- | | clientId | string | 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de | | | clientSecret | string | 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled | | -| prompt | array | Array of Kakao OAuth2 prompt values. 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. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. | | | 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. | | +| prompt | array | Array of Kakao OAuth2 prompt values. 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. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. | | ```http request @@ -1104,7 +1104,7 @@ POST https://cloud.appwrite.io/v1/project/platforms/android PUT https://cloud.appwrite.io/v1/project/platforms/android/{platformId} ``` -** Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. ** +** Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. ** ### Parameters @@ -1537,7 +1537,7 @@ GET https://cloud.appwrite.io/v1/project/policies/{policyId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| policyId | string | **Required** Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. | | +| policyId | string | **Required** Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. | | ```http request @@ -1627,7 +1627,7 @@ PATCH https://cloud.appwrite.io/v1/project/templates/email | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| templateId | string | Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession | | +| templateId | string | Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery | | | locale | string | Custom email template locale. If left empty, the fallback locale (en) will be used. | | | subject | string | Subject of the email template. Can be up to 255 characters. | | | message | string | Plain or HTML body of the email template message. Can be up to 10MB of content. | | @@ -1647,7 +1647,7 @@ GET https://cloud.appwrite.io/v1/project/templates/email/{templateId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| templateId | string | **Required** Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession | | +| templateId | string | **Required** Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery | | | locale | string | Custom email template locale. If left empty, the fallback locale (en) will be used. | | diff --git a/docs/proxy.md b/docs/proxy.md index baf24feb..1ad44349 100644 --- a/docs/proxy.md +++ b/docs/proxy.md @@ -7,7 +7,9 @@ POST https://cloud.appwrite.io/v1/proxy/invalidations ** Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. -Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. ** +Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. + +Domains that route to a function do not support cache invalidation. ** ### Parameters diff --git a/docs/storage.md b/docs/storage.md index cecf8af3..e24fa98a 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -201,7 +201,7 @@ GET https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId}/previ | fileId | string | **Required** File ID | | | width | integer | Resize preview image width, Pass an integer between 0 to 4000. | 0 | | height | integer | Resize preview image height, Pass an integer between 0 to 4000. | 0 | -| gravity | string | Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right | center | +| gravity | string | Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right | center | | quality | integer | Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. | -1 | | borderWidth | integer | Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. | 0 | | borderColor | string | Preview image border color. Use a valid HEX color, no # is needed for prefix. | | diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 4f2816ef..cd9fa038 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -39,7 +39,7 @@ POST https://cloud.appwrite.io/v1/tablesdb GET https://cloud.appwrite.io/v1/tablesdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request @@ -327,7 +327,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables | rowSecurity | boolean | Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. | 1 | | columns | array | Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. | [] | -| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | +| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | ```http request @@ -911,6 +911,24 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | restrict | +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key} +``` + +** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | | +| newKey | string | New Column Key. | | + + ```http request POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/string ``` @@ -1100,24 +1118,6 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/colum | key | string | **Required** Column Key. | | -```http request -PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship -``` - -** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | | -| newKey | string | New Column Key. | | - - ```http request GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes ``` @@ -1139,7 +1139,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes ``` ** Creates an index on the columns listed. Your index should include all the columns you will query in a single request. -Type can be `key`, `fulltext`, or `unique`. ** +Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. ** ### Parameters diff --git a/docs/teams.md b/docs/teams.md index c08fa9b7..d7477399 100644 --- a/docs/teams.md +++ b/docs/teams.md @@ -28,7 +28,7 @@ POST https://cloud.appwrite.io/v1/teams | --- | --- | --- | --- | | teamId | string | Team 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 | Team name. Max length: 128 chars. | | -| roles | array | Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. | ["owner"] | +| roles | array | Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. 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. | ["owner"] | ```http request diff --git a/docs/users.md b/docs/users.md index 17e7c54d..4c70df69 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, accessedAt | [] | +| 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, passwordPwned, 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 | @@ -226,7 +226,7 @@ PATCH https://cloud.appwrite.io/v1/users/{userId}/email PATCH https://cloud.appwrite.io/v1/users/{userId}/impersonator ``` -** Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. +** Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. Account endpoints are read-only while impersonating: they report the target's account, and anything that would change it is refused, so an impersonator cannot alter the target's credentials or delete their account. ** ### Parameters @@ -268,21 +268,6 @@ Labels can be used to grant access to resources. While teams are a way for user' | labels | array | Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | | -```http request -GET https://cloud.appwrite.io/v1/users/{userId}/logs -``` - -** Get the user activity logs list by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User 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/users/{userId}/memberships ``` diff --git a/docs/vectorsdb.md b/docs/vectorsdb.md index 70da401a..d94cc7b0 100644 --- a/docs/vectorsdb.md +++ b/docs/vectorsdb.md @@ -38,7 +38,7 @@ POST https://cloud.appwrite.io/v1/vectorsdb GET https://cloud.appwrite.io/v1/vectorsdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/webhooks.md b/docs/webhooks.md index c8b7ec5c..5ed6ad59 100644 --- a/docs/webhooks.md +++ b/docs/webhooks.md @@ -31,8 +31,8 @@ POST https://cloud.appwrite.io/v1/webhooks | events | array | Events list. Maximum of 100 events are allowed. | | | enabled | boolean | Enable or disable a webhook. | 1 | | tls | boolean | Certificate verification, false for disabled or true for enabled. | | -| authUsername | string | Webhook HTTP user. Max length: 256 chars. | | -| authPassword | string | Webhook HTTP password. Max length: 256 chars. | | +| authUsername | string | Webhook HTTP user. Max length: 255 chars. | | +| authPassword | string | Webhook HTTP password. Max length: 2048 chars. | | | secret | string | Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. | | @@ -65,8 +65,8 @@ PUT https://cloud.appwrite.io/v1/webhooks/{webhookId} | events | array | Events list. Maximum of 100 events are allowed. | | | enabled | boolean | Enable or disable a webhook. | 1 | | tls | boolean | Certificate verification, false for disabled or true for enabled. | | -| authUsername | string | Webhook HTTP user. Max length: 256 chars. | | -| authPassword | string | Webhook HTTP password. Max length: 256 chars. | | +| authUsername | string | Webhook HTTP user. Max length: 255 chars. | | +| authPassword | string | Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. | | ```http request diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 7aaf3809..aad6396c 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -6,6 +6,7 @@ use Ahc\Jwt\JWT; use Psr\Http\Client\ClientExceptionInterface; +use Psr\Http\Client\ClientInterface; use Utopia\Client\Adapter\Curl\Client as CurlAdapter; use Utopia\Client\Client as HttpClient; use Utopia\Psr7\Request\Factory as RequestFactory; @@ -43,11 +44,11 @@ class Client * */ protected array $headers = [ - 'user-agent' => 'AppwritePHPSDK/30.4.0 ()', + 'user-agent' => 'AppwritePHPSDK/31.0.0 ()', 'x-sdk-name' => 'PHP', 'x-sdk-platform' => 'server', 'x-sdk-language' => 'php', - 'x-sdk-version' => '30.4.0', + 'x-sdk-version' => '31.0.0', ]; /** @@ -105,12 +106,13 @@ class Client protected RequestFactory $requestFactory; /** - * Client constructor. + * An injected PSR-18 transport owns its timeout, TLS, connection reuse and + * redirect configuration. Without one, the SDK configures its cURL client. */ - public function __construct() + public function __construct(private readonly ?ClientInterface $transport = null) { $this->requestFactory = new RequestFactory(); - $this->headers['X-Appwrite-Response-Format'] = '2.0.0'; + $this->headers['X-Appwrite-Response-Format'] = '2.5.0'; } /** @@ -233,21 +235,6 @@ public function setForwardedUserAgent(string $value): Client return $this; } - /** - * Set DevKey - * - * Your secret dev API key - * - * - */ - public function setDevKey(string $value): Client - { - $this->addHeader('X-Appwrite-Dev-Key', $value); - $this->config['devkey'] = $value; - - return $this; - } - /** * Set Cookie * @@ -578,8 +565,12 @@ protected function toMultipartParts(array $data): array return $parts; } - protected function getHttpClient(bool $followRedirects): HttpClient + protected function getHttpClient(bool $followRedirects): ClientInterface { + if ($this->transport instanceof ClientInterface) { + return $this->transport; + } + if ($followRedirects) { return $this->httpClient ??= $this->createHttpClient(true); } diff --git a/src/Appwrite/Enums/BillingPlanGroup.php b/src/Appwrite/Enums/BillingPlanGroup.php index 59b1adab..c3a69534 100644 --- a/src/Appwrite/Enums/BillingPlanGroup.php +++ b/src/Appwrite/Enums/BillingPlanGroup.php @@ -9,7 +9,6 @@ class BillingPlanGroup implements JsonSerializable, Stringable { - private static BillingPlanGroup $STARTER; private static BillingPlanGroup $FREE; private static BillingPlanGroup $START; private static BillingPlanGroup $PRO; @@ -29,12 +28,6 @@ public function jsonSerialize(): string return $this->value; } - public static function STARTER(): BillingPlanGroup - { - self::$STARTER ??= new BillingPlanGroup('starter'); - - return self::$STARTER; - } public static function FREE(): BillingPlanGroup { self::$FREE ??= new BillingPlanGroup('free'); @@ -63,7 +56,6 @@ public static function SCALE(): BillingPlanGroup public static function from(string $value): self { return match ($value) { - 'starter' => self::STARTER(), 'free' => self::FREE(), 'start' => self::START(), 'pro' => self::PRO(), diff --git a/src/Appwrite/Enums/OrganizationKeyScopes.php b/src/Appwrite/Enums/OrganizationKeyScopes.php deleted file mode 100644 index b28e58e9..00000000 --- a/src/Appwrite/Enums/OrganizationKeyScopes.php +++ /dev/null @@ -1,162 +0,0 @@ -value; - } - - public function jsonSerialize(): string - { - return $this->value; - } - - public static function PROJECTSREAD(): OrganizationKeyScopes - { - self::$PROJECTSREAD ??= new OrganizationKeyScopes('projects.read'); - - return self::$PROJECTSREAD; - } - public static function PROJECTSWRITE(): OrganizationKeyScopes - { - self::$PROJECTSWRITE ??= new OrganizationKeyScopes('projects.write'); - - return self::$PROJECTSWRITE; - } - public static function DEVKEYSREAD(): OrganizationKeyScopes - { - self::$DEVKEYSREAD ??= new OrganizationKeyScopes('devKeys.read'); - - return self::$DEVKEYSREAD; - } - public static function DEVKEYSWRITE(): OrganizationKeyScopes - { - self::$DEVKEYSWRITE ??= new OrganizationKeyScopes('devKeys.write'); - - return self::$DEVKEYSWRITE; - } - public static function ORGANIZATIONKEYSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONKEYSREAD ??= new OrganizationKeyScopes('organization.keys.read'); - - return self::$ORGANIZATIONKEYSREAD; - } - public static function ORGANIZATIONKEYSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONKEYSWRITE ??= new OrganizationKeyScopes('organization.keys.write'); - - return self::$ORGANIZATIONKEYSWRITE; - } - public static function ORGANIZATIONINSTALLATIONSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONINSTALLATIONSREAD ??= new OrganizationKeyScopes('organization.installations.read'); - - return self::$ORGANIZATIONINSTALLATIONSREAD; - } - public static function ORGANIZATIONINSTALLATIONSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONINSTALLATIONSWRITE ??= new OrganizationKeyScopes('organization.installations.write'); - - return self::$ORGANIZATIONINSTALLATIONSWRITE; - } - public static function ORGANIZATIONMEMBERSHIPSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONMEMBERSHIPSREAD ??= new OrganizationKeyScopes('organization.memberships.read'); - - return self::$ORGANIZATIONMEMBERSHIPSREAD; - } - public static function ORGANIZATIONMEMBERSHIPSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONMEMBERSHIPSWRITE ??= new OrganizationKeyScopes('organization.memberships.write'); - - return self::$ORGANIZATIONMEMBERSHIPSWRITE; - } - public static function ORGANIZATIONREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONREAD ??= new OrganizationKeyScopes('organization.read'); - - return self::$ORGANIZATIONREAD; - } - public static function ORGANIZATIONWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONWRITE ??= new OrganizationKeyScopes('organization.write'); - - return self::$ORGANIZATIONWRITE; - } - public static function DOMAINSREAD(): OrganizationKeyScopes - { - self::$DOMAINSREAD ??= new OrganizationKeyScopes('domains.read'); - - return self::$DOMAINSREAD; - } - public static function DOMAINSWRITE(): OrganizationKeyScopes - { - self::$DOMAINSWRITE ??= new OrganizationKeyScopes('domains.write'); - - return self::$DOMAINSWRITE; - } - public static function KEYSREAD(): OrganizationKeyScopes - { - self::$KEYSREAD ??= new OrganizationKeyScopes('keys.read'); - - return self::$KEYSREAD; - } - public static function KEYSWRITE(): OrganizationKeyScopes - { - self::$KEYSWRITE ??= new OrganizationKeyScopes('keys.write'); - - return self::$KEYSWRITE; - } - - public static function from(string $value): self - { - return match ($value) { - 'projects.read' => self::PROJECTSREAD(), - 'projects.write' => self::PROJECTSWRITE(), - 'devKeys.read' => self::DEVKEYSREAD(), - 'devKeys.write' => self::DEVKEYSWRITE(), - 'organization.keys.read' => self::ORGANIZATIONKEYSREAD(), - 'organization.keys.write' => self::ORGANIZATIONKEYSWRITE(), - 'organization.installations.read' => self::ORGANIZATIONINSTALLATIONSREAD(), - 'organization.installations.write' => self::ORGANIZATIONINSTALLATIONSWRITE(), - '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(), - 'keys.write' => self::KEYSWRITE(), - default => throw new \InvalidArgumentException('Unknown OrganizationKeyScopes value: ' . $value), - }; - } -} diff --git a/src/Appwrite/Models/ActivityEventList.php b/src/Appwrite/Models/ActivityEventList.php index 8fd47418..357d7578 100644 --- a/src/Appwrite/Models/ActivityEventList.php +++ b/src/Appwrite/Models/ActivityEventList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'events' => [], ]; - if (!array_key_exists('events', $data)) { - throw new \InvalidArgumentException('Missing required field "events" for ' . static::class . '.'); - } - return new static( total: $data['total'], events: is_array($data['events']) diff --git a/src/Appwrite/Models/App.php b/src/Appwrite/Models/App.php index 24d11d56..7b0f9e16 100644 --- a/src/Appwrite/Models/App.php +++ b/src/Appwrite/Models/App.php @@ -104,12 +104,9 @@ public static function from(array $data): static 'userId' => "", 'installationScopes' => [], 'installationRedirectUrl' => "", + 'secrets' => [], ]; - if (!array_key_exists('secrets', $data)) { - throw new \InvalidArgumentException('Missing required field "secrets" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/AppInstallationList.php b/src/Appwrite/Models/AppInstallationList.php index cd5c3396..09803f30 100644 --- a/src/Appwrite/Models/AppInstallationList.php +++ b/src/Appwrite/Models/AppInstallationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'installations' => [], ]; - if (!array_key_exists('installations', $data)) { - throw new \InvalidArgumentException('Missing required field "installations" for ' . static::class . '.'); - } - return new static( total: $data['total'], installations: is_array($data['installations']) diff --git a/src/Appwrite/Models/AppKeyList.php b/src/Appwrite/Models/AppKeyList.php index 25f9edf9..577dfc64 100644 --- a/src/Appwrite/Models/AppKeyList.php +++ b/src/Appwrite/Models/AppKeyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'keys' => [], ]; - if (!array_key_exists('keys', $data)) { - throw new \InvalidArgumentException('Missing required field "keys" for ' . static::class . '.'); - } - return new static( total: $data['total'], keys: is_array($data['keys']) diff --git a/src/Appwrite/Models/AppScopeList.php b/src/Appwrite/Models/AppScopeList.php index 7ccaf66a..06bace42 100644 --- a/src/Appwrite/Models/AppScopeList.php +++ b/src/Appwrite/Models/AppScopeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'scopes' => [], ]; - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } - return new static( total: $data['total'], scopes: is_array($data['scopes']) diff --git a/src/Appwrite/Models/AppSecretList.php b/src/Appwrite/Models/AppSecretList.php index eae43eb6..9eb22f83 100644 --- a/src/Appwrite/Models/AppSecretList.php +++ b/src/Appwrite/Models/AppSecretList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'secrets' => [], ]; - if (!array_key_exists('secrets', $data)) { - throw new \InvalidArgumentException('Missing required field "secrets" for ' . static::class . '.'); - } - return new static( total: $data['total'], secrets: is_array($data['secrets']) diff --git a/src/Appwrite/Models/AppsList.php b/src/Appwrite/Models/AppsList.php index 4b028315..5685206d 100644 --- a/src/Appwrite/Models/AppsList.php +++ b/src/Appwrite/Models/AppsList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'apps' => [], ]; - if (!array_key_exists('apps', $data)) { - throw new \InvalidArgumentException('Missing required field "apps" for ' . static::class . '.'); - } - return new static( total: $data['total'], apps: is_array($data['apps']) diff --git a/src/Appwrite/Models/AttributeEnum.php b/src/Appwrite/Models/AttributeEnum.php index d2d84316..c99bdc57 100644 --- a/src/Appwrite/Models/AttributeEnum.php +++ b/src/Appwrite/Models/AttributeEnum.php @@ -57,15 +57,13 @@ public static function from(array $data): static 'required' => false, '$createdAt' => "", '$updatedAt' => "", + 'elements' => [], 'format' => "enum", ]; if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('elements', $data)) { - throw new \InvalidArgumentException('Missing required field "elements" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeList.php b/src/Appwrite/Models/AttributeList.php index 0dd3e89e..b583570c 100644 --- a/src/Appwrite/Models/AttributeList.php +++ b/src/Appwrite/Models/AttributeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'attributes' => [], ]; - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - return new static( total: $data['total'], attributes: $data['attributes'] diff --git a/src/Appwrite/Models/BackupArchive.php b/src/Appwrite/Models/BackupArchive.php index 44422c20..949c9466 100644 --- a/src/Appwrite/Models/BackupArchive.php +++ b/src/Appwrite/Models/BackupArchive.php @@ -20,12 +20,12 @@ * @param string $createdAt archive creation time in iso 8601 format. * @param string $updatedAt archive update date in iso 8601 format. * @param string $policyId archive policy id. - * @param int $size archive size in bytes. * @param string $status the status of the archive creation. possible values: pending, processing, uploading, completed, failed, skipped. - * @param string $startedAt the backup start time. * @param string $migrationId migration id. * @param array $services the services that are backed up by this archive. * @param array $resources the resources that are backed up by this archive. + * @param int|null $size archive size in bytes. null until the size is known. + * @param string|null $startedAt the backup start time. null until the backup starts. * @param string|null $resourceId the resource id to backup. set only if this archive should backup a single resource. * @param string|null $resourceType the resource type to backup. set only if this archive should backup a single resource. */ @@ -34,12 +34,12 @@ public function __construct( public string $createdAt, public string $updatedAt, public string $policyId, - public int $size, public string $status, - public string $startedAt, public string $migrationId, public array $services, public array $resources, + public ?int $size = null, + public ?string $startedAt = null, public ?string $resourceId = null, public ?string $resourceType = null ) { @@ -57,32 +57,21 @@ public static function from(array $data): static 'policyId' => "", 'status' => "", 'migrationId' => "", + 'services' => [], + 'resources' => [], ]; - if (!array_key_exists('size', $data)) { - throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); - } - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], updatedAt: $data['$updatedAt'], policyId: $data['policyId'], - size: $data['size'], status: $data['status'], - startedAt: $data['startedAt'], migrationId: $data['migrationId'], services: $data['services'], resources: $data['resources'], + size: $data['size'] ?? null, + startedAt: $data['startedAt'] ?? null, resourceId: $data['resourceId'] ?? null, resourceType: $data['resourceType'] ?? null ); diff --git a/src/Appwrite/Models/BackupArchiveList.php b/src/Appwrite/Models/BackupArchiveList.php index 49691da9..e166d7a7 100644 --- a/src/Appwrite/Models/BackupArchiveList.php +++ b/src/Appwrite/Models/BackupArchiveList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'archives' => [], ]; - if (!array_key_exists('archives', $data)) { - throw new \InvalidArgumentException('Missing required field "archives" for ' . static::class . '.'); - } - return new static( total: $data['total'], archives: is_array($data['archives']) diff --git a/src/Appwrite/Models/BackupPolicy.php b/src/Appwrite/Models/BackupPolicy.php index 790139c0..b527ffbc 100644 --- a/src/Appwrite/Models/BackupPolicy.php +++ b/src/Appwrite/Models/BackupPolicy.php @@ -55,19 +55,14 @@ public static function from(array $data): static 'name' => "", '$createdAt' => "", '$updatedAt' => "", + 'services' => [], + 'resources' => [], 'retention' => 1, 'schedule' => "0 * * * *", 'type' => "full", 'enabled' => false, ]; - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], name: $data['name'], diff --git a/src/Appwrite/Models/BackupPolicyList.php b/src/Appwrite/Models/BackupPolicyList.php index f27fe912..ab81c662 100644 --- a/src/Appwrite/Models/BackupPolicyList.php +++ b/src/Appwrite/Models/BackupPolicyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'policies' => [], ]; - if (!array_key_exists('policies', $data)) { - throw new \InvalidArgumentException('Missing required field "policies" for ' . static::class . '.'); - } - return new static( total: $data['total'], policies: is_array($data['policies']) diff --git a/src/Appwrite/Models/BackupRestoration.php b/src/Appwrite/Models/BackupRestoration.php index c6581f63..0a588ec3 100644 --- a/src/Appwrite/Models/BackupRestoration.php +++ b/src/Appwrite/Models/BackupRestoration.php @@ -22,11 +22,11 @@ * @param string $archiveId backup archive id. * @param string $policyId backup policy id. * @param string $status the status of the restoration. possible values: pending, downloading, processing, completed, failed. - * @param string $startedAt the backup start time. * @param string $migrationId migration id. * @param array $services the services that are backed up by this policy. * @param array $resources the resources that are backed up by this policy. - * @param string $options optional data in key-value object. + * @param array $options restoration options as a key-value object. + * @param string|null $startedAt the restoration start time. null until the restoration starts. */ public function __construct( public string $id, @@ -35,11 +35,11 @@ public function __construct( public string $archiveId, public string $policyId, public string $status, - public string $startedAt, public string $migrationId, public array $services, public array $resources, - public string $options + public array $options, + public ?string $startedAt = null ) { } @@ -56,19 +56,11 @@ public static function from(array $data): static 'policyId' => "", 'status' => "", 'migrationId' => "", + 'services' => [], + 'resources' => [], 'options' => [], ]; - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], @@ -76,11 +68,11 @@ public static function from(array $data): static archiveId: $data['archiveId'], policyId: $data['policyId'], status: $data['status'], - startedAt: $data['startedAt'], migrationId: $data['migrationId'], services: $data['services'], resources: $data['resources'], - options: $data['options'] + options: $data['options'], + startedAt: $data['startedAt'] ?? null ); } diff --git a/src/Appwrite/Models/BackupRestorationList.php b/src/Appwrite/Models/BackupRestorationList.php index 6d7f13dc..86759d45 100644 --- a/src/Appwrite/Models/BackupRestorationList.php +++ b/src/Appwrite/Models/BackupRestorationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'restorations' => [], ]; - if (!array_key_exists('restorations', $data)) { - throw new \InvalidArgumentException('Missing required field "restorations" for ' . static::class . '.'); - } - return new static( total: $data['total'], restorations: is_array($data['restorations']) diff --git a/src/Appwrite/Models/BillingPlan.php b/src/Appwrite/Models/BillingPlan.php index c8da4643..29ad81c0 100644 --- a/src/Appwrite/Models/BillingPlan.php +++ b/src/Appwrite/Models/BillingPlan.php @@ -30,6 +30,7 @@ * @param int $screenshotsGenerated screenshots generated * @param int $webhooks webhooks * @param int $wafRules maximum waf rules per project + * @param int $environments maximum environments per project. 0 when the plan does not offer environments. * @param int $projects projects * @param int $platforms platforms * @param int $users users @@ -54,7 +55,6 @@ * @param int $usageLogs usage history days * @param int $projectInactivityDays number of days of console inactivity before a project is paused. 0 means pausing is disabled. * @param int $alertLimit alert threshold percentage - * @param UsageBillingPlan $usage additional resources * @param BillingPlanAddon $addons addons * @param bool $budgetCapEnabled budget cap enabled or disabled. * @param bool $customSmtp custom smtp @@ -83,10 +83,10 @@ * @param BillingPlanGroup $group group of this billing plan for variants * @param float $databaseComputeCredit included monthly dedicated-database compute credit in usd. resets each billing cycle with no roll-over. * @param int|null $members members - * @param int|null $environments maximum environments per project. 0 when the plan does not offer environments. * @param int|null $activityLogs activity log days * @param array|null $usageLogsIntervals usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). * @param array|null $usageAggregateOnlyMetrics metrics this plan only records as a total. they cannot be broken down by dimension or filtered, because the stored events cover a fraction of the real traffic. + * @param UsageBillingPlan|null $usage additional resources. null when the plan does not support usage billing. * @param array|null $eligibleCountries iso country codes eligible for this regional plan. empty means no restriction. * @param bool|null $backupsEnabled does plan support backup policies. * @param int|null $backupPolicies how many policies does plan support @@ -107,6 +107,7 @@ public function __construct( public int $screenshotsGenerated, public int $webhooks, public int $wafRules, + public int $environments, public int $projects, public int $platforms, public int $users, @@ -131,7 +132,6 @@ public function __construct( public int $usageLogs, public int $projectInactivityDays, public int $alertLimit, - public UsageBillingPlan $usage, public BillingPlanAddon $addons, public bool $budgetCapEnabled, public bool $customSmtp, @@ -160,10 +160,10 @@ public function __construct( public BillingPlanGroup $group, public float $databaseComputeCredit, public ?int $members = null, - public ?int $environments = null, public ?int $activityLogs = null, public ?array $usageLogsIntervals = null, public ?array $usageAggregateOnlyMetrics = null, + public ?UsageBillingPlan $usage = null, public ?array $eligibleCountries = null, public ?bool $backupsEnabled = null, public ?int $backupPolicies = null, @@ -191,6 +191,7 @@ public static function from(array $data): static 'screenshotsGenerated' => 0, 'webhooks' => 0, 'wafRules' => 0, + 'environments' => 0, 'projects' => 0, 'platforms' => 0, 'users' => 0, @@ -241,9 +242,6 @@ public static function from(array $data): static 'databaseComputeCredit' => 0, ]; - 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 . '.'); } @@ -267,6 +265,7 @@ public static function from(array $data): static screenshotsGenerated: $data['screenshotsGenerated'], webhooks: $data['webhooks'], wafRules: $data['wafRules'], + environments: $data['environments'], projects: $data['projects'], platforms: $data['platforms'], users: $data['users'], @@ -291,7 +290,6 @@ functions: $data['functions'], 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'], @@ -320,10 +318,10 @@ functionsIntervalMinimum: $data['functionsIntervalMinimum'], group: static::hydrateTypedValue(BillingPlanGroup::class, $data['group']), databaseComputeCredit: $data['databaseComputeCredit'], members: $data['members'] ?? null, - environments: $data['environments'] ?? null, activityLogs: $data['activityLogs'] ?? null, usageLogsIntervals: $data['usageLogsIntervals'] ?? null, usageAggregateOnlyMetrics: $data['usageAggregateOnlyMetrics'] ?? null, + usage: array_key_exists('usage', $data) ? static::hydrateTypedValue(UsageBillingPlan::class, $data['usage'], true) : null, eligibleCountries: $data['eligibleCountries'] ?? null, backupsEnabled: $data['backupsEnabled'] ?? null, backupPolicies: $data['backupPolicies'] ?? null, diff --git a/src/Appwrite/Models/Block.php b/src/Appwrite/Models/Block.php index f40cb573..3b918222 100644 --- a/src/Appwrite/Models/Block.php +++ b/src/Appwrite/Models/Block.php @@ -20,12 +20,6 @@ * @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. - * @param string $organizationId id of the organization that owns the project. - * @param string $billingPlan billing plan of the organization that owns the project. - * @param string|null $reason reason for the block. can be null if no reason was provided. * @param string|null $expiredAt block expiration date in iso 8601 format. can be null if the block does not expire. */ public function __construct( @@ -33,12 +27,6 @@ public function __construct( public string $resourceType, public string $resourceId, public string $mode, - public string $projectName, - public string $region, - public string $organizationName, - public string $organizationId, - public string $billingPlan, - public ?string $reason = null, public ?string $expiredAt = null ) { } @@ -55,33 +43,11 @@ public static function from(array $data): static 'mode' => "full", ]; - if (!array_key_exists('projectName', $data)) { - throw new \InvalidArgumentException('Missing required field "projectName" for ' . static::class . '.'); - } - if (!array_key_exists('region', $data)) { - throw new \InvalidArgumentException('Missing required field "region" for ' . static::class . '.'); - } - if (!array_key_exists('organizationName', $data)) { - throw new \InvalidArgumentException('Missing required field "organizationName" for ' . static::class . '.'); - } - if (!array_key_exists('organizationId', $data)) { - throw new \InvalidArgumentException('Missing required field "organizationId" for ' . static::class . '.'); - } - if (!array_key_exists('billingPlan', $data)) { - throw new \InvalidArgumentException('Missing required field "billingPlan" for ' . static::class . '.'); - } - return new static( createdAt: $data['$createdAt'], resourceType: $data['resourceType'], resourceId: $data['resourceId'], mode: $data['mode'], - projectName: $data['projectName'], - region: $data['region'], - organizationName: $data['organizationName'], - organizationId: $data['organizationId'], - billingPlan: $data['billingPlan'], - reason: $data['reason'] ?? null, expiredAt: $data['expiredAt'] ?? null ); } @@ -96,13 +62,7 @@ public function toArray(): array '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), - 'region' => static::serializeValue($this->region), - 'organizationName' => static::serializeValue($this->organizationName), - 'organizationId' => static::serializeValue($this->organizationId), - 'billingPlan' => static::serializeValue($this->billingPlan) + 'expiredAt' => static::serializeValue($this->expiredAt) ]; } } diff --git a/src/Appwrite/Models/BucketList.php b/src/Appwrite/Models/BucketList.php index 4ee13e87..d5e2831f 100644 --- a/src/Appwrite/Models/BucketList.php +++ b/src/Appwrite/Models/BucketList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'buckets' => [], ]; - if (!array_key_exists('buckets', $data)) { - throw new \InvalidArgumentException('Missing required field "buckets" for ' . static::class . '.'); - } - return new static( total: $data['total'], buckets: is_array($data['buckets']) diff --git a/src/Appwrite/Models/Collection.php b/src/Appwrite/Models/Collection.php index 34e1ff95..cf23cf70 100644 --- a/src/Appwrite/Models/Collection.php +++ b/src/Appwrite/Models/Collection.php @@ -54,24 +54,17 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'documentSecurity' => false, + 'attributes' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/CollectionList.php b/src/Appwrite/Models/CollectionList.php index 435e41ad..19110117 100644 --- a/src/Appwrite/Models/CollectionList.php +++ b/src/Appwrite/Models/CollectionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'collections' => [], ]; - if (!array_key_exists('collections', $data)) { - throw new \InvalidArgumentException('Missing required field "collections" for ' . static::class . '.'); - } - return new static( total: $data['total'], collections: is_array($data['collections']) diff --git a/src/Appwrite/Models/ColumnEnum.php b/src/Appwrite/Models/ColumnEnum.php index f9c4c458..31b43871 100644 --- a/src/Appwrite/Models/ColumnEnum.php +++ b/src/Appwrite/Models/ColumnEnum.php @@ -57,15 +57,13 @@ public static function from(array $data): static 'required' => false, '$createdAt' => "", '$updatedAt' => "", + 'elements' => [], 'format' => "enum", ]; if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('elements', $data)) { - throw new \InvalidArgumentException('Missing required field "elements" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnIndexList.php b/src/Appwrite/Models/ColumnIndexList.php index b5eaf075..1ce04240 100644 --- a/src/Appwrite/Models/ColumnIndexList.php +++ b/src/Appwrite/Models/ColumnIndexList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'indexes' => [], ]; - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( total: $data['total'], indexes: is_array($data['indexes']) diff --git a/src/Appwrite/Models/ColumnList.php b/src/Appwrite/Models/ColumnList.php index 108ff6a4..bc3a30f3 100644 --- a/src/Appwrite/Models/ColumnList.php +++ b/src/Appwrite/Models/ColumnList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'columns' => [], ]; - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - return new static( total: $data['total'], columns: $data['columns'] diff --git a/src/Appwrite/Models/ContinentList.php b/src/Appwrite/Models/ContinentList.php index 3af16511..dbf1b56c 100644 --- a/src/Appwrite/Models/ContinentList.php +++ b/src/Appwrite/Models/ContinentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'continents' => [], ]; - if (!array_key_exists('continents', $data)) { - throw new \InvalidArgumentException('Missing required field "continents" for ' . static::class . '.'); - } - return new static( total: $data['total'], continents: is_array($data['continents']) diff --git a/src/Appwrite/Models/CountryList.php b/src/Appwrite/Models/CountryList.php index 0a9210a9..84ce278a 100644 --- a/src/Appwrite/Models/CountryList.php +++ b/src/Appwrite/Models/CountryList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'countries' => [], ]; - if (!array_key_exists('countries', $data)) { - throw new \InvalidArgumentException('Missing required field "countries" for ' . static::class . '.'); - } - return new static( total: $data['total'], countries: is_array($data['countries']) diff --git a/src/Appwrite/Models/CurrencyList.php b/src/Appwrite/Models/CurrencyList.php index d2b33e37..9243c75f 100644 --- a/src/Appwrite/Models/CurrencyList.php +++ b/src/Appwrite/Models/CurrencyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'currencies' => [], ]; - if (!array_key_exists('currencies', $data)) { - throw new \InvalidArgumentException('Missing required field "currencies" for ' . static::class . '.'); - } - return new static( total: $data['total'], currencies: is_array($data['currencies']) diff --git a/src/Appwrite/Models/Database.php b/src/Appwrite/Models/Database.php index bd3a45e1..6cbaff98 100644 --- a/src/Appwrite/Models/Database.php +++ b/src/Appwrite/Models/Database.php @@ -30,7 +30,7 @@ * @param string|null $specification compute specification identifier of the dedicated backing, e.g. s-2vcpu-2gb. null when the database has no dedicated backing. * @param int|null $replicas number of secondary high availability replicas, excluding the primary. null when backing configuration is unavailable. * @param string|null $error error message when the dedicated backing failed. null when the database has no dedicated backing or has not failed. - * @param string|null $containerStatus container status of the dedicated backing: active or inactive. null when the database has no dedicated backing or the runtime has not reported one. + * @param string|null $containerStatus container status of the dedicated backing: active, inactive, or failed (a wake was declined because the backing namespace is gone). null when the database has no dedicated backing or the runtime has not reported one. * @param string|null $lifecycleState idle-lifecycle state of the dedicated backing: active, warm, cold, or hibernated. null when the database has no dedicated backing or the runtime has not reported one. * @param list|null $policies database backup policies. * @param list|null $archives database backup archives. diff --git a/src/Appwrite/Models/DatabaseList.php b/src/Appwrite/Models/DatabaseList.php index 86fb3468..8a1dd971 100644 --- a/src/Appwrite/Models/DatabaseList.php +++ b/src/Appwrite/Models/DatabaseList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'databases' => [], ]; - if (!array_key_exists('databases', $data)) { - throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); - } - return new static( total: $data['total'], databases: is_array($data['databases']) diff --git a/src/Appwrite/Models/DatabaseMigrationList.php b/src/Appwrite/Models/DatabaseMigrationList.php index ae2528dd..480bf847 100644 --- a/src/Appwrite/Models/DatabaseMigrationList.php +++ b/src/Appwrite/Models/DatabaseMigrationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'migrations' => [], ]; - if (!array_key_exists('migrations', $data)) { - throw new \InvalidArgumentException('Missing required field "migrations" for ' . static::class . '.'); - } - return new static( total: $data['total'], migrations: is_array($data['migrations']) diff --git a/src/Appwrite/Models/DatabaseStatus.php b/src/Appwrite/Models/DatabaseStatus.php index 6fdaf141..b685e035 100644 --- a/src/Appwrite/Models/DatabaseStatus.php +++ b/src/Appwrite/Models/DatabaseStatus.php @@ -21,13 +21,13 @@ * @param string $engine database engine: postgresql, mysql, or mongodb. * @param string $version database engine version. * @param int $uptime database uptime in seconds. - * @param DatabaseStatusConnections $connections connection statistics. * @param string $syncMode requested replication sync mode. possible values: async, sync, quorum. compare with effectivesyncmode for what the primary is enforcing. * @param bool $syncDegraded whether the enforced replication is weaker than the requested syncmode. * @param int $syncAcknowledgements number of standby acknowledgements the primary waits for before a write is committed. * @param int $syncStandbyCount number of standbys registered with the primary for synchronous replication. * @param list $replicas list of database replicas and their status. every configured member appears, including one the backend has not brought up, which is reported as not healthy. * @param list $volumes storage volume information. + * @param DatabaseStatusConnections|null $connections connection statistics. null when the database has not been probed. * @param string|null $effectiveSyncMode replication sync mode the primary is actually enforcing. null when high availability is disabled or the state could not be read. * @param bool|null $syncStateConfirmed whether the other sync fields are an engine reading rather than a recorded estimate. true when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. false when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. false never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ @@ -37,13 +37,13 @@ public function __construct( public string $engine, public string $version, public int $uptime, - public DatabaseStatusConnections $connections, public string $syncMode, public bool $syncDegraded, public int $syncAcknowledgements, public int $syncStandbyCount, public array $replicas, public array $volumes, + public ?DatabaseStatusConnections $connections = null, public ?string $effectiveSyncMode = null, public ?bool $syncStateConfirmed = null ) { @@ -64,25 +64,16 @@ public static function from(array $data): static 'syncDegraded' => false, 'syncAcknowledgements' => 0, 'syncStandbyCount' => 0, + 'replicas' => [], + 'volumes' => [], ]; - if (!array_key_exists('connections', $data)) { - throw new \InvalidArgumentException('Missing required field "connections" for ' . static::class . '.'); - } - if (!array_key_exists('replicas', $data)) { - throw new \InvalidArgumentException('Missing required field "replicas" for ' . static::class . '.'); - } - if (!array_key_exists('volumes', $data)) { - throw new \InvalidArgumentException('Missing required field "volumes" for ' . static::class . '.'); - } - return new static( health: $data['health'], ready: $data['ready'], engine: $data['engine'], version: $data['version'], uptime: $data['uptime'], - connections: static::hydrateTypedValue(DatabaseStatusConnections::class, $data['connections']), syncMode: $data['syncMode'], syncDegraded: $data['syncDegraded'], syncAcknowledgements: $data['syncAcknowledgements'], @@ -99,6 +90,7 @@ public static function from(array $data): static $data['volumes'] ) : $data['volumes'], + connections: array_key_exists('connections', $data) ? static::hydrateTypedValue(DatabaseStatusConnections::class, $data['connections'], true) : null, effectiveSyncMode: $data['effectiveSyncMode'] ?? null, syncStateConfirmed: $data['syncStateConfirmed'] ?? null ); diff --git a/src/Appwrite/Models/DedicatedDatabase.php b/src/Appwrite/Models/DedicatedDatabase.php index acd6c5d1..fd356542 100644 --- a/src/Appwrite/Models/DedicatedDatabase.php +++ b/src/Appwrite/Models/DedicatedDatabase.php @@ -21,25 +21,23 @@ * @param string $updatedAt database update date in iso 8601 format. * @param string $projectId project id that owns this database. * @param string $name database display name. - * @param string $api product api that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. - * @param string $engine database engine: postgresql, mysql, or mongodb. null until the backing reports one. * @param string $version database engine version. * @param string $specification specification identifier. * @param string $backend database backend provider. possible values: edge. * @param string $hostname database hostname for connections. - * @param int $connectionPort database port for connections. derived from the engine when the backing has not reported one yet. * @param string $connectionUser database username for connections. * @param string $connectionPassword database password for connections. - * @param int $credentialGeneration committed generation of the primary connection credentials. null until the rotation contract has been initialized. * @param string $connectionString full database connection string (uri format). * @param bool $ssl whether ssl/tls is required for client connections. * @param string $status database status. possible values: provisioning, ready, inactive, paused, failed, deleted, restoring, scaling. - * @param string $containerStatus container status for lifecycle-managed database runtimes: active or inactive. + * @param string $containerStatus container status for lifecycle-managed database runtimes: active, inactive, or failed (a wake was declined because the backing namespace is gone). * @param string $lifecycleState idle-lifecycle state of the database. possible values: active, warm, cold, hibernated. * @param int $idleTimeoutMinutes minutes of inactivity before container scales to zero. * @param int $cpu cpu allocated in millicores. * @param int $memory memory allocated in mb. * @param int $storage storage allocated in gb. + * @param string $storageStatus storage resize status. possible values: idle (no resize in flight), resizing (the volume is growing towards storagetargetgb). + * @param int $storageTargetGb size in gb the volume is growing towards while storagestatus is resizing. 0 when no resize is in flight. * @param string $storageClass storage class. currently always 'ssd'; digitalocean exposes a single block-storage class. * @param int $storageMaxGb maximum storage allowed in gb. 0 means use system default. * @param string $nodePool kubernetes node pool where the database is scheduled. @@ -53,7 +51,7 @@ * @param int $pitrRetentionDays number of days to retain pitr data. * @param bool $storageAutoscaling whether automatic storage expansion is enabled. * @param int $storageAutoscalingThresholdPercent storage usage percentage that triggers automatic expansion. - * @param int $storageAutoscalingMaxGb maximum storage size in gb for autoscaling. 0 means no limit. + * @param int $storageAutoscalingMaxGb maximum storage size in gb for autoscaling. defaults to 3 times the specification's storage. 0 means no limit. * @param string $maintenanceWindowDay day of the week for the maintenance window. possible values: sun, mon, tue, wed, thu, fri, sat. * @param int $maintenanceWindowHourUtc hour in utc (0-23) when the maintenance window starts. * @param bool $metricsEnabled whether metrics collection is enabled. @@ -63,10 +61,12 @@ * @param int $sqlApiMaxBytes maximum serialised sql api result payload in bytes. results larger than this are truncated. * @param int $sqlApiTimeoutSeconds maximum server-side sql api execution time in seconds before the query is cancelled. * @param string $error error message if status is failed. + * @param string|null $api product api that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. + * @param string|null $engine database engine: postgresql, mysql, or mongodb. null until the backing reports one. + * @param int|null $connectionPort database port for connections. derived from the engine when the backing has not reported one yet. + * @param int|null $credentialGeneration committed generation of the primary connection credentials. null until the rotation contract has been initialized. * @param string|null $lastAccessedAt last activity timestamp in iso 8601 format. * @param string|null $idleUntil display-only timestamp when the database is expected to be considered idle (iso 8601 format). derived from last activity; lifecycle transitions are driven by lifecyclestate. - * @param string|null $storageStatus storage resize status. possible values: idle (no resize in flight), resizing (the volume is growing towards storagetargetgb). - * @param int|null $storageTargetGb size in gb the volume is growing towards while storagestatus is resizing. 0 when no resize is in flight. * @param string|null $storageResizeStartedAt time the in-flight storage resize started, in iso 8601 format. */ public function __construct( @@ -75,16 +75,12 @@ public function __construct( public string $updatedAt, public string $projectId, public string $name, - public string $api, - public string $engine, public string $version, public string $specification, public string $backend, public string $hostname, - public int $connectionPort, public string $connectionUser, public string $connectionPassword, - public int $credentialGeneration, public string $connectionString, public bool $ssl, public string $status, @@ -94,6 +90,8 @@ public function __construct( public int $cpu, public int $memory, public int $storage, + public string $storageStatus, + public int $storageTargetGb, public string $storageClass, public int $storageMaxGb, public string $nodePool, @@ -117,10 +115,12 @@ public function __construct( public int $sqlApiMaxBytes, public int $sqlApiTimeoutSeconds, public string $error, + public ?string $api = null, + public ?string $engine = null, + public ?int $connectionPort = null, + public ?int $credentialGeneration = null, public ?string $lastAccessedAt = null, public ?string $idleUntil = null, - public ?string $storageStatus = null, - public ?int $storageTargetGb = null, public ?string $storageResizeStartedAt = null ) { } @@ -151,6 +151,8 @@ public static function from(array $data): static 'cpu' => 500, 'memory' => 512, 'storage' => 10, + 'storageStatus' => "idle", + 'storageTargetGb' => 0, 'storageClass' => "ssd", 'storageMaxGb' => 0, 'nodePool' => "", @@ -176,35 +178,18 @@ public static function from(array $data): static 'error' => "", ]; - if (!array_key_exists('api', $data)) { - throw new \InvalidArgumentException('Missing required field "api" for ' . static::class . '.'); - } - if (!array_key_exists('engine', $data)) { - throw new \InvalidArgumentException('Missing required field "engine" for ' . static::class . '.'); - } - if (!array_key_exists('connectionPort', $data)) { - throw new \InvalidArgumentException('Missing required field "connectionPort" for ' . static::class . '.'); - } - if (!array_key_exists('credentialGeneration', $data)) { - throw new \InvalidArgumentException('Missing required field "credentialGeneration" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], updatedAt: $data['$updatedAt'], projectId: $data['projectId'], name: $data['name'], - api: $data['api'], - engine: $data['engine'], version: $data['version'], specification: $data['specification'], backend: $data['backend'], hostname: $data['hostname'], - connectionPort: $data['connectionPort'], connectionUser: $data['connectionUser'], connectionPassword: $data['connectionPassword'], - credentialGeneration: $data['credentialGeneration'], connectionString: $data['connectionString'], ssl: $data['ssl'], status: $data['status'], @@ -214,6 +199,8 @@ public static function from(array $data): static cpu: $data['cpu'], memory: $data['memory'], storage: $data['storage'], + storageStatus: $data['storageStatus'], + storageTargetGb: $data['storageTargetGb'], storageClass: $data['storageClass'], storageMaxGb: $data['storageMaxGb'], nodePool: $data['nodePool'], @@ -237,10 +224,12 @@ public static function from(array $data): static sqlApiMaxBytes: $data['sqlApiMaxBytes'], sqlApiTimeoutSeconds: $data['sqlApiTimeoutSeconds'], error: $data['error'], + api: $data['api'] ?? null, + engine: $data['engine'] ?? null, + connectionPort: $data['connectionPort'] ?? null, + credentialGeneration: $data['credentialGeneration'] ?? null, lastAccessedAt: $data['lastAccessedAt'] ?? null, idleUntil: $data['idleUntil'] ?? null, - storageStatus: $data['storageStatus'] ?? null, - storageTargetGb: $data['storageTargetGb'] ?? null, storageResizeStartedAt: $data['storageResizeStartedAt'] ?? null ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseBackupList.php b/src/Appwrite/Models/DedicatedDatabaseBackupList.php index fb6b0225..745fe62c 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBackupList.php +++ b/src/Appwrite/Models/DedicatedDatabaseBackupList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'backups' => [], ]; - if (!array_key_exists('backups', $data)) { - throw new \InvalidArgumentException('Missing required field "backups" for ' . static::class . '.'); - } - return new static( total: $data['total'], backups: is_array($data['backups']) diff --git a/src/Appwrite/Models/DedicatedDatabaseBranch.php b/src/Appwrite/Models/DedicatedDatabaseBranch.php index 47704627..7ddfe531 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBranch.php +++ b/src/Appwrite/Models/DedicatedDatabaseBranch.php @@ -21,13 +21,13 @@ * @param string $namespace kubernetes namespace where the branch is deployed. * @param int $expiresAt unix timestamp when the branch expires. * @param string $host branch hostname for direct connections. - * @param int $port branch port. null until the backing reports one. * @param string $database advertised catalog the client connects to. mysql/mariadb use default; postgres uses the routing label. * @param string $username database username. shared with the parent database. * @param string $password database password. shared with the parent database. * @param bool $ssl whether ssl is required. * @param string $engine database engine. possible values: postgresql, mysql, mongodb. * @param string $connectionString full connection string for the branch. + * @param int|null $port branch port. null until the backing reports one. */ public function __construct( public string $branchId, @@ -35,13 +35,13 @@ public function __construct( public string $namespace, public int $expiresAt, public string $host, - public int $port, public string $database, public string $username, public string $password, public bool $ssl, public string $engine, - public string $connectionString + public string $connectionString, + public ?int $port = null ) { } @@ -64,23 +64,19 @@ public static function from(array $data): static 'connectionString' => "", ]; - if (!array_key_exists('port', $data)) { - throw new \InvalidArgumentException('Missing required field "port" for ' . static::class . '.'); - } - return new static( branchId: $data['branchId'], branchName: $data['branchName'], namespace: $data['namespace'], expiresAt: $data['expiresAt'], host: $data['host'], - port: $data['port'], database: $data['database'], username: $data['username'], password: $data['password'], ssl: $data['ssl'], engine: $data['engine'], - connectionString: $data['connectionString'] + connectionString: $data['connectionString'], + port: $data['port'] ?? null ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseBranchList.php b/src/Appwrite/Models/DedicatedDatabaseBranchList.php index 4212a97d..c7bd5afc 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBranchList.php +++ b/src/Appwrite/Models/DedicatedDatabaseBranchList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'branches' => [], ]; - if (!array_key_exists('branches', $data)) { - throw new \InvalidArgumentException('Missing required field "branches" for ' . static::class . '.'); - } - return new static( total: $data['total'], branches: is_array($data['branches']) diff --git a/src/Appwrite/Models/DedicatedDatabaseExecution.php b/src/Appwrite/Models/DedicatedDatabaseExecution.php index 12e54077..283c9897 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExecution.php +++ b/src/Appwrite/Models/DedicatedDatabaseExecution.php @@ -41,15 +41,12 @@ public static function from(array $data): static $data += [ 'rows' => [], 'rowCount' => 0, + 'columns' => [], 'durationMs' => 0, 'truncated' => false, 'bytes' => 0, ]; - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - return new static( rows: $data['rows'], rowCount: $data['rowCount'], diff --git a/src/Appwrite/Models/DedicatedDatabaseExtensions.php b/src/Appwrite/Models/DedicatedDatabaseExtensions.php index b1532138..9f294000 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExtensions.php +++ b/src/Appwrite/Models/DedicatedDatabaseExtensions.php @@ -35,12 +35,9 @@ public static function from(array $data): static $data += [ 'installed' => [], 'available' => [], + 'metadata' => [], ]; - if (!array_key_exists('metadata', $data)) { - throw new \InvalidArgumentException('Missing required field "metadata" for ' . static::class . '.'); - } - return new static( installed: $data['installed'], available: $data['available'], diff --git a/src/Appwrite/Models/DedicatedDatabaseList.php b/src/Appwrite/Models/DedicatedDatabaseList.php index a9784de3..796742c0 100644 --- a/src/Appwrite/Models/DedicatedDatabaseList.php +++ b/src/Appwrite/Models/DedicatedDatabaseList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'databases' => [], ]; - if (!array_key_exists('databases', $data)) { - throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); - } - return new static( total: $data['total'], databases: is_array($data['databases']) diff --git a/src/Appwrite/Models/DedicatedDatabaseOperationList.php b/src/Appwrite/Models/DedicatedDatabaseOperationList.php index 7710285e..c8d97389 100644 --- a/src/Appwrite/Models/DedicatedDatabaseOperationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseOperationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'operations' => [], ]; - if (!array_key_exists('operations', $data)) { - throw new \InvalidArgumentException('Missing required field "operations" for ' . static::class . '.'); - } - return new static( total: $data['total'], operations: is_array($data['operations']) diff --git a/src/Appwrite/Models/DedicatedDatabaseReplicas.php b/src/Appwrite/Models/DedicatedDatabaseReplicas.php index 563630fe..451679fc 100644 --- a/src/Appwrite/Models/DedicatedDatabaseReplicas.php +++ b/src/Appwrite/Models/DedicatedDatabaseReplicas.php @@ -48,12 +48,9 @@ public static function from(array $data): static 'syncDegraded' => false, 'syncAcknowledgements' => 0, 'syncStandbyCount' => 0, + 'members' => [], ]; - if (!array_key_exists('members', $data)) { - throw new \InvalidArgumentException('Missing required field "members" for ' . static::class . '.'); - } - return new static( replicas: $data['replicas'], syncMode: $data['syncMode'], diff --git a/src/Appwrite/Models/DedicatedDatabaseRestoration.php b/src/Appwrite/Models/DedicatedDatabaseRestoration.php index 02927028..28b38db0 100644 --- a/src/Appwrite/Models/DedicatedDatabaseRestoration.php +++ b/src/Appwrite/Models/DedicatedDatabaseRestoration.php @@ -19,29 +19,29 @@ * @param string $id restoration id. * @param string $createdAt restoration creation time in iso 8601 format. * @param string $databaseId database id being restored into. - * @param string $sourceDatabaseId source database id when restoring a backup into another database. * @param string $projectId project id. - * @param string $backupId backup id used for restoration (null for pitr). * @param string $type restoration type. possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). * @param string $status restoration status. possible values: pending (queued for processing), running (currently in progress), completed (successfully finished), failed (encountered an error). - * @param string $targetTime target time for pitr restoration in iso 8601 format. - * @param string $startedAt restoration start time in iso 8601 format. - * @param string $completedAt restoration completion time in iso 8601 format. * @param string $error error message if restoration failed. + * @param string|null $sourceDatabaseId source database id when restoring a backup into another database. + * @param string|null $backupId backup id used for restoration (null for pitr). + * @param string|null $targetTime target time for pitr restoration in iso 8601 format. + * @param string|null $startedAt restoration start time in iso 8601 format. + * @param string|null $completedAt restoration completion time in iso 8601 format. */ public function __construct( public string $id, public string $createdAt, public string $databaseId, - public string $sourceDatabaseId, public string $projectId, - public string $backupId, public string $type, public string $status, - public string $targetTime, - public string $startedAt, - public string $completedAt, - public string $error + public string $error, + public ?string $sourceDatabaseId = null, + public ?string $backupId = null, + public ?string $targetTime = null, + public ?string $startedAt = null, + public ?string $completedAt = null ) { } @@ -60,35 +60,19 @@ public static function from(array $data): static 'error' => "", ]; - if (!array_key_exists('sourceDatabaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "sourceDatabaseId" for ' . static::class . '.'); - } - if (!array_key_exists('backupId', $data)) { - throw new \InvalidArgumentException('Missing required field "backupId" for ' . static::class . '.'); - } - if (!array_key_exists('targetTime', $data)) { - throw new \InvalidArgumentException('Missing required field "targetTime" for ' . static::class . '.'); - } - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('completedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "completedAt" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], databaseId: $data['databaseId'], - sourceDatabaseId: $data['sourceDatabaseId'], projectId: $data['projectId'], - backupId: $data['backupId'], type: $data['type'], status: $data['status'], - targetTime: $data['targetTime'], - startedAt: $data['startedAt'], - completedAt: $data['completedAt'], - error: $data['error'] + error: $data['error'], + sourceDatabaseId: $data['sourceDatabaseId'] ?? null, + backupId: $data['backupId'] ?? null, + targetTime: $data['targetTime'] ?? null, + startedAt: $data['startedAt'] ?? null, + completedAt: $data['completedAt'] ?? null ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseRestorationList.php b/src/Appwrite/Models/DedicatedDatabaseRestorationList.php index b4491a49..b599e127 100644 --- a/src/Appwrite/Models/DedicatedDatabaseRestorationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseRestorationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'restorations' => [], ]; - if (!array_key_exists('restorations', $data)) { - throw new \InvalidArgumentException('Missing required field "restorations" for ' . static::class . '.'); - } - return new static( total: $data['total'], restorations: is_array($data['restorations']) diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecification.php b/src/Appwrite/Models/DedicatedDatabaseSpecification.php index a4612cc0..aa10cd8e 100644 --- a/src/Appwrite/Models/DedicatedDatabaseSpecification.php +++ b/src/Appwrite/Models/DedicatedDatabaseSpecification.php @@ -19,31 +19,31 @@ * @param string $slug specification slug. use this value when creating a dedicated database. * @param string $name human readable specification name. * @param float $price monthly price of the specification in usd. + * @param float $storageOverageRate price per gb of storage above the included amount, per month, in usd. + * @param float $bandwidthOverageRate price per gb of bandwidth above the included amount, per month, in usd. + * @param float $replicaRate high availability replica price as a fraction of the specification price. + * @param float $pitrRate point-in-time recovery price as a fraction of the specification price. * @param int $cpu allocated cpu in millicores. * @param int $memory allocated memory in mb. * @param int $maxConnections maximum number of concurrent connections. * @param int $includedStorage included storage in gb before overage charges apply. * @param int $includedBandwidth included bandwidth in gb before overage charges apply. * @param bool $enabled whether the specification is available on the current plan. - * @param float|null $storageOverageRate price per gb of storage above the included amount, per month, in usd. - * @param float|null $bandwidthOverageRate price per gb of bandwidth above the included amount, per month, in usd. - * @param float|null $replicaRate high availability replica price as a fraction of the specification price. - * @param float|null $pitrRate point-in-time recovery price as a fraction of the specification price. */ public function __construct( public string $slug, public string $name, public float $price, + public float $storageOverageRate, + public float $bandwidthOverageRate, + public float $replicaRate, + public float $pitrRate, public int $cpu, public int $memory, public int $maxConnections, public int $includedStorage, public int $includedBandwidth, - public bool $enabled, - public ?float $storageOverageRate = null, - public ?float $bandwidthOverageRate = null, - public ?float $replicaRate = null, - public ?float $pitrRate = null + public bool $enabled ) { } @@ -56,6 +56,10 @@ public static function from(array $data): static 'slug' => "", 'name' => "", 'price' => 0, + 'storageOverageRate' => 0, + 'bandwidthOverageRate' => 0, + 'replicaRate' => 0, + 'pitrRate' => 0, 'cpu' => 0, 'memory' => 0, 'maxConnections' => 0, @@ -68,16 +72,16 @@ public static function from(array $data): static slug: $data['slug'], name: $data['name'], price: $data['price'], + storageOverageRate: $data['storageOverageRate'], + bandwidthOverageRate: $data['bandwidthOverageRate'], + replicaRate: $data['replicaRate'], + pitrRate: $data['pitrRate'], cpu: $data['cpu'], memory: $data['memory'], maxConnections: $data['maxConnections'], includedStorage: $data['includedStorage'], includedBandwidth: $data['includedBandwidth'], - enabled: $data['enabled'], - storageOverageRate: $data['storageOverageRate'] ?? null, - bandwidthOverageRate: $data['bandwidthOverageRate'] ?? null, - replicaRate: $data['replicaRate'] ?? null, - pitrRate: $data['pitrRate'] ?? null + enabled: $data['enabled'] ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php b/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php index 9ac12067..3f3aca02 100644 --- a/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php @@ -18,12 +18,10 @@ * * @param list $specifications list of dedicated database specifications. * @param int $total total number of specifications. - * @param DedicatedDatabaseSpecificationPricing $pricing overage and add-on pricing shared across all specifications. */ public function __construct( public array $specifications, - public int $total, - public DedicatedDatabaseSpecificationPricing $pricing + public int $total ) { } @@ -33,16 +31,10 @@ public function __construct( public static function from(array $data): static { $data += [ + 'specifications' => [], 'total' => 0, ]; - if (!array_key_exists('specifications', $data)) { - throw new \InvalidArgumentException('Missing required field "specifications" for ' . static::class . '.'); - } - if (!array_key_exists('pricing', $data)) { - throw new \InvalidArgumentException('Missing required field "pricing" for ' . static::class . '.'); - } - return new static( specifications: is_array($data['specifications']) ? array_map( @@ -50,8 +42,7 @@ public static function from(array $data): static $data['specifications'] ) : $data['specifications'], - total: $data['total'], - pricing: static::hydrateTypedValue(DedicatedDatabaseSpecificationPricing::class, $data['pricing']) + total: $data['total'] ); } @@ -62,8 +53,7 @@ public function toArray(): array { return [ 'specifications' => static::serializeValue($this->specifications), - 'total' => static::serializeValue($this->total), - 'pricing' => static::serializeValue($this->pricing) + 'total' => static::serializeValue($this->total) ]; } } diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php b/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php deleted file mode 100644 index c8a11f5f..00000000 --- a/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php +++ /dev/null @@ -1,70 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('storageOverageRate', $data)) { - throw new \InvalidArgumentException('Missing required field "storageOverageRate" for ' . static::class . '.'); - } - if (!array_key_exists('bandwidthOverageRate', $data)) { - throw new \InvalidArgumentException('Missing required field "bandwidthOverageRate" for ' . static::class . '.'); - } - if (!array_key_exists('replicaRate', $data)) { - throw new \InvalidArgumentException('Missing required field "replicaRate" for ' . static::class . '.'); - } - if (!array_key_exists('pitrRate', $data)) { - throw new \InvalidArgumentException('Missing required field "pitrRate" for ' . static::class . '.'); - } - - return new static( - storageOverageRate: $data['storageOverageRate'], - bandwidthOverageRate: $data['bandwidthOverageRate'], - replicaRate: $data['replicaRate'], - pitrRate: $data['pitrRate'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'storageOverageRate' => static::serializeValue($this->storageOverageRate), - 'bandwidthOverageRate' => static::serializeValue($this->bandwidthOverageRate), - 'replicaRate' => static::serializeValue($this->replicaRate), - 'pitrRate' => static::serializeValue($this->pitrRate) - ]; - } -} diff --git a/src/Appwrite/Models/DeploymentList.php b/src/Appwrite/Models/DeploymentList.php index 84e99d1e..cd39aa38 100644 --- a/src/Appwrite/Models/DeploymentList.php +++ b/src/Appwrite/Models/DeploymentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'deployments' => [], ]; - if (!array_key_exists('deployments', $data)) { - throw new \InvalidArgumentException('Missing required field "deployments" for ' . static::class . '.'); - } - return new static( total: $data['total'], deployments: is_array($data['deployments']) diff --git a/src/Appwrite/Models/DevKey.php b/src/Appwrite/Models/DevKey.php deleted file mode 100644 index 971c16fa..00000000 --- a/src/Appwrite/Models/DevKey.php +++ /dev/null @@ -1,98 +0,0 @@ - $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('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - - return new static( - id: $data['$id'], - createdAt: $data['$createdAt'], - updatedAt: $data['$updatedAt'], - name: $data['name'], - expire: $data['expire'], - secret: $data['secret'], - accessedAt: $data['accessedAt'], - sdks: $data['sdks'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - '$id' => static::serializeValue($this->id), - '$createdAt' => static::serializeValue($this->createdAt), - '$updatedAt' => static::serializeValue($this->updatedAt), - 'name' => static::serializeValue($this->name), - 'expire' => static::serializeValue($this->expire), - 'secret' => static::serializeValue($this->secret), - 'accessedAt' => static::serializeValue($this->accessedAt), - 'sdks' => static::serializeValue($this->sdks) - ]; - } -} diff --git a/src/Appwrite/Models/Document.php b/src/Appwrite/Models/Document.php index b0cf5b9c..fa1231f8 100644 --- a/src/Appwrite/Models/Document.php +++ b/src/Appwrite/Models/Document.php @@ -49,12 +49,9 @@ public static function from(array $data): static '$databaseId' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - $additionalProperties = static::extractAdditionalPropertiesFromFields( $data, [ diff --git a/src/Appwrite/Models/DocumentList.php b/src/Appwrite/Models/DocumentList.php index 8a34e498..68bfb14e 100644 --- a/src/Appwrite/Models/DocumentList.php +++ b/src/Appwrite/Models/DocumentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'documents' => [], ]; - if (!array_key_exists('documents', $data)) { - throw new \InvalidArgumentException('Missing required field "documents" for ' . static::class . '.'); - } - return new static( total: $data['total'], documents: is_array($data['documents']) diff --git a/src/Appwrite/Models/EmailTemplateList.php b/src/Appwrite/Models/EmailTemplateList.php index 934220ab..015cc0db 100644 --- a/src/Appwrite/Models/EmailTemplateList.php +++ b/src/Appwrite/Models/EmailTemplateList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'templates' => [], ]; - if (!array_key_exists('templates', $data)) { - throw new \InvalidArgumentException('Missing required field "templates" for ' . static::class . '.'); - } - return new static( total: $data['total'], templates: is_array($data['templates']) diff --git a/src/Appwrite/Models/EmbeddingList.php b/src/Appwrite/Models/EmbeddingList.php index dde35f28..7e362a18 100644 --- a/src/Appwrite/Models/EmbeddingList.php +++ b/src/Appwrite/Models/EmbeddingList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'embeddings' => [], ]; - if (!array_key_exists('embeddings', $data)) { - throw new \InvalidArgumentException('Missing required field "embeddings" for ' . static::class . '.'); - } - return new static( total: $data['total'], embeddings: is_array($data['embeddings']) diff --git a/src/Appwrite/Models/EphemeralKey.php b/src/Appwrite/Models/EphemeralKey.php index 0709c91c..c338f61e 100644 --- a/src/Appwrite/Models/EphemeralKey.php +++ b/src/Appwrite/Models/EphemeralKey.php @@ -53,12 +53,9 @@ public static function from(array $data): static 'scopes' => [], 'secret' => "", 'accessedAt' => "", + 'sdks' => [], ]; - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/Execution.php b/src/Appwrite/Models/Execution.php index 8ac7d6fa..29d3b3dd 100644 --- a/src/Appwrite/Models/Execution.php +++ b/src/Appwrite/Models/Execution.php @@ -37,7 +37,7 @@ * @param list $responseHeaders http response headers as a key-value object. this will return only whitelisted headers. all headers are returned if execution is created as synchronous. * @param string $logs resource logs. includes the last 4,000 characters. this will return an empty string unless the response is returned using an api key or as part of a webhook payload. * @param string $errors resource errors. includes the last 4,000 characters. this will return an empty string unless the response is returned using an api key or as part of a webhook payload. - * @param float $duration resource(function/site) execution duration in seconds. + * @param float $duration total time the resource(function/site) took to respond, in seconds. * @param string|null $scheduledAt the scheduled time for execution. if left empty, execution will be queued immediately. */ public function __construct( @@ -72,33 +72,27 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'resourceId' => "", 'resourceType' => "functions", 'deploymentId' => "", 'requestMethod' => "", 'requestPath' => "", + 'requestHeaders' => [], 'responseStatusCode' => 0, 'responseBody' => "", + 'responseHeaders' => [], 'logs' => "", 'errors' => "", 'duration' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } if (!array_key_exists('trigger', $data)) { throw new \InvalidArgumentException('Missing required field "trigger" for ' . static::class . '.'); } if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('requestHeaders', $data)) { - throw new \InvalidArgumentException('Missing required field "requestHeaders" for ' . static::class . '.'); - } - if (!array_key_exists('responseHeaders', $data)) { - throw new \InvalidArgumentException('Missing required field "responseHeaders" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/ExecutionList.php b/src/Appwrite/Models/ExecutionList.php index ee91c286..2b164511 100644 --- a/src/Appwrite/Models/ExecutionList.php +++ b/src/Appwrite/Models/ExecutionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'executions' => [], ]; - if (!array_key_exists('executions', $data)) { - throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.'); - } - return new static( total: $data['total'], executions: is_array($data['executions']) diff --git a/src/Appwrite/Models/FileList.php b/src/Appwrite/Models/FileList.php index f934a390..cab60fc5 100644 --- a/src/Appwrite/Models/FileList.php +++ b/src/Appwrite/Models/FileList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'files' => [], ]; - if (!array_key_exists('files', $data)) { - throw new \InvalidArgumentException('Missing required field "files" for ' . static::class . '.'); - } - return new static( total: $data['total'], files: is_array($data['files']) diff --git a/src/Appwrite/Models/Framework.php b/src/Appwrite/Models/Framework.php index 7c3efaff..20a43d42 100644 --- a/src/Appwrite/Models/Framework.php +++ b/src/Appwrite/Models/Framework.php @@ -40,15 +40,10 @@ public static function from(array $data): static 'key' => "", 'name' => "", 'buildRuntime' => "", + 'runtimes' => [], + 'adapters' => [], ]; - if (!array_key_exists('runtimes', $data)) { - throw new \InvalidArgumentException('Missing required field "runtimes" for ' . static::class . '.'); - } - if (!array_key_exists('adapters', $data)) { - throw new \InvalidArgumentException('Missing required field "adapters" for ' . static::class . '.'); - } - return new static( key: $data['key'], name: $data['name'], diff --git a/src/Appwrite/Models/FrameworkList.php b/src/Appwrite/Models/FrameworkList.php index 8188732e..9397daa1 100644 --- a/src/Appwrite/Models/FrameworkList.php +++ b/src/Appwrite/Models/FrameworkList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'frameworks' => [], ]; - if (!array_key_exists('frameworks', $data)) { - throw new \InvalidArgumentException('Missing required field "frameworks" for ' . static::class . '.'); - } - return new static( total: $data['total'], frameworks: is_array($data['frameworks']) diff --git a/src/Appwrite/Models/FunctionList.php b/src/Appwrite/Models/FunctionList.php index e5f38db1..39fca279 100644 --- a/src/Appwrite/Models/FunctionList.php +++ b/src/Appwrite/Models/FunctionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'functions' => [], ]; - if (!array_key_exists('functions', $data)) { - throw new \InvalidArgumentException('Missing required field "functions" for ' . static::class . '.'); - } - return new static( total: $data['total'], functions: is_array($data['functions']) diff --git a/src/Appwrite/Models/FunctionModel.php b/src/Appwrite/Models/FunctionModel.php index a6fbc219..559d2087 100644 --- a/src/Appwrite/Models/FunctionModel.php +++ b/src/Appwrite/Models/FunctionModel.php @@ -109,6 +109,7 @@ public static function from(array $data): static 'latestDeploymentCreatedAt' => "", 'latestDeploymentStatus' => "", 'scopes' => [], + 'vars' => [], 'events' => [], 'schedule' => "", 'timeout' => 15, @@ -126,10 +127,6 @@ public static function from(array $data): static 'runtimeSpecification' => "s-1vcpu-512mb", ]; - if (!array_key_exists('vars', $data)) { - throw new \InvalidArgumentException('Missing required field "vars" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/Identity.php b/src/Appwrite/Models/Identity.php index 7b208ff5..d7cc7c47 100644 --- a/src/Appwrite/Models/Identity.php +++ b/src/Appwrite/Models/Identity.php @@ -26,7 +26,7 @@ * @param string $providerAccessToken identity provider access token. * @param string $providerAccessTokenExpiry the date of when the access token expires in iso 8601 format. * @param string $providerRefreshToken identity provider refresh token. - * @param string|null $providerIdToken identity provider id token (jwt) from the most recent native sign-in. empty for identities created through the browser oauth2 flow. + * @param string $providerIdToken identity provider id token (jwt) from the most recent native sign-in. empty for identities created through the browser oauth2 flow. */ public function __construct( public string $id, @@ -39,7 +39,7 @@ public function __construct( public string $providerAccessToken, public string $providerAccessTokenExpiry, public string $providerRefreshToken, - public ?string $providerIdToken = null + public string $providerIdToken ) { } @@ -59,6 +59,7 @@ public static function from(array $data): static 'providerAccessToken' => "", 'providerAccessTokenExpiry' => "", 'providerRefreshToken' => "", + 'providerIdToken' => "", ]; return new static( @@ -72,7 +73,7 @@ public static function from(array $data): static providerAccessToken: $data['providerAccessToken'], providerAccessTokenExpiry: $data['providerAccessTokenExpiry'], providerRefreshToken: $data['providerRefreshToken'], - providerIdToken: $data['providerIdToken'] ?? null + providerIdToken: $data['providerIdToken'] ); } diff --git a/src/Appwrite/Models/IdentityList.php b/src/Appwrite/Models/IdentityList.php index f16cced6..d999ce18 100644 --- a/src/Appwrite/Models/IdentityList.php +++ b/src/Appwrite/Models/IdentityList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'identities' => [], ]; - if (!array_key_exists('identities', $data)) { - throw new \InvalidArgumentException('Missing required field "identities" for ' . static::class . '.'); - } - return new static( total: $data['total'], identities: is_array($data['identities']) diff --git a/src/Appwrite/Models/IndexList.php b/src/Appwrite/Models/IndexList.php index 4f2fbb8e..b9c1b65d 100644 --- a/src/Appwrite/Models/IndexList.php +++ b/src/Appwrite/Models/IndexList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'indexes' => [], ]; - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( total: $data['total'], indexes: is_array($data['indexes']) diff --git a/src/Appwrite/Models/Insight.php b/src/Appwrite/Models/Insight.php index b5b50f95..f05df485 100644 --- a/src/Appwrite/Models/Insight.php +++ b/src/Appwrite/Models/Insight.php @@ -74,12 +74,9 @@ public static function from(array $data): static 'parentResourceId' => "", 'title' => "", 'summary' => "", + 'ctas' => [], ]; - if (!array_key_exists('ctas', $data)) { - throw new \InvalidArgumentException('Missing required field "ctas" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/InsightList.php b/src/Appwrite/Models/InsightList.php index dfa3e4a9..3eee4fe6 100644 --- a/src/Appwrite/Models/InsightList.php +++ b/src/Appwrite/Models/InsightList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'insights' => [], ]; - if (!array_key_exists('insights', $data)) { - throw new \InvalidArgumentException('Missing required field "insights" for ' . static::class . '.'); - } - return new static( total: $data['total'], insights: is_array($data['insights']) diff --git a/src/Appwrite/Models/Key.php b/src/Appwrite/Models/Key.php index 216deb87..6b8e6841 100644 --- a/src/Appwrite/Models/Key.php +++ b/src/Appwrite/Models/Key.php @@ -53,12 +53,9 @@ public static function from(array $data): static 'scopes' => [], 'secret' => "", 'accessedAt' => "", + 'sdks' => [], ]; - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/KeyList.php b/src/Appwrite/Models/KeyList.php index 042450fb..92c164b9 100644 --- a/src/Appwrite/Models/KeyList.php +++ b/src/Appwrite/Models/KeyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'keys' => [], ]; - if (!array_key_exists('keys', $data)) { - throw new \InvalidArgumentException('Missing required field "keys" for ' . static::class . '.'); - } - return new static( total: $data['total'], keys: is_array($data['keys']) diff --git a/src/Appwrite/Models/LanguageList.php b/src/Appwrite/Models/LanguageList.php index 6a57c4b8..7cf1275f 100644 --- a/src/Appwrite/Models/LanguageList.php +++ b/src/Appwrite/Models/LanguageList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'languages' => [], ]; - if (!array_key_exists('languages', $data)) { - throw new \InvalidArgumentException('Missing required field "languages" for ' . static::class . '.'); - } - return new static( total: $data['total'], languages: is_array($data['languages']) diff --git a/src/Appwrite/Models/LocaleCodeList.php b/src/Appwrite/Models/LocaleCodeList.php index 59223a66..a9f1dfcd 100644 --- a/src/Appwrite/Models/LocaleCodeList.php +++ b/src/Appwrite/Models/LocaleCodeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'localeCodes' => [], ]; - if (!array_key_exists('localeCodes', $data)) { - throw new \InvalidArgumentException('Missing required field "localeCodes" for ' . static::class . '.'); - } - return new static( total: $data['total'], localeCodes: is_array($data['localeCodes']) diff --git a/src/Appwrite/Models/Log.php b/src/Appwrite/Models/Log.php deleted file mode 100644 index 01bfb02f..00000000 --- a/src/Appwrite/Models/Log.php +++ /dev/null @@ -1,196 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('event', $data)) { - throw new \InvalidArgumentException('Missing required field "event" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('userEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "userEmail" for ' . static::class . '.'); - } - if (!array_key_exists('userName', $data)) { - throw new \InvalidArgumentException('Missing required field "userName" for ' . static::class . '.'); - } - if (!array_key_exists('mode', $data)) { - throw new \InvalidArgumentException('Missing required field "mode" for ' . static::class . '.'); - } - if (!array_key_exists('userType', $data)) { - throw new \InvalidArgumentException('Missing required field "userType" for ' . static::class . '.'); - } - if (!array_key_exists('ip', $data)) { - throw new \InvalidArgumentException('Missing required field "ip" for ' . static::class . '.'); - } - if (!array_key_exists('time', $data)) { - throw new \InvalidArgumentException('Missing required field "time" for ' . static::class . '.'); - } - if (!array_key_exists('osCode', $data)) { - throw new \InvalidArgumentException('Missing required field "osCode" for ' . static::class . '.'); - } - if (!array_key_exists('osName', $data)) { - throw new \InvalidArgumentException('Missing required field "osName" for ' . static::class . '.'); - } - if (!array_key_exists('osVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "osVersion" for ' . static::class . '.'); - } - if (!array_key_exists('clientType', $data)) { - throw new \InvalidArgumentException('Missing required field "clientType" for ' . static::class . '.'); - } - if (!array_key_exists('clientCode', $data)) { - throw new \InvalidArgumentException('Missing required field "clientCode" for ' . static::class . '.'); - } - if (!array_key_exists('clientName', $data)) { - throw new \InvalidArgumentException('Missing required field "clientName" for ' . static::class . '.'); - } - if (!array_key_exists('clientVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "clientVersion" for ' . static::class . '.'); - } - if (!array_key_exists('clientEngine', $data)) { - throw new \InvalidArgumentException('Missing required field "clientEngine" for ' . static::class . '.'); - } - if (!array_key_exists('clientEngineVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "clientEngineVersion" for ' . static::class . '.'); - } - if (!array_key_exists('deviceName', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceName" for ' . static::class . '.'); - } - if (!array_key_exists('deviceBrand', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceBrand" for ' . static::class . '.'); - } - if (!array_key_exists('deviceModel', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceModel" 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( - event: $data['event'], - userId: $data['userId'], - userEmail: $data['userEmail'], - userName: $data['userName'], - mode: $data['mode'], - userType: $data['userType'], - ip: $data['ip'], - time: $data['time'], - osCode: $data['osCode'], - osName: $data['osName'], - osVersion: $data['osVersion'], - clientType: $data['clientType'], - clientCode: $data['clientCode'], - clientName: $data['clientName'], - clientVersion: $data['clientVersion'], - clientEngine: $data['clientEngine'], - clientEngineVersion: $data['clientEngineVersion'], - deviceName: $data['deviceName'], - deviceBrand: $data['deviceBrand'], - deviceModel: $data['deviceModel'], - countryCode: $data['countryCode'], - countryName: $data['countryName'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'event' => static::serializeValue($this->event), - 'userId' => static::serializeValue($this->userId), - 'userEmail' => static::serializeValue($this->userEmail), - 'userName' => static::serializeValue($this->userName), - 'mode' => static::serializeValue($this->mode), - 'userType' => static::serializeValue($this->userType), - 'ip' => static::serializeValue($this->ip), - 'time' => static::serializeValue($this->time), - 'osCode' => static::serializeValue($this->osCode), - 'osName' => static::serializeValue($this->osName), - 'osVersion' => static::serializeValue($this->osVersion), - 'clientType' => static::serializeValue($this->clientType), - 'clientCode' => static::serializeValue($this->clientCode), - 'clientName' => static::serializeValue($this->clientName), - 'clientVersion' => static::serializeValue($this->clientVersion), - 'clientEngine' => static::serializeValue($this->clientEngine), - 'clientEngineVersion' => static::serializeValue($this->clientEngineVersion), - 'deviceName' => static::serializeValue($this->deviceName), - 'deviceBrand' => static::serializeValue($this->deviceBrand), - 'deviceModel' => static::serializeValue($this->deviceModel), - 'countryCode' => static::serializeValue($this->countryCode), - 'countryName' => static::serializeValue($this->countryName) - ]; - } -} diff --git a/src/Appwrite/Models/LogList.php b/src/Appwrite/Models/LogList.php deleted file mode 100644 index 944b82ca..00000000 --- a/src/Appwrite/Models/LogList.php +++ /dev/null @@ -1,61 +0,0 @@ - $logs list of logs. - */ - public function __construct( - public int $total, - public array $logs - ) { - } - - /** - * @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('logs', $data)) { - throw new \InvalidArgumentException('Missing required field "logs" for ' . static::class . '.'); - } - - return new static( - total: $data['total'], - logs: is_array($data['logs']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(Log::class, $item), - $data['logs'] - ) - : $data['logs'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'total' => static::serializeValue($this->total), - 'logs' => static::serializeValue($this->logs) - ]; - } -} diff --git a/src/Appwrite/Models/MembershipList.php b/src/Appwrite/Models/MembershipList.php index 48529162..ece0e4b1 100644 --- a/src/Appwrite/Models/MembershipList.php +++ b/src/Appwrite/Models/MembershipList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'memberships' => [], ]; - if (!array_key_exists('memberships', $data)) { - throw new \InvalidArgumentException('Missing required field "memberships" for ' . static::class . '.'); - } - return new static( total: $data['total'], memberships: is_array($data['memberships']) diff --git a/src/Appwrite/Models/Message.php b/src/Appwrite/Models/Message.php index 267901bc..3d6ea590 100644 --- a/src/Appwrite/Models/Message.php +++ b/src/Appwrite/Models/Message.php @@ -59,21 +59,14 @@ public static function from(array $data): static '$createdAt' => "", '$updatedAt' => "", 'providerType' => "", + 'topics' => [], + 'users' => [], + 'targets' => [], 'deliveredTotal' => 0, 'data' => [], 'status' => "draft", ]; - if (!array_key_exists('topics', $data)) { - throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); - } - if (!array_key_exists('users', $data)) { - throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); - } - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/MessageList.php b/src/Appwrite/Models/MessageList.php index ea36b3e9..0f341543 100644 --- a/src/Appwrite/Models/MessageList.php +++ b/src/Appwrite/Models/MessageList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'messages' => [], ]; - if (!array_key_exists('messages', $data)) { - throw new \InvalidArgumentException('Missing required field "messages" for ' . static::class . '.'); - } - return new static( total: $data['total'], messages: is_array($data['messages']) diff --git a/src/Appwrite/Models/MockNumberList.php b/src/Appwrite/Models/MockNumberList.php index 60291620..b444d1b0 100644 --- a/src/Appwrite/Models/MockNumberList.php +++ b/src/Appwrite/Models/MockNumberList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'mockNumbers' => [], ]; - if (!array_key_exists('mockNumbers', $data)) { - throw new \InvalidArgumentException('Missing required field "mockNumbers" for ' . static::class . '.'); - } - return new static( total: $data['total'], mockNumbers: is_array($data['mockNumbers']) diff --git a/src/Appwrite/Models/OAuth2Apple.php b/src/Appwrite/Models/OAuth2Apple.php index 91b6b61c..0e9d8915 100644 --- a/src/Appwrite/Models/OAuth2Apple.php +++ b/src/Appwrite/Models/OAuth2Apple.php @@ -22,8 +22,8 @@ * @param string $keyId apple oauth2 key id. * @param string $teamId apple oauth2 team id. * @param string $p8File apple oauth2 .p8 private key file contents. the secret key wrapped by the pem markers is 200 characters long. - * @param bool|null $nativeEnabled native sign in with apple is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. - * @param array|null $nativeClientIds app bundle ids accepted as id token audiences for native sign in with apple, next to the services id. + * @param bool $nativeEnabled native sign in with apple is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. + * @param array $nativeClientIds app bundle ids accepted as id token audiences for native sign in with apple, next to the services id. */ public function __construct( public string $id, @@ -32,8 +32,8 @@ public function __construct( public string $keyId, public string $teamId, public string $p8File, - public ?bool $nativeEnabled = null, - public ?array $nativeClientIds = null + public bool $nativeEnabled, + public array $nativeClientIds ) { } @@ -49,6 +49,8 @@ public static function from(array $data): static 'keyId' => "", 'teamId' => "", 'p8File' => "", + 'nativeEnabled' => false, + 'nativeClientIds' => [], ]; return new static( @@ -58,8 +60,8 @@ public static function from(array $data): static keyId: $data['keyId'], teamId: $data['teamId'], p8File: $data['p8File'], - nativeEnabled: $data['nativeEnabled'] ?? null, - nativeClientIds: $data['nativeClientIds'] ?? null + nativeEnabled: $data['nativeEnabled'], + nativeClientIds: $data['nativeClientIds'] ); } diff --git a/src/Appwrite/Models/OAuth2Auth0.php b/src/Appwrite/Models/OAuth2Auth0.php index 2e119529..6f13390d 100644 --- a/src/Appwrite/Models/OAuth2Auth0.php +++ b/src/Appwrite/Models/OAuth2Auth0.php @@ -22,16 +22,16 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId auth0 oauth2 client id. * @param string $clientSecret auth0 oauth2 client secret. + * @param list $prompt auth0 oauth2 prompt values. * @param string $endpoint auth0 oauth2 endpoint domain. - * @param list|null $prompt auth0 oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public string $endpoint, - public ?array $prompt = null + public array $prompt, + public string $endpoint ) { } @@ -45,6 +45,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'endpoint' => "", ]; @@ -53,17 +54,13 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - endpoint: $data['endpoint'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2Auth0Prompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2Auth0Prompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'], + endpoint: $data['endpoint'] ); } diff --git a/src/Appwrite/Models/OAuth2Discord.php b/src/Appwrite/Models/OAuth2Discord.php index 34d4d3d0..6f1866f7 100644 --- a/src/Appwrite/Models/OAuth2Discord.php +++ b/src/Appwrite/Models/OAuth2Discord.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId discord oauth2 client id. * @param string $clientSecret discord oauth2 client secret. - * @param list|null $prompt discord oauth2 prompt values. + * @param list $prompt discord oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2DiscordPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2DiscordPrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'] ); } diff --git a/src/Appwrite/Models/OAuth2Github.php b/src/Appwrite/Models/OAuth2Github.php index 3e40437f..add2cfba 100644 --- a/src/Appwrite/Models/OAuth2Github.php +++ b/src/Appwrite/Models/OAuth2Github.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId github oauth2 client id. for github apps, use the "app id" when both an app id and client id are available. * @param string $clientSecret github oauth2 client secret. - * @param list|null $prompt github oauth2 prompt values. + * @param list $prompt github oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GithubPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GithubPrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'] ); } diff --git a/src/Appwrite/Models/OAuth2Google.php b/src/Appwrite/Models/OAuth2Google.php index ac2a6bef..4c9d2eb4 100644 --- a/src/Appwrite/Models/OAuth2Google.php +++ b/src/Appwrite/Models/OAuth2Google.php @@ -23,8 +23,8 @@ * @param string $clientId google oauth2 client id. * @param string $clientSecret google oauth2 client secret. * @param list $prompt google oauth2 prompt values. - * @param bool|null $nativeEnabled native google sign-in is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. - * @param array|null $nativeClientIds additional oauth2 client ids accepted as id token audiences for native sign-in, next to the client id. + * @param bool $nativeEnabled native google sign-in is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. + * @param array $nativeClientIds additional oauth2 client ids accepted as id token audiences for native sign-in, next to the client id. */ public function __construct( public string $id, @@ -32,8 +32,8 @@ public function __construct( public string $clientId, public string $clientSecret, public array $prompt, - public ?bool $nativeEnabled = null, - public ?array $nativeClientIds = null + public bool $nativeEnabled, + public array $nativeClientIds ) { } @@ -48,6 +48,8 @@ public static function from(array $data): static 'clientId' => "", 'clientSecret' => "", 'prompt' => ["consent"], + 'nativeEnabled' => false, + 'nativeClientIds' => [], ]; return new static( @@ -61,8 +63,8 @@ public static function from(array $data): static $data['prompt'] ) : $data['prompt'], - nativeEnabled: $data['nativeEnabled'] ?? null, - nativeClientIds: $data['nativeClientIds'] ?? null + nativeEnabled: $data['nativeEnabled'], + nativeClientIds: $data['nativeClientIds'] ); } diff --git a/src/Appwrite/Models/OAuth2Microsoft.php b/src/Appwrite/Models/OAuth2Microsoft.php index 12cddc22..e0e855b3 100644 --- a/src/Appwrite/Models/OAuth2Microsoft.php +++ b/src/Appwrite/Models/OAuth2Microsoft.php @@ -22,16 +22,16 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $applicationId microsoft oauth2 application id. * @param string $applicationSecret microsoft oauth2 application secret. + * @param list $prompt microsoft oauth2 prompt values. * @param string $tenant microsoft entra id tenant identifier. use 'common', 'organizations', 'consumers' or a specific tenant id. - * @param list|null $prompt microsoft oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $applicationId, public string $applicationSecret, - public string $tenant, - public ?array $prompt = null + public array $prompt, + public string $tenant ) { } @@ -45,6 +45,7 @@ public static function from(array $data): static 'enabled' => false, 'applicationId' => "", 'applicationSecret' => "", + 'prompt' => [], 'tenant' => "", ]; @@ -53,17 +54,13 @@ public static function from(array $data): static enabled: $data['enabled'], applicationId: $data['applicationId'], applicationSecret: $data['applicationSecret'], - tenant: $data['tenant'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2MicrosoftPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2MicrosoftPrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'], + tenant: $data['tenant'] ); } diff --git a/src/Appwrite/Models/OAuth2Oidc.php b/src/Appwrite/Models/OAuth2Oidc.php index 3f4a32f6..07547037 100644 --- a/src/Appwrite/Models/OAuth2Oidc.php +++ b/src/Appwrite/Models/OAuth2Oidc.php @@ -22,11 +22,11 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId openid connect oauth2 client id. * @param string $clientSecret openid connect oauth2 client secret. + * @param list $prompt openid connect prompt values controlling the authentication and consent screens. * @param string $wellKnownURL openid connect well-known configuration url. when set, authorization, token, and user info endpoints can be discovered automatically. * @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( @@ -34,11 +34,11 @@ public function __construct( public bool $enabled, public string $clientId, public string $clientSecret, + public array $prompt, public string $wellKnownURL, public string $authorizationURL, public string $tokenURL, public string $userInfoURL, - public array $prompt, public ?int $maxAge = null ) { } @@ -53,11 +53,11 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'wellKnownURL' => "", 'authorizationURL' => "", 'tokenURL' => "", 'userInfoURL' => "", - 'prompt' => [], ]; return new static( @@ -65,16 +65,16 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - wellKnownURL: $data['wellKnownURL'], - authorizationURL: $data['authorizationURL'], - tokenURL: $data['tokenURL'], - userInfoURL: $data['userInfoURL'], prompt: is_array($data['prompt']) ? array_map( static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OidcPrompt::class, $item), $data['prompt'] ) : $data['prompt'], + wellKnownURL: $data['wellKnownURL'], + authorizationURL: $data['authorizationURL'], + tokenURL: $data['tokenURL'], + userInfoURL: $data['userInfoURL'], maxAge: $data['maxAge'] ?? null ); } @@ -89,11 +89,11 @@ public function toArray(): array 'enabled' => static::serializeValue($this->enabled), 'clientId' => static::serializeValue($this->clientId), 'clientSecret' => static::serializeValue($this->clientSecret), + 'prompt' => static::serializeValue($this->prompt), 'wellKnownURL' => static::serializeValue($this->wellKnownURL), 'authorizationURL' => static::serializeValue($this->authorizationURL), 'tokenURL' => static::serializeValue($this->tokenURL), 'userInfoURL' => static::serializeValue($this->userInfoURL), - 'prompt' => static::serializeValue($this->prompt), 'maxAge' => static::serializeValue($this->maxAge) ]; } diff --git a/src/Appwrite/Models/OAuth2Okta.php b/src/Appwrite/Models/OAuth2Okta.php index 10f220af..121607ee 100644 --- a/src/Appwrite/Models/OAuth2Okta.php +++ b/src/Appwrite/Models/OAuth2Okta.php @@ -22,18 +22,18 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId okta oauth2 client id. * @param string $clientSecret okta oauth2 client secret. + * @param list $prompt okta oauth2 prompt values. * @param string $domain okta oauth2 domain. * @param string $authorizationServerId okta oauth2 authorization server id. - * @param list|null $prompt okta oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, + public array $prompt, public string $domain, - public string $authorizationServerId, - public ?array $prompt = null + public string $authorizationServerId ) { } @@ -47,6 +47,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'domain' => "", 'authorizationServerId' => "", ]; @@ -56,18 +57,14 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - domain: $data['domain'], - authorizationServerId: $data['authorizationServerId'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OktaPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OktaPrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'], + domain: $data['domain'], + authorizationServerId: $data['authorizationServerId'] ); } diff --git a/src/Appwrite/Models/OAuth2ProviderList.php b/src/Appwrite/Models/OAuth2ProviderList.php index bd2607be..4e278802 100644 --- a/src/Appwrite/Models/OAuth2ProviderList.php +++ b/src/Appwrite/Models/OAuth2ProviderList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'providers' => [], ]; - if (!array_key_exists('providers', $data)) { - throw new \InvalidArgumentException('Missing required field "providers" for ' . static::class . '.'); - } - return new static( total: $data['total'], providers: $data['providers'] diff --git a/src/Appwrite/Models/OAuth2Salesforce.php b/src/Appwrite/Models/OAuth2Salesforce.php index bea4ea61..f48965c8 100644 --- a/src/Appwrite/Models/OAuth2Salesforce.php +++ b/src/Appwrite/Models/OAuth2Salesforce.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $customerKey salesforce oauth2 consumer key. * @param string $customerSecret salesforce oauth2 consumer secret. - * @param list|null $prompt salesforce oauth2 prompt values. + * @param list $prompt salesforce oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $customerKey, public string $customerSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'customerKey' => "", 'customerSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], customerKey: $data['customerKey'], customerSecret: $data['customerSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2SalesforcePrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2SalesforcePrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'] ); } diff --git a/src/Appwrite/Models/OAuth2Zoho.php b/src/Appwrite/Models/OAuth2Zoho.php index 31966c63..ba102619 100644 --- a/src/Appwrite/Models/OAuth2Zoho.php +++ b/src/Appwrite/Models/OAuth2Zoho.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId zoho oauth2 client id. * @param string $clientSecret zoho oauth2 client secret. - * @param list|null $prompt zoho oauth2 prompt values. + * @param list $prompt zoho oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2ZohoPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2ZohoPrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'] ); } diff --git a/src/Appwrite/Models/Oauth2ConsentList.php b/src/Appwrite/Models/Oauth2ConsentList.php index 5b83a171..1397c04b 100644 --- a/src/Appwrite/Models/Oauth2ConsentList.php +++ b/src/Appwrite/Models/Oauth2ConsentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'consents' => [], ]; - if (!array_key_exists('consents', $data)) { - throw new \InvalidArgumentException('Missing required field "consents" for ' . static::class . '.'); - } - return new static( total: $data['total'], consents: is_array($data['consents']) diff --git a/src/Appwrite/Models/Oauth2ConsentTokenList.php b/src/Appwrite/Models/Oauth2ConsentTokenList.php index 0a0a7bb4..1b23700d 100644 --- a/src/Appwrite/Models/Oauth2ConsentTokenList.php +++ b/src/Appwrite/Models/Oauth2ConsentTokenList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tokens' => [], ]; - if (!array_key_exists('tokens', $data)) { - throw new \InvalidArgumentException('Missing required field "tokens" for ' . static::class . '.'); - } - return new static( total: $data['total'], tokens: is_array($data['tokens']) diff --git a/src/Appwrite/Models/Oauth2OrganizationList.php b/src/Appwrite/Models/Oauth2OrganizationList.php index 6549f554..c5134675 100644 --- a/src/Appwrite/Models/Oauth2OrganizationList.php +++ b/src/Appwrite/Models/Oauth2OrganizationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'organizations' => [], ]; - if (!array_key_exists('organizations', $data)) { - throw new \InvalidArgumentException('Missing required field "organizations" for ' . static::class . '.'); - } - return new static( total: $data['total'], organizations: is_array($data['organizations']) diff --git a/src/Appwrite/Models/Oauth2ProjectList.php b/src/Appwrite/Models/Oauth2ProjectList.php index 111dda83..ad709350 100644 --- a/src/Appwrite/Models/Oauth2ProjectList.php +++ b/src/Appwrite/Models/Oauth2ProjectList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'projects' => [], ]; - if (!array_key_exists('projects', $data)) { - throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); - } - return new static( total: $data['total'], projects: is_array($data['projects']) diff --git a/src/Appwrite/Models/Organization.php b/src/Appwrite/Models/Organization.php index 569bc18f..dbed5cbc 100644 --- a/src/Appwrite/Models/Organization.php +++ b/src/Appwrite/Models/Organization.php @@ -27,19 +27,19 @@ * @param string $billingPlanId organization's billing plan id. * @param BillingPlan $billingPlanDetails organization's billing plan. * @param string $billingEmail billing email set for the organization. - * @param string $billingStartDate billing cycle start date. - * @param string $billingCurrentInvoiceDate current invoice cycle start date. - * @param string $billingNextInvoiceDate next invoice cycle start date. - * @param int $billingTrialDays number of trial days. - * @param string $billingAggregationId current active aggregation id. - * @param string $billingInvoiceId current active aggregation id. - * @param string $paymentMethodId default payment method. * @param string $status team status. * @param bool $markedForDeletion marked for deletion * @param string $platform product with which the organization is associated (appwrite or imagine) * @param array $projects selected projects * @param int|null $billingBudget project budget limit. null when no budget is set. + * @param string|null $billingStartDate billing cycle start date. + * @param string|null $billingCurrentInvoiceDate current invoice cycle start date. + * @param string|null $billingNextInvoiceDate next invoice cycle start date. * @param string|null $billingTrialStartDate start date of trial. + * @param int|null $billingTrialDays number of trial days. + * @param string|null $billingAggregationId current active aggregation id. + * @param string|null $billingInvoiceId current active aggregation id. + * @param string|null $paymentMethodId default payment method. * @param string|null $billingAddressId default payment method. * @param string|null $backupPaymentMethodId backup payment method. * @param string|null $remarks remarks on team status. @@ -64,19 +64,19 @@ public function __construct( public string $billingPlanId, public BillingPlan $billingPlanDetails, public string $billingEmail, - public string $billingStartDate, - public string $billingCurrentInvoiceDate, - public string $billingNextInvoiceDate, - public int $billingTrialDays, - public string $billingAggregationId, - public string $billingInvoiceId, - public string $paymentMethodId, public string $status, public bool $markedForDeletion, public string $platform, public array $projects, public ?int $billingBudget = null, + public ?string $billingStartDate = null, + public ?string $billingCurrentInvoiceDate = null, + public ?string $billingNextInvoiceDate = null, public ?string $billingTrialStartDate = null, + public ?int $billingTrialDays = null, + public ?string $billingAggregationId = null, + public ?string $billingInvoiceId = null, + public ?string $paymentMethodId = null, public ?string $billingAddressId = null, public ?string $backupPaymentMethodId = null, public ?string $remarks = null, @@ -118,27 +118,6 @@ public static function from(array $data): static if (!array_key_exists('billingPlanDetails', $data)) { throw new \InvalidArgumentException('Missing required field "billingPlanDetails" 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('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 . '.'); - } return new static( id: $data['$id'], @@ -152,19 +131,19 @@ public static function from(array $data): static billingPlanId: $data['billingPlanId'], billingPlanDetails: static::hydrateTypedValue(BillingPlan::class, $data['billingPlanDetails']), billingEmail: $data['billingEmail'], - billingStartDate: $data['billingStartDate'], - billingCurrentInvoiceDate: $data['billingCurrentInvoiceDate'], - billingNextInvoiceDate: $data['billingNextInvoiceDate'], - billingTrialDays: $data['billingTrialDays'], - billingAggregationId: $data['billingAggregationId'], - billingInvoiceId: $data['billingInvoiceId'], - paymentMethodId: $data['paymentMethodId'], status: $data['status'], markedForDeletion: $data['markedForDeletion'], platform: $data['platform'], projects: $data['projects'], billingBudget: $data['billingBudget'] ?? null, + billingStartDate: $data['billingStartDate'] ?? null, + billingCurrentInvoiceDate: $data['billingCurrentInvoiceDate'] ?? null, + billingNextInvoiceDate: $data['billingNextInvoiceDate'] ?? null, billingTrialStartDate: $data['billingTrialStartDate'] ?? null, + billingTrialDays: $data['billingTrialDays'] ?? null, + billingAggregationId: $data['billingAggregationId'] ?? null, + billingInvoiceId: $data['billingInvoiceId'] ?? null, + paymentMethodId: $data['paymentMethodId'] ?? null, billingAddressId: $data['billingAddressId'] ?? null, backupPaymentMethodId: $data['backupPaymentMethodId'] ?? null, remarks: $data['remarks'] ?? null, diff --git a/src/Appwrite/Models/Passkey.php b/src/Appwrite/Models/Passkey.php index 19e27794..61233db4 100644 --- a/src/Appwrite/Models/Passkey.php +++ b/src/Appwrite/Models/Passkey.php @@ -36,21 +36,13 @@ public function __construct( */ 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('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'accessedAt' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PasskeyChallenge.php b/src/Appwrite/Models/PasskeyChallenge.php index bb415366..c0ba66ca 100644 --- a/src/Appwrite/Models/PasskeyChallenge.php +++ b/src/Appwrite/Models/PasskeyChallenge.php @@ -36,21 +36,13 @@ public function __construct( */ 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('passkeyId', $data)) { - throw new \InvalidArgumentException('Missing required field "passkeyId" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('publicKey', $data)) { - throw new \InvalidArgumentException('Missing required field "publicKey" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'passkeyId' => "", + 'expire' => "", + 'publicKey' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PasskeyList.php b/src/Appwrite/Models/PasskeyList.php index f9506e55..7ef3d4b0 100644 --- a/src/Appwrite/Models/PasskeyList.php +++ b/src/Appwrite/Models/PasskeyList.php @@ -30,12 +30,10 @@ public function __construct( */ 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('passkeys', $data)) { - throw new \InvalidArgumentException('Missing required field "passkeys" for ' . static::class . '.'); - } + $data += [ + 'total' => 0, + 'passkeys' => [], + ]; return new static( total: $data['total'], diff --git a/src/Appwrite/Models/PhoneList.php b/src/Appwrite/Models/PhoneList.php index ac802484..318a2782 100644 --- a/src/Appwrite/Models/PhoneList.php +++ b/src/Appwrite/Models/PhoneList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'phones' => [], ]; - if (!array_key_exists('phones', $data)) { - throw new \InvalidArgumentException('Missing required field "phones" for ' . static::class . '.'); - } - return new static( total: $data['total'], phones: is_array($data['phones']) diff --git a/src/Appwrite/Models/PlatformAndroid.php b/src/Appwrite/Models/PlatformAndroid.php index 246df74b..bc9f9662 100644 --- a/src/Appwrite/Models/PlatformAndroid.php +++ b/src/Appwrite/Models/PlatformAndroid.php @@ -24,7 +24,7 @@ * @param string $name platform name. * @param PlatformType $type platform type. possible values are: windows, apple, android, linux, web. * @param string $applicationId android application id. - * @param array|null $fingerprints sha-256 fingerprints of the certificates the app is signed with. passkeys created in the app are accepted when its signature matches one. + * @param array $fingerprints sha-256 fingerprints of the certificates the app is signed with. passkeys created in the app are accepted when its signature matches one. */ public function __construct( public string $id, @@ -33,7 +33,7 @@ public function __construct( public string $name, public PlatformType $type, public string $applicationId, - public ?array $fingerprints = null + public array $fingerprints ) { } @@ -48,6 +48,7 @@ public static function from(array $data): static '$updatedAt' => "", 'name' => "", 'applicationId' => "", + 'fingerprints' => [], ]; if (!array_key_exists('type', $data)) { @@ -61,7 +62,7 @@ public static function from(array $data): static name: $data['name'], type: static::hydrateTypedValue(PlatformType::class, $data['type']), applicationId: $data['applicationId'], - fingerprints: $data['fingerprints'] ?? null + fingerprints: $data['fingerprints'] ); } diff --git a/src/Appwrite/Models/PlatformList.php b/src/Appwrite/Models/PlatformList.php index c8d64a41..6819d824 100644 --- a/src/Appwrite/Models/PlatformList.php +++ b/src/Appwrite/Models/PlatformList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'platforms' => [], ]; - if (!array_key_exists('platforms', $data)) { - throw new \InvalidArgumentException('Missing required field "platforms" for ' . static::class . '.'); - } - return new static( total: $data['total'], platforms: $data['platforms'] diff --git a/src/Appwrite/Models/PolicyList.php b/src/Appwrite/Models/PolicyList.php index a1599a40..16069c98 100644 --- a/src/Appwrite/Models/PolicyList.php +++ b/src/Appwrite/Models/PolicyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'policies' => [], ]; - if (!array_key_exists('policies', $data)) { - throw new \InvalidArgumentException('Missing required field "policies" for ' . static::class . '.'); - } - return new static( total: $data['total'], policies: $data['policies'] diff --git a/src/Appwrite/Models/PolicyPasskey.php b/src/Appwrite/Models/PolicyPasskey.php index 5dd5735a..f094bda4 100644 --- a/src/Appwrite/Models/PolicyPasskey.php +++ b/src/Appwrite/Models/PolicyPasskey.php @@ -32,15 +32,11 @@ public function __construct( */ 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('rpId', $data)) { - throw new \InvalidArgumentException('Missing required field "rpId" for ' . static::class . '.'); - } - if (!array_key_exists('origins', $data)) { - throw new \InvalidArgumentException('Missing required field "origins" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'rpId' => "", + 'origins' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Presence.php b/src/Appwrite/Models/Presence.php index 95ae696c..bd211ffe 100644 --- a/src/Appwrite/Models/Presence.php +++ b/src/Appwrite/Models/Presence.php @@ -48,14 +48,11 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'userId' => "", 'source' => "", ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/PresenceList.php b/src/Appwrite/Models/PresenceList.php index c363e108..c2e12147 100644 --- a/src/Appwrite/Models/PresenceList.php +++ b/src/Appwrite/Models/PresenceList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'presences' => [], ]; - if (!array_key_exists('presences', $data)) { - throw new \InvalidArgumentException('Missing required field "presences" for ' . static::class . '.'); - } - return new static( total: $data['total'], presences: is_array($data['presences']) diff --git a/src/Appwrite/Models/Project.php b/src/Appwrite/Models/Project.php index 256193bd..9735a0d8 100644 --- a/src/Appwrite/Models/Project.php +++ b/src/Appwrite/Models/Project.php @@ -22,7 +22,6 @@ * @param string $name project name. * @param string $teamId project team id. * @param string $region project region - * @param list $devKeys deprecated since 1.9.5: list of dev keys. * @param bool $smtpEnabled status for custom smtp * @param string $smtpSenderName smtp sender name * @param string $smtpSenderEmail smtp sender email @@ -73,7 +72,6 @@ public function __construct( public string $name, public string $teamId, public string $region, - public array $devKeys, public bool $smtpEnabled, public string $smtpSenderName, public string $smtpSenderEmail, @@ -146,25 +144,13 @@ public static function from(array $data): static 'labels' => [], 'status' => "active", 'onboarding' => [], + 'authMethods' => [], + 'services' => [], + 'protocols' => [], + 'blocks' => [], 'consoleAccessedAt' => "", ]; - if (!array_key_exists('devKeys', $data)) { - throw new \InvalidArgumentException('Missing required field "devKeys" for ' . static::class . '.'); - } - if (!array_key_exists('authMethods', $data)) { - throw new \InvalidArgumentException('Missing required field "authMethods" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('protocols', $data)) { - throw new \InvalidArgumentException('Missing required field "protocols" for ' . static::class . '.'); - } - if (!array_key_exists('blocks', $data)) { - throw new \InvalidArgumentException('Missing required field "blocks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], @@ -172,12 +158,6 @@ public static function from(array $data): static name: $data['name'], teamId: $data['teamId'], region: $data['region'], - devKeys: is_array($data['devKeys']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(DevKey::class, $item), - $data['devKeys'] - ) - : $data['devKeys'], smtpEnabled: $data['smtpEnabled'], smtpSenderName: $data['smtpSenderName'], smtpSenderEmail: $data['smtpSenderEmail'], @@ -255,7 +235,6 @@ public function toArray(): array 'name' => static::serializeValue($this->name), 'teamId' => static::serializeValue($this->teamId), 'region' => static::serializeValue($this->region), - 'devKeys' => static::serializeValue($this->devKeys), 'smtpEnabled' => static::serializeValue($this->smtpEnabled), 'smtpSenderName' => static::serializeValue($this->smtpSenderName), 'smtpSenderEmail' => static::serializeValue($this->smtpSenderEmail), diff --git a/src/Appwrite/Models/ProjectList.php b/src/Appwrite/Models/ProjectList.php index f7261447..17d71c0c 100644 --- a/src/Appwrite/Models/ProjectList.php +++ b/src/Appwrite/Models/ProjectList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'projects' => [], ]; - if (!array_key_exists('projects', $data)) { - throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); - } - return new static( total: $data['total'], projects: is_array($data['projects']) diff --git a/src/Appwrite/Models/ProviderList.php b/src/Appwrite/Models/ProviderList.php index 68bbeb5d..bd6ba8ea 100644 --- a/src/Appwrite/Models/ProviderList.php +++ b/src/Appwrite/Models/ProviderList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'providers' => [], ]; - if (!array_key_exists('providers', $data)) { - throw new \InvalidArgumentException('Missing required field "providers" for ' . static::class . '.'); - } - return new static( total: $data['total'], providers: is_array($data['providers']) diff --git a/src/Appwrite/Models/ProxyRule.php b/src/Appwrite/Models/ProxyRule.php index cc9f7583..5caeec45 100644 --- a/src/Appwrite/Models/ProxyRule.php +++ b/src/Appwrite/Models/ProxyRule.php @@ -33,7 +33,7 @@ * @param ProxyRuleStatus $status domain verification status. possible values are "unverified", "verifying", "verified" * @param string $logs logs from rule verification or certificate generation. certificate generation logs are prioritized if both are available. * @param string $renewAt certificate auto-renewal date in iso 8601 format. - * @param ProxyRuleDeploymentResourceType|null $deploymentResourceType type of deployment. possible values are "function", "site". used if rule's type is "deployment". + * @param ProxyRuleDeploymentResourceType|null $deploymentResourceType type of deployment resource: function, site, or dedicateddatabase. */ public function __construct( public string $id, diff --git a/src/Appwrite/Models/ProxyRuleList.php b/src/Appwrite/Models/ProxyRuleList.php index 413058a4..ac83cabf 100644 --- a/src/Appwrite/Models/ProxyRuleList.php +++ b/src/Appwrite/Models/ProxyRuleList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'rules' => [], ]; - if (!array_key_exists('rules', $data)) { - throw new \InvalidArgumentException('Missing required field "rules" for ' . static::class . '.'); - } - return new static( total: $data['total'], rules: is_array($data['rules']) diff --git a/src/Appwrite/Models/Report.php b/src/Appwrite/Models/Report.php index 8ecd43f9..e004db96 100644 --- a/src/Appwrite/Models/Report.php +++ b/src/Appwrite/Models/Report.php @@ -61,12 +61,9 @@ public static function from(array $data): static 'targetType' => "", 'target' => "", 'categories' => [], + 'insights' => [], ]; - if (!array_key_exists('insights', $data)) { - throw new \InvalidArgumentException('Missing required field "insights" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/ReportList.php b/src/Appwrite/Models/ReportList.php index ea32a528..5e129d3d 100644 --- a/src/Appwrite/Models/ReportList.php +++ b/src/Appwrite/Models/ReportList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'reports' => [], ]; - if (!array_key_exists('reports', $data)) { - throw new \InvalidArgumentException('Missing required field "reports" for ' . static::class . '.'); - } - return new static( total: $data['total'], reports: is_array($data['reports']) diff --git a/src/Appwrite/Models/ResourceTokenList.php b/src/Appwrite/Models/ResourceTokenList.php index 2b9b1885..c50b4801 100644 --- a/src/Appwrite/Models/ResourceTokenList.php +++ b/src/Appwrite/Models/ResourceTokenList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tokens' => [], ]; - if (!array_key_exists('tokens', $data)) { - throw new \InvalidArgumentException('Missing required field "tokens" for ' . static::class . '.'); - } - return new static( total: $data['total'], tokens: is_array($data['tokens']) diff --git a/src/Appwrite/Models/Row.php b/src/Appwrite/Models/Row.php index d37ab8ab..1e323515 100644 --- a/src/Appwrite/Models/Row.php +++ b/src/Appwrite/Models/Row.php @@ -49,12 +49,9 @@ public static function from(array $data): static '$databaseId' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - $additionalProperties = static::extractAdditionalPropertiesFromFields( $data, [ diff --git a/src/Appwrite/Models/RowList.php b/src/Appwrite/Models/RowList.php index f5194b86..9cf05c07 100644 --- a/src/Appwrite/Models/RowList.php +++ b/src/Appwrite/Models/RowList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'rows' => [], ]; - if (!array_key_exists('rows', $data)) { - throw new \InvalidArgumentException('Missing required field "rows" for ' . static::class . '.'); - } - return new static( total: $data['total'], rows: is_array($data['rows']) diff --git a/src/Appwrite/Models/Runtime.php b/src/Appwrite/Models/Runtime.php index 6b51ebed..84aa814d 100644 --- a/src/Appwrite/Models/Runtime.php +++ b/src/Appwrite/Models/Runtime.php @@ -50,12 +50,9 @@ public static function from(array $data): static 'base' => "", 'image' => "", 'logo' => "", + 'supports' => [], ]; - if (!array_key_exists('supports', $data)) { - throw new \InvalidArgumentException('Missing required field "supports" for ' . static::class . '.'); - } - return new static( id: $data['$id'], key: $data['key'], diff --git a/src/Appwrite/Models/RuntimeList.php b/src/Appwrite/Models/RuntimeList.php index 32baecf3..c13abbcf 100644 --- a/src/Appwrite/Models/RuntimeList.php +++ b/src/Appwrite/Models/RuntimeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'runtimes' => [], ]; - if (!array_key_exists('runtimes', $data)) { - throw new \InvalidArgumentException('Missing required field "runtimes" for ' . static::class . '.'); - } - return new static( total: $data['total'], runtimes: is_array($data['runtimes']) diff --git a/src/Appwrite/Models/SessionList.php b/src/Appwrite/Models/SessionList.php index 33e062cc..d834c970 100644 --- a/src/Appwrite/Models/SessionList.php +++ b/src/Appwrite/Models/SessionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'sessions' => [], ]; - if (!array_key_exists('sessions', $data)) { - throw new \InvalidArgumentException('Missing required field "sessions" for ' . static::class . '.'); - } - return new static( total: $data['total'], sessions: is_array($data['sessions']) diff --git a/src/Appwrite/Models/Site.php b/src/Appwrite/Models/Site.php index 671bb5d4..3b00ca02 100644 --- a/src/Appwrite/Models/Site.php +++ b/src/Appwrite/Models/Site.php @@ -114,6 +114,7 @@ public static function from(array $data): static 'latestDeploymentCreatedAt' => "", 'latestDeploymentStatus' => "", 'scopes' => [], + 'vars' => [], 'timeout' => 15, 'installCommand' => "", 'buildCommand' => "", @@ -131,9 +132,6 @@ public static function from(array $data): static 'buildRuntime' => "", ]; - if (!array_key_exists('vars', $data)) { - throw new \InvalidArgumentException('Missing required field "vars" for ' . static::class . '.'); - } if (!array_key_exists('adapter', $data)) { throw new \InvalidArgumentException('Missing required field "adapter" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/SiteList.php b/src/Appwrite/Models/SiteList.php index e3b32b48..2adcf105 100644 --- a/src/Appwrite/Models/SiteList.php +++ b/src/Appwrite/Models/SiteList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'sites' => [], ]; - if (!array_key_exists('sites', $data)) { - throw new \InvalidArgumentException('Missing required field "sites" for ' . static::class . '.'); - } - return new static( total: $data['total'], sites: is_array($data['sites']) diff --git a/src/Appwrite/Models/SpecificationList.php b/src/Appwrite/Models/SpecificationList.php index e48faded..117627c5 100644 --- a/src/Appwrite/Models/SpecificationList.php +++ b/src/Appwrite/Models/SpecificationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'specifications' => [], ]; - if (!array_key_exists('specifications', $data)) { - throw new \InvalidArgumentException('Missing required field "specifications" for ' . static::class . '.'); - } - return new static( total: $data['total'], specifications: is_array($data['specifications']) diff --git a/src/Appwrite/Models/SubscriberList.php b/src/Appwrite/Models/SubscriberList.php index 705cb0b5..cdd1819b 100644 --- a/src/Appwrite/Models/SubscriberList.php +++ b/src/Appwrite/Models/SubscriberList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'subscribers' => [], ]; - if (!array_key_exists('subscribers', $data)) { - throw new \InvalidArgumentException('Missing required field "subscribers" for ' . static::class . '.'); - } - return new static( total: $data['total'], subscribers: is_array($data['subscribers']) diff --git a/src/Appwrite/Models/Table.php b/src/Appwrite/Models/Table.php index 49869583..dc197d32 100644 --- a/src/Appwrite/Models/Table.php +++ b/src/Appwrite/Models/Table.php @@ -54,24 +54,17 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'rowSecurity' => false, + 'columns' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/TableList.php b/src/Appwrite/Models/TableList.php index c6352fb6..c3aa35fc 100644 --- a/src/Appwrite/Models/TableList.php +++ b/src/Appwrite/Models/TableList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tables' => [], ]; - if (!array_key_exists('tables', $data)) { - throw new \InvalidArgumentException('Missing required field "tables" for ' . static::class . '.'); - } - return new static( total: $data['total'], tables: is_array($data['tables']) diff --git a/src/Appwrite/Models/TargetList.php b/src/Appwrite/Models/TargetList.php index 8596f116..e68cdcf4 100644 --- a/src/Appwrite/Models/TargetList.php +++ b/src/Appwrite/Models/TargetList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'targets' => [], ]; - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } - return new static( total: $data['total'], targets: is_array($data['targets']) diff --git a/src/Appwrite/Models/TeamList.php b/src/Appwrite/Models/TeamList.php index 8c75339d..b9647882 100644 --- a/src/Appwrite/Models/TeamList.php +++ b/src/Appwrite/Models/TeamList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'teams' => [], ]; - if (!array_key_exists('teams', $data)) { - throw new \InvalidArgumentException('Missing required field "teams" for ' . static::class . '.'); - } - return new static( total: $data['total'], teams: is_array($data['teams']) diff --git a/src/Appwrite/Models/TokenSecret.php b/src/Appwrite/Models/TokenSecret.php index deedef6b..a9b879de 100644 --- a/src/Appwrite/Models/TokenSecret.php +++ b/src/Appwrite/Models/TokenSecret.php @@ -38,24 +38,14 @@ public function __construct( */ 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('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('phrase', $data)) { - throw new \InvalidArgumentException('Missing required field "phrase" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'userId' => "", + 'secret' => "", + 'expire' => "", + 'phrase' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Topic.php b/src/Appwrite/Models/Topic.php index 42f22386..4719c755 100644 --- a/src/Appwrite/Models/Topic.php +++ b/src/Appwrite/Models/Topic.php @@ -25,7 +25,7 @@ * @param int $pushTotal total count of push subscribers subscribed to the topic. * @param array $subscribe subscribe permissions. * @param int|null $qos mqtt qos for delivery on this topic. null lets the subscriber choose their level. - * @param int|null $expiry message retention in seconds for offline delivery. + * @param int|null $expiry message retention in seconds for offline delivery. null inherits the lowest expiry of the project's enabled appwrite providers, or the 7-day ledger window if none sets one. */ public function __construct( public string $id, diff --git a/src/Appwrite/Models/TopicList.php b/src/Appwrite/Models/TopicList.php index 4ba86969..48bbc421 100644 --- a/src/Appwrite/Models/TopicList.php +++ b/src/Appwrite/Models/TopicList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'topics' => [], ]; - if (!array_key_exists('topics', $data)) { - throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); - } - return new static( total: $data['total'], topics: is_array($data['topics']) diff --git a/src/Appwrite/Models/TransactionList.php b/src/Appwrite/Models/TransactionList.php index 7e17740d..92fd205d 100644 --- a/src/Appwrite/Models/TransactionList.php +++ b/src/Appwrite/Models/TransactionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'transactions' => [], ]; - if (!array_key_exists('transactions', $data)) { - throw new \InvalidArgumentException('Missing required field "transactions" for ' . static::class . '.'); - } - return new static( total: $data['total'], transactions: is_array($data['transactions']) diff --git a/src/Appwrite/Models/UsageBillingPlan.php b/src/Appwrite/Models/UsageBillingPlan.php index eb9cab99..1db3b763 100644 --- a/src/Appwrite/Models/UsageBillingPlan.php +++ b/src/Appwrite/Models/UsageBillingPlan.php @@ -16,29 +16,29 @@ /** * UsageBillingPlan constructor. * - * @param AdditionalResource $bandwidth bandwidth additional resources - * @param AdditionalResource $executions executions additional resources - * @param AdditionalResource $realtime realtime additional resources - * @param AdditionalResource $realtimeMessages realtime messages additional resources - * @param AdditionalResource $storage storage additional resources - * @param AdditionalResource $users user additional resources - * @param AdditionalResource $gBHours gbhour additional resources - * @param AdditionalResource $imageTransformations image transformation additional resources + * @param AdditionalResource|null $bandwidth bandwidth additional resources + * @param AdditionalResource|null $executions executions additional resources * @param AdditionalResource|null $member member additional resources + * @param AdditionalResource|null $realtime realtime additional resources + * @param AdditionalResource|null $realtimeMessages realtime messages additional resources * @param AdditionalResource|null $realtimeBandwidth realtime bandwidth additional resources + * @param AdditionalResource|null $storage storage additional resources + * @param AdditionalResource|null $users user additional resources + * @param AdditionalResource|null $gBHours gbhour additional resources + * @param AdditionalResource|null $imageTransformations image transformation additional resources * @param AdditionalResource|null $credits credits additional resources */ public function __construct( - public AdditionalResource $bandwidth, - public AdditionalResource $executions, - public AdditionalResource $realtime, - public AdditionalResource $realtimeMessages, - public AdditionalResource $storage, - public AdditionalResource $users, - public AdditionalResource $gBHours, - public AdditionalResource $imageTransformations, + public ?AdditionalResource $bandwidth = null, + public ?AdditionalResource $executions = null, public ?AdditionalResource $member = null, + public ?AdditionalResource $realtime = null, + public ?AdditionalResource $realtimeMessages = null, public ?AdditionalResource $realtimeBandwidth = null, + public ?AdditionalResource $storage = null, + public ?AdditionalResource $users = null, + public ?AdditionalResource $gBHours = null, + public ?AdditionalResource $imageTransformations = null, public ?AdditionalResource $credits = null ) { } @@ -48,42 +48,18 @@ public function __construct( */ 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('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('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 . '.'); - } return new static( - bandwidth: static::hydrateTypedValue(AdditionalResource::class, $data['bandwidth']), - executions: static::hydrateTypedValue(AdditionalResource::class, $data['executions']), - realtime: static::hydrateTypedValue(AdditionalResource::class, $data['realtime']), - realtimeMessages: static::hydrateTypedValue(AdditionalResource::class, $data['realtimeMessages']), - 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']), + bandwidth: array_key_exists('bandwidth', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['bandwidth'], true) : null, + executions: array_key_exists('executions', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['executions'], true) : null, member: array_key_exists('member', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['member'], true) : null, + realtime: array_key_exists('realtime', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtime'], true) : null, + realtimeMessages: array_key_exists('realtimeMessages', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtimeMessages'], true) : null, realtimeBandwidth: array_key_exists('realtimeBandwidth', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtimeBandwidth'], true) : null, + storage: array_key_exists('storage', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['storage'], true) : null, + users: array_key_exists('users', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['users'], true) : null, + gBHours: array_key_exists('GBHours', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['GBHours'], true) : null, + imageTransformations: array_key_exists('imageTransformations', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['imageTransformations'], true) : null, credits: array_key_exists('credits', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['credits'], true) : null ); } diff --git a/src/Appwrite/Models/User.php b/src/Appwrite/Models/User.php index 476c9802..57c6d397 100644 --- a/src/Appwrite/Models/User.php +++ b/src/Appwrite/Models/User.php @@ -94,15 +94,13 @@ public static function from(array $data): static 'emailVerification' => false, 'phoneVerification' => false, 'mfa' => false, + 'targets' => [], 'accessedAt' => "", ]; if (!array_key_exists('prefs', $data)) { throw new \InvalidArgumentException('Missing required field "prefs" for ' . static::class . '.'); } - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/UserList.php b/src/Appwrite/Models/UserList.php index 8c4d99d0..b3c9b38c 100644 --- a/src/Appwrite/Models/UserList.php +++ b/src/Appwrite/Models/UserList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'users' => [], ]; - if (!array_key_exists('users', $data)) { - throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); - } - return new static( total: $data['total'], users: is_array($data['users']) diff --git a/src/Appwrite/Models/VariableList.php b/src/Appwrite/Models/VariableList.php index 698af61c..9a8ae59b 100644 --- a/src/Appwrite/Models/VariableList.php +++ b/src/Appwrite/Models/VariableList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'variables' => [], ]; - if (!array_key_exists('variables', $data)) { - throw new \InvalidArgumentException('Missing required field "variables" for ' . static::class . '.'); - } - return new static( total: $data['total'], variables: is_array($data['variables']) diff --git a/src/Appwrite/Models/VectorsdbCollection.php b/src/Appwrite/Models/VectorsdbCollection.php index 38e5ec63..1ec525b7 100644 --- a/src/Appwrite/Models/VectorsdbCollection.php +++ b/src/Appwrite/Models/VectorsdbCollection.php @@ -56,25 +56,18 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'documentSecurity' => false, + 'attributes' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, 'dimension' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/VectorsdbCollectionList.php b/src/Appwrite/Models/VectorsdbCollectionList.php index e5c2c05c..8e414ae9 100644 --- a/src/Appwrite/Models/VectorsdbCollectionList.php +++ b/src/Appwrite/Models/VectorsdbCollectionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'collections' => [], ]; - if (!array_key_exists('collections', $data)) { - throw new \InvalidArgumentException('Missing required field "collections" for ' . static::class . '.'); - } - return new static( total: $data['total'], collections: is_array($data['collections']) diff --git a/src/Appwrite/Models/Webhook.php b/src/Appwrite/Models/Webhook.php index 9f1bef97..4df57b11 100644 --- a/src/Appwrite/Models/Webhook.php +++ b/src/Appwrite/Models/Webhook.php @@ -24,7 +24,7 @@ * @param array $events webhook trigger events. * @param bool $tls indicates if ssl / tls certificate verification is enabled. * @param string $authUsername http basic authentication username. - * @param string $authPassword http basic authentication password. + * @param string $authPassword http basic authentication password. write-only: always returned empty. * @param string $secret signature key which can be used to validate incoming webhook payloads. only returned on creation and secret rotation. * @param bool $enabled indicates if this webhook is enabled. * @param string $logs webhook error logs from the most recent failure. diff --git a/src/Appwrite/Models/WebhookList.php b/src/Appwrite/Models/WebhookList.php index dafb70d4..9ff66138 100644 --- a/src/Appwrite/Models/WebhookList.php +++ b/src/Appwrite/Models/WebhookList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'webhooks' => [], ]; - if (!array_key_exists('webhooks', $data)) { - throw new \InvalidArgumentException('Missing required field "webhooks" for ' . static::class . '.'); - } - return new static( total: $data['total'], webhooks: is_array($data['webhooks']) diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 6caf55ff..74a1925d 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -144,6 +144,10 @@ public function listConsents(?array $queries = null, ?bool $total = null): \Appw */ public function getConsent(string $consentId): \Appwrite\Models\Oauth2Consent { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -180,6 +184,10 @@ public function getConsent(string $consentId): \Appwrite\Models\Oauth2Consent */ public function deleteConsent(string $consentId): string { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -211,6 +219,10 @@ public function deleteConsent(string $consentId): string */ public function listConsentTokens(string $consentId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\Oauth2ConsentTokenList { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -254,6 +266,14 @@ public function listConsentTokens(string $consentId, ?array $queries = null, ?bo */ public function getConsentToken(string $consentId, string $tokenId): \Appwrite\Models\Oauth2ConsentToken { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{consentId}', '{tokenId}'], [$consentId, $tokenId], @@ -291,6 +311,14 @@ public function getConsentToken(string $consentId, string $tokenId): \Appwrite\M */ public function deleteConsentToken(string $consentId, string $tokenId): string { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{consentId}', '{tokenId}'], [$consentId, $tokenId], @@ -404,6 +432,10 @@ public function listIdentities(?array $queries = null, ?bool $total = null): \Ap */ public function deleteIdentity(string $identityId): string { + if ($identityId === '') { + throw new AppwriteException('Missing required parameter: "identityId"'); + } + $apiPath = str_replace( ['{identityId}'], [$identityId], @@ -416,6 +448,7 @@ public function deleteIdentity(string $identityId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -425,48 +458,6 @@ public function deleteIdentity(string $identityId): string ); } - /** - * Get the list of latest security activity logs for the currently logged in - * user. Each log returns user IP address, location and date and time of log. - * - * @throws AppwriteException - */ - public function listLogs(?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - [], - [], - '/account/logs' - ); - - $apiParams = []; - - 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); - } - /** * Enable or disable MFA on an account. * @@ -597,6 +588,7 @@ public function deleteMFAAuthenticator(AuthenticatorType $type): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1484,7 +1476,8 @@ public function listSessions(?bool $total = null): \Appwrite\Models\SessionList /** * Delete all sessions from the user account and remove any sessions cookies - * from the end client. + * from the end client. Pass `current` as false to keep the session making the + * request and sign out of every other session. * * @throws AppwriteException */ @@ -1505,6 +1498,7 @@ public function deleteSessions(?bool $current = null): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1557,6 +1551,9 @@ public function createAnonymousSession(): \Appwrite\Models\Session /** * Allow the user to login into their account by providing a valid email and * password combination. This route will create a new session for the user. + * Use the optional `duration` parameter to create a shorter session, for + * example when the user doesn't choose "remember me". It must be at least 60 + * seconds and cannot exceed the project maximum session length. * * A user is limited to 10 active sessions at a time by default. [Learn more * about session @@ -1816,6 +1813,10 @@ public function createSession(string $userId, string $secret): \Appwrite\Models\ */ public function getSession(string $sessionId): \Appwrite\Models\Session { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1852,6 +1853,10 @@ public function getSession(string $sessionId): \Appwrite\Models\Session */ public function updateSession(string $sessionId): \Appwrite\Models\Session { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1891,6 +1896,10 @@ public function updateSession(string $sessionId): \Appwrite\Models\Session */ public function deleteSession(string $sessionId): string { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1903,6 +1912,7 @@ public function deleteSession(string $sessionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2068,6 +2078,10 @@ public function createMagicURLToken(string $userId, string $email, ?string $url * session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) * endpoint. * + * If there is already an active session, the OAuth2 identity is attached to + * the logged-in account and that session stays active until the token is + * exchanged for a new one. + * * A user is limited to 10 active sessions at a time by default. [Learn more * about session * limits](https://appwrite.io/docs/authentication-security#limits). diff --git a/src/Appwrite/Services/Activities.php b/src/Appwrite/Services/Activities.php index 4cb0ebb3..c5398cf0 100644 --- a/src/Appwrite/Services/Activities.php +++ b/src/Appwrite/Services/Activities.php @@ -54,6 +54,10 @@ public function listEvents(?array $queries = null): \Appwrite\Models\ActivityEve */ public function getEvent(string $eventId): \Appwrite\Models\ActivityEvent { + if ($eventId === '') { + throw new AppwriteException('Missing required parameter: "eventId"'); + } + $apiPath = str_replace( ['{eventId}'], [$eventId], diff --git a/src/Appwrite/Services/Advisor.php b/src/Appwrite/Services/Advisor.php index c09f9170..cc99a1ea 100644 --- a/src/Appwrite/Services/Advisor.php +++ b/src/Appwrite/Services/Advisor.php @@ -60,6 +60,10 @@ public function listReports(?array $queries = null, ?bool $total = null): \Appwr */ public function getReport(string $reportId): \Appwrite\Models\Report { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -95,6 +99,10 @@ public function getReport(string $reportId): \Appwrite\Models\Report */ public function deleteReport(string $reportId): string { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -107,6 +115,7 @@ public function deleteReport(string $reportId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -124,6 +133,10 @@ public function deleteReport(string $reportId): string */ public function listInsights(string $reportId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\InsightList { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -166,6 +179,14 @@ public function listInsights(string $reportId, ?array $queries = null, ?bool $to */ public function getInsight(string $reportId, string $insightId): \Appwrite\Models\Insight { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + + if ($insightId === '') { + throw new AppwriteException('Missing required parameter: "insightId"'); + } + $apiPath = str_replace( ['{reportId}', '{insightId}'], [$reportId, $insightId], diff --git a/src/Appwrite/Services/Apps.php b/src/Appwrite/Services/Apps.php index c66741f0..64162fa7 100644 --- a/src/Appwrite/Services/Apps.php +++ b/src/Appwrite/Services/Apps.php @@ -225,6 +225,10 @@ public function listOAuth2Scopes(): \Appwrite\Models\AppScopeList */ public function get(string $appId): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -259,6 +263,10 @@ public function get(string $appId): \Appwrite\Models\App */ public function update(string $appId, string $name, ?string $description = null, ?string $clientUri = null, ?string $logoUri = null, ?string $privacyPolicyUrl = null, ?string $termsUrl = null, ?array $contacts = null, ?string $tagline = null, ?array $tags = null, ?array $images = null, ?string $supportUrl = null, ?string $dataDeletionUrl = null, ?bool $enabled = null, ?array $redirectUris = null, ?array $postLogoutRedirectUris = null, ?string $type = null, ?bool $deviceFlow = null, ?array $installationScopes = null, ?string $installationRedirectUrl = null): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -367,6 +375,10 @@ public function update(string $appId, string $name, ?string $description = null, */ public function delete(string $appId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -398,6 +410,10 @@ public function delete(string $appId): string */ public function listInstallations(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppInstallationList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -442,6 +458,14 @@ public function listInstallations(string $appId, ?array $queries = null, ?bool $ */ public function getInstallation(string $appId, string $installationId): \Appwrite\Models\AppInstallation { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -479,6 +503,14 @@ public function getInstallation(string $appId, string $installationId): \Appwrit */ public function deleteInstallation(string $appId, string $installationId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -516,6 +548,14 @@ public function deleteInstallation(string $appId, string $installationId): strin */ public function createInstallationToken(string $appId, string $installationId): \Appwrite\Models\Oauth2Token { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -552,6 +592,10 @@ public function createInstallationToken(string $appId, string $installationId): */ public function listKeys(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppKeyList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -596,6 +640,10 @@ public function listKeys(string $appId, ?array $queries = null, ?bool $total = n */ public function createKey(string $appId): \Appwrite\Models\AppKey { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -631,6 +679,14 @@ public function createKey(string $appId): \Appwrite\Models\AppKey */ public function getKey(string $appId, string $keyId): \Appwrite\Models\AppKey { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{appId}', '{keyId}'], [$appId, $keyId], @@ -666,6 +722,14 @@ public function getKey(string $appId, string $keyId): \Appwrite\Models\AppKey */ public function deleteKey(string $appId, string $keyId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{appId}', '{keyId}'], [$appId, $keyId], @@ -698,6 +762,10 @@ public function deleteKey(string $appId, string $keyId): string */ public function updateLabels(string $appId, array $labels): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -734,6 +802,10 @@ public function updateLabels(string $appId, array $labels): \Appwrite\Models\App */ public function listSecrets(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppSecretList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -776,6 +848,10 @@ public function listSecrets(string $appId, ?array $queries = null, ?bool $total */ public function createSecret(string $appId): \Appwrite\Models\AppSecretPlaintext { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -811,6 +887,14 @@ public function createSecret(string $appId): \Appwrite\Models\AppSecretPlaintext */ public function getSecret(string $appId, string $secretId): \Appwrite\Models\AppSecret { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($secretId === '') { + throw new AppwriteException('Missing required parameter: "secretId"'); + } + $apiPath = str_replace( ['{appId}', '{secretId}'], [$appId, $secretId], @@ -846,6 +930,14 @@ public function getSecret(string $appId, string $secretId): \Appwrite\Models\App */ public function deleteSecret(string $appId, string $secretId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($secretId === '') { + throw new AppwriteException('Missing required parameter: "secretId"'); + } + $apiPath = str_replace( ['{appId}', '{secretId}'], [$appId, $secretId], @@ -876,6 +968,10 @@ public function deleteSecret(string $appId, string $secretId): string */ public function updateTeam(string $appId, string $teamId): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -912,6 +1008,10 @@ public function updateTeam(string $appId, string $teamId): \Appwrite\Models\App */ public function deleteTokens(string $appId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index ba8f5c11..eb5fa3a8 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -298,9 +298,9 @@ public function getInitials(?string $name = null, ?int $width = null, ?int $heig /** * Returns the best available profile photo for a user. The endpoint tries - * each source in priority order and returns the first successful result: - * OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in - * static fallback. + * each source in priority order and returns the first successful result: a + * custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, + * Gravatar, Libravatar, Appwrite Initials, built-in static fallback. * * Passing `userId` — `current()` for the authenticated user — resolves * the photo from everything known about that user: identity photos, email, diff --git a/src/Appwrite/Services/Backups.php b/src/Appwrite/Services/Backups.php index b67014b4..9b22277b 100644 --- a/src/Appwrite/Services/Backups.php +++ b/src/Appwrite/Services/Backups.php @@ -90,6 +90,10 @@ public function createArchive(array $services, ?string $resourceId = null): \App */ public function getArchive(string $archiveId): \Appwrite\Models\BackupArchive { + if ($archiveId === '') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + $apiPath = str_replace( ['{archiveId}'], [$archiveId], @@ -124,6 +128,10 @@ public function getArchive(string $archiveId): \Appwrite\Models\BackupArchive */ public function deleteArchive(string $archiveId): string { + if ($archiveId === '') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + $apiPath = str_replace( ['{archiveId}'], [$archiveId], @@ -237,6 +245,10 @@ public function createPolicy(string $policyId, array $services, int $retention, */ public function getPolicy(string $policyId): \Appwrite\Models\BackupPolicy { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -271,6 +283,10 @@ public function getPolicy(string $policyId): \Appwrite\Models\BackupPolicy */ public function updatePolicy(string $policyId, ?string $name = null, ?int $retention = null, ?string $schedule = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -313,6 +329,10 @@ public function updatePolicy(string $policyId, ?string $name = null, ?int $reten */ public function deletePolicy(string $policyId): string { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -453,6 +473,10 @@ public function listRestorations(?array $queries = null): \Appwrite\Models\Backu */ public function getRestoration(string $restorationId): \Appwrite\Models\BackupRestoration { + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{restorationId}'], [$restorationId], diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 6dd497fe..60caec64 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -200,6 +200,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -237,6 +241,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -283,6 +291,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -295,6 +307,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -314,6 +327,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -357,6 +374,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -394,6 +415,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, ?string $name = null, ?bool $enabled = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -441,6 +466,10 @@ public function update(string $databaseId, ?string $name = null, ?bool $enabled */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -453,6 +482,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -473,6 +503,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\CollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -525,6 +559,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?array $attributes = null, ?array $indexes = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -583,6 +621,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -621,6 +667,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, ?string $name = null, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -678,6 +732,14 @@ public function updateCollection(string $databaseId, string $collectionId, ?stri */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -691,6 +753,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -710,6 +773,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listAttributes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AttributeList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -757,6 +828,14 @@ public function listAttributes(string $databaseId, string $collectionId, ?array */ public function createBigIntAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -806,6 +885,18 @@ public function createBigIntAttribute(string $databaseId, string $collectionId, */ public function updateBigIntAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\AttributeBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -851,6 +942,14 @@ public function updateBigIntAttribute(string $databaseId, string $collectionId, */ public function createBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -898,6 +997,18 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, */ public function updateBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -941,6 +1052,14 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, */ public function createDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -988,6 +1107,18 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId */ public function updateDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1031,6 +1162,14 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId */ public function createEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1078,6 +1217,18 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s */ public function updateEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1122,6 +1273,14 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s */ public function createEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1170,6 +1329,18 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st */ public function updateEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1215,6 +1386,14 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st */ public function createFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1264,6 +1443,18 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s */ public function updateFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): \Appwrite\Models\AttributeFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1310,6 +1501,14 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s */ public function createIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1359,6 +1558,18 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, */ public function updateIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\AttributeInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1404,6 +1615,14 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, */ public function createIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1451,6 +1670,18 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri */ public function updateIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1494,6 +1725,14 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri */ public function createLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributeLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1537,6 +1776,18 @@ public function createLineAttribute(string $databaseId, string $collectionId, st */ public function updateLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributeLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1580,6 +1831,14 @@ public function updateLineAttribute(string $databaseId, string $collectionId, st */ public function createLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1631,6 +1890,18 @@ public function createLongtextAttribute(string $databaseId, string $collectionId */ public function updateLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1674,6 +1945,14 @@ public function updateLongtextAttribute(string $databaseId, string $collectionId */ public function createMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1725,6 +2004,18 @@ public function createMediumtextAttribute(string $databaseId, string $collection */ public function updateMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1768,6 +2059,14 @@ public function updateMediumtextAttribute(string $databaseId, string $collection */ public function createPointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributePoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1811,6 +2110,18 @@ public function createPointAttribute(string $databaseId, string $collectionId, s */ public function updatePointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributePoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1854,6 +2165,14 @@ public function updatePointAttribute(string $databaseId, string $collectionId, s */ public function createPolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributePolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1897,6 +2216,18 @@ public function createPolygonAttribute(string $databaseId, string $collectionId, */ public function updatePolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributePolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1941,6 +2272,14 @@ public function updatePolygonAttribute(string $databaseId, string $collectionId, */ public function createRelationshipAttribute(string $databaseId, string $collectionId, string $relatedCollectionId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): \Appwrite\Models\AttributeRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1993,6 +2332,18 @@ public function createRelationshipAttribute(string $databaseId, string $collecti */ public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\AttributeRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2038,6 +2389,14 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti */ public function createStringAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2090,6 +2449,18 @@ public function createStringAttribute(string $databaseId, string $collectionId, */ public function updateStringAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2134,6 +2505,14 @@ public function updateStringAttribute(string $databaseId, string $collectionId, */ public function createTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2185,6 +2564,18 @@ public function createTextAttribute(string $databaseId, string $collectionId, st */ public function updateTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2228,6 +2619,14 @@ public function updateTextAttribute(string $databaseId, string $collectionId, st */ public function createUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2275,6 +2674,18 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str */ public function updateUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2318,6 +2729,14 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str */ 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 { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2370,6 +2789,18 @@ public function createVarcharAttribute(string $databaseId, string $collectionId, */ public function updateVarcharAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\AttributeVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2412,8 +2843,20 @@ public function updateVarcharAttribute(string $databaseId, string $collectionId, * @deprecated This API has been deprecated since 1.8.0. Please use `getColumn` instead. * @see TablesDB::getColumn */ - public function getAttribute(string $databaseId, string $collectionId, string $key): \Appwrite\Models\AttributeBoolean|\Appwrite\Models\AttributeInteger|\Appwrite\Models\AttributeFloat|\Appwrite\Models\AttributeEmail|\Appwrite\Models\AttributeEnum|\Appwrite\Models\AttributeUrl|\Appwrite\Models\AttributeIp|\Appwrite\Models\AttributeDatetime|\Appwrite\Models\AttributeRelationship|\Appwrite\Models\AttributeString + public function getAttribute(string $databaseId, string $collectionId, string $key): \Appwrite\Models\AttributeBoolean|\Appwrite\Models\AttributeBigint|\Appwrite\Models\AttributeInteger|\Appwrite\Models\AttributeFloat|\Appwrite\Models\AttributeEmail|\Appwrite\Models\AttributeEnum|\Appwrite\Models\AttributeUrl|\Appwrite\Models\AttributeIp|\Appwrite\Models\AttributeDatetime|\Appwrite\Models\AttributeRelationship|\Appwrite\Models\AttributePoint|\Appwrite\Models\AttributeLine|\Appwrite\Models\AttributePolygon|\Appwrite\Models\AttributeVarchar|\Appwrite\Models\AttributeText|\Appwrite\Models\AttributeMediumtext|\Appwrite\Models\AttributeLongtext|\Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2460,6 +2903,10 @@ public function getAttribute(string $databaseId, string $collectionId, string $k return \Appwrite\Models\AttributeBoolean::from($response); } + if (($response['type'] ?? null) === 'bigint') { + return \Appwrite\Models\AttributeBigint::from($response); + } + if (($response['type'] ?? null) === 'integer') { return \Appwrite\Models\AttributeInteger::from($response); } @@ -2476,6 +2923,34 @@ public function getAttribute(string $databaseId, string $collectionId, string $k return \Appwrite\Models\AttributeRelationship::from($response); } + if (($response['type'] ?? null) === 'point') { + return \Appwrite\Models\AttributePoint::from($response); + } + + if (($response['type'] ?? null) === 'linestring') { + return \Appwrite\Models\AttributeLine::from($response); + } + + if (($response['type'] ?? null) === 'polygon') { + return \Appwrite\Models\AttributePolygon::from($response); + } + + if (($response['type'] ?? null) === 'varchar') { + return \Appwrite\Models\AttributeVarchar::from($response); + } + + if (($response['type'] ?? null) === 'text') { + return \Appwrite\Models\AttributeText::from($response); + } + + if (($response['type'] ?? null) === 'mediumtext') { + return \Appwrite\Models\AttributeMediumtext::from($response); + } + + if (($response['type'] ?? null) === 'longtext') { + return \Appwrite\Models\AttributeLongtext::from($response); + } + if (($response['type'] ?? null) === 'string') { return \Appwrite\Models\AttributeString::from($response); } @@ -2493,6 +2968,18 @@ public function getAttribute(string $databaseId, string $collectionId, string $k */ public function deleteAttribute(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2507,6 +2994,7 @@ public function deleteAttribute(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2527,6 +3015,14 @@ public function deleteAttribute(string $databaseId, string $collectionId, string */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2584,6 +3080,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2630,6 +3134,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2674,6 +3186,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2717,6 +3237,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2766,6 +3294,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2814,6 +3350,18 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2864,6 +3412,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2911,6 +3471,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2957,6 +3529,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2975,6 +3559,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2994,6 +3579,22 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -3041,6 +3642,22 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -3088,6 +3705,14 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -3127,7 +3752,9 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu /** * Creates an index on the attributes listed. Your index should include all * the attributes you will query in a single request. - * Attributes can be `key`, `fulltext`, and `unique`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + * `trigram` is only available on PostgreSQL and lets `contains`, + * `startsWith`, and `endsWith` queries on string attributes use an index. * * @throws AppwriteException * @@ -3136,6 +3763,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, DatabasesIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -3186,6 +3821,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -3225,6 +3872,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -3239,6 +3898,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/DocumentsDB.php b/src/Appwrite/Services/DocumentsDB.php index 4e0e734f..efaef6eb 100644 --- a/src/Appwrite/Services/DocumentsDB.php +++ b/src/Appwrite/Services/DocumentsDB.php @@ -104,8 +104,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -223,6 +223,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -257,6 +261,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -300,6 +308,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -312,6 +324,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -328,6 +341,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -368,6 +385,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -402,6 +423,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, string $name, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -446,6 +471,10 @@ public function update(string $databaseId, string $name, ?bool $enabled = null, */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -458,6 +487,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -475,6 +505,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\CollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -524,6 +558,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?array $attributes = null, ?array $indexes = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -579,6 +617,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -614,6 +660,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -668,6 +722,14 @@ public function updateCollection(string $databaseId, string $collectionId, strin */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -681,6 +743,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -698,6 +761,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -752,6 +823,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -801,6 +880,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -845,6 +932,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -888,6 +983,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -937,6 +1040,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -982,6 +1093,18 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1029,6 +1152,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1079,6 +1214,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1128,6 +1275,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1146,6 +1305,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1162,6 +1322,22 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -1212,6 +1388,22 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -1262,6 +1454,14 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1307,6 +1507,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, DocumentsDBIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1354,6 +1562,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1390,6 +1610,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1404,6 +1636,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1428,6 +1661,10 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1467,6 +1704,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1514,6 +1755,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1550,6 +1795,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index d1bb5dda..cf414016 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -268,6 +268,10 @@ public function listSpecifications(?string $type = null, ?bool $total = null): \ */ public function get(string $functionId): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -302,6 +306,10 @@ public function get(string $functionId): \Appwrite\Models\FunctionModel */ public function update(string $functionId, string $name, ?Runtime $runtime = null, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?int $interval = null): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -404,6 +412,10 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul */ public function delete(string $functionId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -416,6 +428,7 @@ public function delete(string $functionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -433,6 +446,10 @@ public function delete(string $functionId): string */ public function updateFunctionDeployment(string $functionId, string $deploymentId): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -470,6 +487,10 @@ public function updateFunctionDeployment(string $functionId, string $deploymentI */ public function listDeployments(string $functionId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\DeploymentList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -525,6 +546,10 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str */ public function createDeployment(string $functionId, InputFile $code, bool $activate, ?string $entrypoint = null, ?string $commands = null, ?callable $onProgress = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -548,9 +573,6 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($code->getPath() ?? null)) { $size = strlen($code->getData()); $mimeType = $code->getMimeType(); @@ -704,6 +726,10 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti */ public function createDuplicateDeployment(string $functionId, string $deploymentId, ?string $buildId = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -748,6 +774,10 @@ public function createDuplicateDeployment(string $functionId, string $deployment */ public function createTemplateDeployment(string $functionId, string $repository, string $owner, string $rootDirectory, TemplateReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -794,6 +824,10 @@ public function createTemplateDeployment(string $functionId, string $repository, */ public function createVcsDeployment(string $functionId, VCSReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -835,6 +869,14 @@ public function createVcsDeployment(string $functionId, VCSReferenceType $type, */ public function getDeployment(string $functionId, string $deploymentId): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -870,6 +912,14 @@ public function getDeployment(string $functionId, string $deploymentId): \Appwri */ public function deleteDeployment(string $functionId, string $deploymentId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -883,6 +933,7 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -901,6 +952,14 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri */ public function getDeploymentDownload(string $functionId, string $deploymentId, ?DeploymentDownloadType $type = null, ?string $token = null): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -942,6 +1001,14 @@ public function getDeploymentDownload(string $functionId, string $deploymentId, */ public function updateDeploymentStatus(string $functionId, string $deploymentId): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -979,6 +1046,10 @@ public function updateDeploymentStatus(string $functionId, string $deploymentId) */ public function listExecutions(string $functionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ExecutionList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1024,6 +1095,10 @@ public function listExecutions(string $functionId, ?array $queries = null, ?bool */ public function createExecution(string $functionId, ?string $body = null, ?bool $async = null, ?string $xpath = null, ?ExecutionMethod $method = null, ?array $headers = null, ?string $scheduledAt = null): \Appwrite\Models\Execution { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1080,6 +1155,14 @@ public function createExecution(string $functionId, ?string $body = null, ?bool */ public function getExecution(string $functionId, string $executionId): \Appwrite\Models\Execution { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($executionId === '') { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + $apiPath = str_replace( ['{functionId}', '{executionId}'], [$functionId, $executionId], @@ -1115,6 +1198,14 @@ public function getExecution(string $functionId, string $executionId): \Appwrite */ public function deleteExecution(string $functionId, string $executionId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($executionId === '') { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + $apiPath = str_replace( ['{functionId}', '{executionId}'], [$functionId, $executionId], @@ -1128,6 +1219,7 @@ public function deleteExecution(string $functionId, string $executionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1144,6 +1236,10 @@ public function deleteExecution(string $functionId, string $executionId): string */ public function listVariables(string $functionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\VariableList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1187,6 +1283,10 @@ public function listVariables(string $functionId, ?array $queries = null, ?bool */ public function createVariable(string $functionId, string $variableId, string $key, string $value, ?bool $secret = null): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1229,6 +1329,14 @@ public function createVariable(string $functionId, string $variableId, string $k */ public function getVariable(string $functionId, string $variableId): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1264,6 +1372,14 @@ public function getVariable(string $functionId, string $variableId): \Appwrite\M */ public function updateVariable(string $functionId, string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1303,6 +1419,14 @@ public function updateVariable(string $functionId, string $variableId, ?string $ */ public function deleteVariable(string $functionId, string $variableId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1316,6 +1440,7 @@ public function deleteVariable(string $functionId, string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Messaging.php b/src/Appwrite/Services/Messaging.php index 053d0e67..af0072de 100644 --- a/src/Appwrite/Services/Messaging.php +++ b/src/Appwrite/Services/Messaging.php @@ -94,10 +94,7 @@ public function createEmail(string $messageId, string $subject, string $content, if (!is_null($bcc)) { $apiParams['bcc'] = $bcc; } - - if (!is_null($attachments)) { - $apiParams['attachments'] = $attachments; - } + $apiParams['attachments'] = $attachments; if (!is_null($draft)) { $apiParams['draft'] = $draft; @@ -144,6 +141,10 @@ public function createEmail(string $messageId, string $subject, string $content, */ public function updateEmail(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $subject = null, ?string $content = null, ?bool $draft = null, ?bool $html = null, ?array $cc = null, ?array $bcc = null, ?string $scheduledAt = null, ?array $attachments = null, ?string $replyToEmail = null, ?string $replyToName = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -299,6 +300,10 @@ public function createPush(string $messageId, ?string $title = null, ?string $bo */ public function updatePush(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $title = null, ?string $body = null, ?array $data = null, ?string $action = null, ?string $image = null, ?string $icon = null, ?string $sound = null, ?string $color = null, ?string $tag = null, ?int $badge = null, ?bool $draft = null, ?string $scheduledAt = null, ?bool $contentAvailable = null, ?bool $critical = null, ?MessagePriority $priority = null, ?string $channelId = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -408,6 +413,10 @@ public function createSMS(string $messageId, string $content, ?array $topics = n */ public function updateSMS(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $content = null, ?bool $draft = null, ?string $scheduledAt = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -449,6 +458,10 @@ public function updateSMS(string $messageId, ?array $topics = null, ?array $user */ public function getMessage(string $messageId): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -484,6 +497,10 @@ public function getMessage(string $messageId): \Appwrite\Models\Message */ public function delete(string $messageId): string { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -496,6 +513,7 @@ public function delete(string $messageId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -512,6 +530,10 @@ public function delete(string $messageId): string */ public function listTargets(string $messageId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\TargetList { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -656,6 +678,10 @@ public function createAPNSProvider(string $providerId, string $name, ?string $au */ public function updateAPNSProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $authKey = null, ?string $authKeyId = null, ?string $teamId = null, ?string $bundleId = null, ?bool $sandbox = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -836,6 +862,10 @@ public function createFCMProvider(string $providerId, string $name, ?array $serv */ public function updateFCMProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?array $serviceAccountJSON = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -939,6 +969,10 @@ public function createMailgunProvider(string $providerId, string $name, ?string */ public function updateMailgunProvider(string $providerId, ?string $name = null, ?string $apiKey = null, ?string $domain = null, ?bool $isEuRegion = null, ?bool $enabled = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1053,6 +1087,10 @@ public function createMsg91Provider(string $providerId, string $name, ?string $t */ public function updateMsg91Provider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $templateId = null, ?string $senderId = null, ?string $authKey = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1162,6 +1200,10 @@ public function createResendProvider(string $providerId, string $name, ?string $ */ public function updateResendProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1279,6 +1321,10 @@ public function createSendgridProvider(string $providerId, string $name, ?string */ public function updateSendgridProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1404,6 +1450,10 @@ public function createSesProvider(string $providerId, string $name, ?string $acc */ public function updateSesProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $accessKey = null, ?string $secretKey = null, ?string $region = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1550,6 +1600,10 @@ public function createSMTPProvider(string $providerId, string $name, string $hos */ public function updateSMTPProvider(string $providerId, ?string $name = null, ?string $host = null, ?int $port = null, ?string $username = null, ?string $password = null, ?SmtpEncryption $encryption = null, ?bool $autoTLS = null, ?string $mailer = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null, ?bool $enabled = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1677,6 +1731,10 @@ public function createTelesignProvider(string $providerId, string $name, ?string */ public function updateTelesignProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $customerId = null, ?string $apiKey = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1778,6 +1836,10 @@ public function createTextmagicProvider(string $providerId, string $name, ?strin */ public function updateTextmagicProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $username = null, ?string $apiKey = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1879,6 +1941,10 @@ public function createTwilioProvider(string $providerId, string $name, ?string $ */ public function updateTwilioProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $accountSid = null, ?string $authToken = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1980,6 +2046,10 @@ public function createVonageProvider(string $providerId, string $name, ?string $ */ public function updateVonageProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $apiSecret = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2032,6 +2102,10 @@ public function updateVonageProvider(string $providerId, ?string $name = null, ? */ public function getProvider(string $providerId): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2066,6 +2140,10 @@ public function getProvider(string $providerId): \Appwrite\Models\Provider */ public function deleteProvider(string $providerId): string { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2078,6 +2156,7 @@ public function deleteProvider(string $providerId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2181,6 +2260,10 @@ public function createTopic(string $topicId, string $name, ?array $subscribe = n */ public function getTopic(string $topicId): \Appwrite\Models\Topic { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2215,6 +2298,10 @@ public function getTopic(string $topicId): \Appwrite\Models\Topic */ public function updateTopic(string $topicId, ?string $name = null, ?array $subscribe = null, ?int $qos = null, ?int $expiry = null): \Appwrite\Models\Topic { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2254,6 +2341,10 @@ public function updateTopic(string $topicId, ?string $name = null, ?array $subsc */ public function deleteTopic(string $topicId): string { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2266,6 +2357,7 @@ public function deleteTopic(string $topicId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2282,6 +2374,10 @@ public function deleteTopic(string $topicId): string */ public function listSubscribers(string $topicId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\SubscriberList { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2328,6 +2424,10 @@ public function listSubscribers(string $topicId, ?array $queries = null, ?string */ public function createSubscriber(string $topicId, string $subscriberId, string $targetId): \Appwrite\Models\Subscriber { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2365,6 +2465,14 @@ public function createSubscriber(string $topicId, string $subscriberId, string $ */ public function getSubscriber(string $topicId, string $subscriberId): \Appwrite\Models\Subscriber { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + if ($subscriberId === '') { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + $apiPath = str_replace( ['{topicId}', '{subscriberId}'], [$topicId, $subscriberId], @@ -2400,6 +2508,14 @@ public function getSubscriber(string $topicId, string $subscriberId): \Appwrite\ */ public function deleteSubscriber(string $topicId, string $subscriberId): string { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + if ($subscriberId === '') { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + $apiPath = str_replace( ['{topicId}', '{subscriberId}'], [$topicId, $subscriberId], @@ -2413,6 +2529,7 @@ public function deleteSubscriber(string $topicId, string $subscriberId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Mongo.php b/src/Appwrite/Services/Mongo.php index 21771ece..4c74acc4 100644 --- a/src/Appwrite/Services/Mongo.php +++ b/src/Appwrite/Services/Mongo.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -849,6 +938,10 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -887,6 +980,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -927,6 +1024,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -967,6 +1068,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1014,6 +1119,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1049,6 +1158,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1084,6 +1197,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1137,6 +1254,10 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st */ public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1180,6 +1301,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1217,6 +1346,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1252,6 +1385,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Mysql.php b/src/Appwrite/Services/Mysql.php index 95f4cd35..d0787222 100644 --- a/src/Appwrite/Services/Mysql.php +++ b/src/Appwrite/Services/Mysql.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -849,6 +938,10 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate */ public function createExecution(string $databaseId, string $sql, ?array $bindings = null, ?int $timeoutSeconds = null): \Appwrite\Models\DedicatedDatabaseExecution { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -895,6 +988,10 @@ public function createExecution(string $databaseId, string $sql, ?array $binding */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -933,6 +1030,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -973,6 +1074,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1013,6 +1118,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1060,6 +1169,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1095,6 +1208,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1130,6 +1247,10 @@ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabas */ public function updatePooler(string $databaseId, ?string $mode = null, ?int $maxConnections = null, ?int $defaultPoolSize = null, ?bool $readWriteSplitting = null, ?string $poolerCpuRequest = null, ?string $poolerCpuLimit = null, ?string $poolerMemoryRequest = null, ?string $poolerMemoryLimit = null): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1174,6 +1295,10 @@ public function updatePooler(string $databaseId, ?string $mode = null, ?int $max */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1209,6 +1334,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1262,6 +1391,10 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st */ public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1305,6 +1438,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1342,6 +1483,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1377,6 +1522,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Oauth2.php b/src/Appwrite/Services/Oauth2.php index 45d4927a..e246e345 100644 --- a/src/Appwrite/Services/Oauth2.php +++ b/src/Appwrite/Services/Oauth2.php @@ -65,7 +65,7 @@ public function approve(string $grantId, ?string $authorizationDetails = null, ? * * @throws AppwriteException */ - public function authorize(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize + public function authorize(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize { $apiPath = str_replace( ['{project_id}'], @@ -157,7 +157,7 @@ public function authorize(?string $clientId = null, ?string $redirectUri = null, * * @throws AppwriteException */ - public function authorizePost(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize + public function authorizePost(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize { $apiPath = str_replace( ['{project_id}'], @@ -244,7 +244,7 @@ public function authorizePost(?string $clientId = null, ?string $redirectUri = n * * @throws AppwriteException */ - public function createDeviceAuthorization(?string $clientId = null, ?string $scope = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2DeviceAuthorization + public function createDeviceAuthorization(?string $clientId = null, ?string $scope = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2DeviceAuthorization { $apiPath = str_replace( ['{project_id}'], @@ -338,6 +338,10 @@ public function createGrant(string $userCode): \Appwrite\Models\Oauth2Grant */ public function getGrant(string $grantId): \Appwrite\Models\Oauth2Grant { + if ($grantId === '') { + throw new AppwriteException('Missing required parameter: "grantId"'); + } + $apiPath = str_replace( ['{project_id}', '{grant_id}'], [$this->client->getConfig('project'), $grantId], @@ -465,7 +469,7 @@ public function listOrganizations(?int $limit = null, ?int $offset = null, ?stri * * @throws AppwriteException */ - public function createPAR(string $clientId, string $redirectUri, string $responseType, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2PAR + public function createPAR(string $clientId, string $redirectUri, string $responseType, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2PAR { $apiPath = str_replace( ['{project_id}'], @@ -662,7 +666,7 @@ public function revoke(string $token, ?string $tokenTypeHint = null, ?string $cl * * @throws AppwriteException */ - public function createToken(string $grantType, ?string $code = null, ?string $refreshToken = null, ?string $deviceCode = null, ?string $clientId = null, ?string $clientSecret = null, ?string $codeVerifier = null, ?string $redirectUri = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2Token + public function createToken(string $grantType, ?string $code = null, ?string $refreshToken = null, ?string $deviceCode = null, ?string $clientId = null, ?string $clientSecret = null, ?string $codeVerifier = null, ?string $redirectUri = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2Token { $apiPath = str_replace( ['{project_id}'], diff --git a/src/Appwrite/Services/Organization.php b/src/Appwrite/Services/Organization.php index 3b572126..d8be8f07 100644 --- a/src/Appwrite/Services/Organization.php +++ b/src/Appwrite/Services/Organization.php @@ -98,6 +98,7 @@ public function delete(): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -198,6 +199,10 @@ public function createInstallation(string $appId, ?string $authorizationDetails */ public function getInstallation(string $installationId): \Appwrite\Models\AppInstallation { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -235,6 +240,10 @@ public function getInstallation(string $installationId): \Appwrite\Models\AppIns */ public function updateInstallation(string $installationId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -273,6 +282,10 @@ public function updateInstallation(string $installationId, ?string $authorizatio */ public function deleteInstallation(string $installationId): string { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -295,188 +308,6 @@ public function deleteInstallation(string $installationId): string ); } - /** - * Get a list of all API keys from the current organization. - * - * @throws AppwriteException - */ - public function listKeys(?array $queries = null, ?bool $total = null): \Appwrite\Models\KeyList - { - $apiPath = str_replace( - [], - [], - '/organization/keys' - ); - - $apiParams = []; - - 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\KeyList::from($response); - } - - /** - * Create a new organization API key. - * - * @throws AppwriteException - */ - public function createKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key - { - $apiPath = str_replace( - [], - [], - '/organization/keys' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - $apiParams['name'] = $name; - $apiParams['scopes'] = $scopes; - $apiParams['expire'] = $expire; - - $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\Key::from($response); - } - - /** - * Get a key by its unique ID. This endpoint returns details about a specific - * API key in your organization including its scopes. - * - * @throws AppwriteException - */ - public function getKey(string $keyId): \Appwrite\Models\Key - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - - $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\Key::from($response); - } - - /** - * Update a key by its unique ID. Use this endpoint to update the name, - * scopes, or expiration time of an API key. - * - * @throws AppwriteException - */ - public function updateKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - $apiParams['name'] = $name; - $apiParams['scopes'] = $scopes; - $apiParams['expire'] = $expire; - - $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\Key::from($response); - } - - /** - * Delete a key by its unique ID. Once deleted, the key can no longer be used - * to authenticate API calls. - * - * @throws AppwriteException - */ - public function deleteKey(string $keyId): string - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - /** * Get a list of all memberships from the current organization. * @@ -586,6 +417,10 @@ public function createMembership(array $roles, ?string $email = null, ?string $u */ public function getMembership(string $membershipId): \Appwrite\Models\Membership { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -620,6 +455,10 @@ public function getMembership(string $membershipId): \Appwrite\Models\Membership */ public function updateMembership(string $membershipId, array $roles): \Appwrite\Models\Membership { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -658,6 +497,10 @@ public function updateMembership(string $membershipId, array $roles): \Appwrite\ */ public function deleteMembership(string $membershipId): string { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -670,6 +513,7 @@ public function deleteMembership(string $membershipId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -772,6 +616,10 @@ public function createProject(string $projectId, string $name, ?Region $region = */ public function getProject(string $projectId): \Appwrite\Models\Project { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -783,6 +631,7 @@ public function getProject(string $projectId): \Appwrite\Models\Project $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; $response = $this->client->call( Client::METHOD_GET, @@ -805,6 +654,10 @@ public function getProject(string $projectId): \Appwrite\Models\Project */ public function updateProject(string $projectId, string $name): \Appwrite\Models\Project { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -841,6 +694,10 @@ public function updateProject(string $projectId, string $name): \Appwrite\Models */ public function deleteProject(string $projectId): string { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -853,6 +710,7 @@ public function deleteProject(string $projectId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Postgresql.php b/src/Appwrite/Services/Postgresql.php index 536e5730..701d5238 100644 --- a/src/Appwrite/Services/Postgresql.php +++ b/src/Appwrite/Services/Postgresql.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -849,6 +938,10 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate */ public function createExecution(string $databaseId, string $sql, ?array $bindings = null, ?int $timeoutSeconds = null): \Appwrite\Models\DedicatedDatabaseExecution { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -887,6 +980,10 @@ public function createExecution(string $databaseId, string $sql, ?array $binding */ public function listExtensions(string $databaseId): \Appwrite\Models\DedicatedDatabaseExtensions { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -922,6 +1019,10 @@ public function listExtensions(string $databaseId): \Appwrite\Models\DedicatedDa */ public function createExtension(string $databaseId, string $name): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -959,6 +1060,14 @@ public function createExtension(string $databaseId, string $name): \Appwrite\Mod */ public function deleteExtension(string $databaseId, string $extensionName): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($extensionName === '') { + throw new AppwriteException('Missing required parameter: "extensionName"'); + } + $apiPath = str_replace( ['{databaseId}', '{extensionName}'], [$databaseId, $extensionName], @@ -1003,6 +1112,10 @@ public function deleteExtension(string $databaseId, string $extensionName): \App */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1041,6 +1154,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1081,6 +1198,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1121,6 +1242,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1168,6 +1293,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1203,6 +1332,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1238,6 +1371,10 @@ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabas */ public function updatePooler(string $databaseId, ?string $mode = null, ?int $maxConnections = null, ?int $defaultPoolSize = null, ?bool $readWriteSplitting = null, ?string $poolerCpuRequest = null, ?string $poolerCpuLimit = null, ?string $poolerMemoryRequest = null, ?string $poolerMemoryLimit = null): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1282,6 +1419,10 @@ public function updatePooler(string $databaseId, ?string $mode = null, ?int $max */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1317,6 +1458,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1370,6 +1515,10 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st */ public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1413,6 +1562,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1450,6 +1607,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1485,6 +1646,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Presences.php b/src/Appwrite/Services/Presences.php index 80f429c9..5a04fc40 100644 --- a/src/Appwrite/Services/Presences.php +++ b/src/Appwrite/Services/Presences.php @@ -63,6 +63,10 @@ public function list(?array $queries = null, ?bool $total = null, ?int $ttl = nu */ public function get(string $presenceId): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -97,6 +101,10 @@ public function get(string $presenceId): \Appwrite\Models\Presence */ public function upsert(string $presenceId, string $userId, string $status, ?array $permissions = null, ?string $expiresAt = null, ?array $metadata = null): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -147,6 +155,10 @@ public function upsert(string $presenceId, string $userId, string $status, ?arra */ public function update(string $presenceId, string $userId, ?string $status = null, ?string $expiresAt = null, ?array $metadata = null, ?array $permissions = null, ?bool $purge = null): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -203,6 +215,10 @@ public function update(string $presenceId, string $userId, ?string $status = nul */ public function delete(string $presenceId): string { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -215,6 +231,7 @@ public function delete(string $presenceId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Project.php b/src/Appwrite/Services/Project.php index 05577731..223a6273 100644 --- a/src/Appwrite/Services/Project.php +++ b/src/Appwrite/Services/Project.php @@ -35,6 +35,7 @@ public function get(): \Appwrite\Models\Project $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; $response = $this->client->call( Client::METHOD_GET, @@ -68,6 +69,7 @@ public function delete(): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -393,6 +395,10 @@ public function createEphemeralKey(array $scopes, int $duration): \Appwrite\Mode */ public function getKey(string $keyId): \Appwrite\Models\Key { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -428,6 +434,10 @@ public function getKey(string $keyId): \Appwrite\Models\Key */ public function updateKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -467,6 +477,10 @@ public function updateKey(string $keyId, string $name, array $scopes, ?string $e */ public function deleteKey(string $keyId): string { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -479,6 +493,7 @@ public function deleteKey(string $keyId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -611,6 +626,10 @@ public function createMockPhone(string $number, string $otp): \Appwrite\Models\M */ public function getMockPhone(string $number): \Appwrite\Models\MockNumber { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -646,6 +665,10 @@ public function getMockPhone(string $number): \Appwrite\Models\MockNumber */ public function updateMockPhone(string $number, string $otp): \Appwrite\Models\MockNumber { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -683,6 +706,10 @@ public function updateMockPhone(string $number, string $otp): \Appwrite\Models\M */ public function deleteMockPhone(string $number): string { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -695,6 +722,7 @@ public function deleteMockPhone(string $number): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1648,7 +1676,7 @@ public function updateOAuth2HuggingFace(?string $clientId = null, ?string $clien * * @throws AppwriteException */ - public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecret = null, ?array $prompt = null, ?bool $enabled = null): \Appwrite\Models\OAuth2Kakao + public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecret = null, ?bool $enabled = null, ?array $prompt = null): \Appwrite\Models\OAuth2Kakao { $apiPath = str_replace( [], @@ -1659,8 +1687,8 @@ public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecre $apiParams = []; $apiParams['clientId'] = $clientId; $apiParams['clientSecret'] = $clientSecret; - $apiParams['prompt'] = $prompt; $apiParams['enabled'] = $enabled; + $apiParams['prompt'] = $prompt; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -2964,12 +2992,16 @@ public function createAndroidPlatform(string $platformId, string $name, string $ /** * Update an Android platform by its unique ID. Use this endpoint to update - * the platform's name or application ID. + * the platform's name, application ID or signing certificate fingerprints. * * @throws AppwriteException */ public function updateAndroidPlatform(string $platformId, string $name, string $applicationId, ?array $fingerprints = null): \Appwrite\Models\PlatformAndroid { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3048,6 +3080,10 @@ public function createApplePlatform(string $platformId, string $name, string $bu */ public function updateApplePlatform(string $platformId, string $name, string $bundleIdentifier): \Appwrite\Models\PlatformApple { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3125,6 +3161,10 @@ public function createLinuxPlatform(string $platformId, string $name, string $pa */ public function updateLinuxPlatform(string $platformId, string $name, string $packageName): \Appwrite\Models\PlatformLinux { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3202,6 +3242,10 @@ public function createWebPlatform(string $platformId, string $name, string $host */ public function updateWebPlatform(string $platformId, string $name, string $hostname): \Appwrite\Models\PlatformWeb { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3279,6 +3323,10 @@ public function createWindowsPlatform(string $platformId, string $name, string $ */ public function updateWindowsPlatform(string $platformId, string $name, string $packageIdentifierName): \Appwrite\Models\PlatformWindows { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3317,6 +3365,10 @@ public function updateWindowsPlatform(string $platformId, string $name, string $ */ public function getPlatform(string $platformId): \Appwrite\Models\PlatformWeb|\Appwrite\Models\PlatformApple|\Appwrite\Models\PlatformAndroid|\Appwrite\Models\PlatformWindows|\Appwrite\Models\PlatformLinux { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3372,6 +3424,10 @@ public function getPlatform(string $platformId): \Appwrite\Models\PlatformWeb|\A */ public function deletePlatform(string $platformId): string { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3384,6 +3440,7 @@ public function deletePlatform(string $platformId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -4432,6 +4489,7 @@ public function createSMTPTest(array $emails): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_POST, @@ -4660,6 +4718,10 @@ public function createVariable(string $variableId, string $key, string $value, ? */ public function getVariable(string $variableId): \Appwrite\Models\Variable { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4694,6 +4756,10 @@ public function getVariable(string $variableId): \Appwrite\Models\Variable */ public function updateVariable(string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4732,6 +4798,10 @@ public function updateVariable(string $variableId, ?string $key = null, ?string */ public function deleteVariable(string $variableId): string { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4744,6 +4814,7 @@ public function deleteVariable(string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Proxy.php b/src/Appwrite/Services/Proxy.php index 4b04c9e1..6fbe84b2 100644 --- a/src/Appwrite/Services/Proxy.php +++ b/src/Appwrite/Services/Proxy.php @@ -20,6 +20,8 @@ class Proxy extends Service * Depending on type, the invalidation purges a single cache tag, a single URL * path, or all cached content for the domain. * + * Domains that route to a function do not support cache invalidation. + * * @throws AppwriteException */ public function createInvalidation(string $domain, InvalidationType $type, ?string $reference = null): \Appwrite\Models\ProxyInvalidation @@ -273,6 +275,10 @@ public function createSiteRule(string $domain, string $siteId, ?string $branch = */ public function getRule(string $ruleId): \Appwrite\Models\ProxyRule { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], @@ -307,6 +313,10 @@ public function getRule(string $ruleId): \Appwrite\Models\ProxyRule */ public function deleteRule(string $ruleId): string { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], @@ -319,6 +329,7 @@ public function deleteRule(string $ruleId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -338,6 +349,10 @@ public function deleteRule(string $ruleId): string */ public function updateRuleStatus(string $ruleId): \Appwrite\Models\ProxyRule { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], diff --git a/src/Appwrite/Services/Sites.php b/src/Appwrite/Services/Sites.php index 3aeb94d8..c585adaa 100644 --- a/src/Appwrite/Services/Sites.php +++ b/src/Appwrite/Services/Sites.php @@ -268,6 +268,10 @@ public function listSpecifications(?string $type = null, ?bool $total = null): \ */ public function get(string $siteId): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -302,6 +306,10 @@ public function get(string $siteId): \Appwrite\Models\Site */ public function update(string $siteId, string $name, Framework $framework, ?bool $enabled = null, ?bool $logging = null, ?int $timeout = null, ?string $installCommand = null, ?string $buildCommand = null, ?string $startCommand = null, ?string $outputDirectory = null, ?BuildRuntime $buildRuntime = null, ?Adapter $adapter = null, ?string $fallbackFile = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?array $scopes = null): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -356,10 +364,7 @@ public function update(string $siteId, string $name, Framework $framework, ?bool if (!is_null($installationId)) { $apiParams['installationId'] = $installationId; } - - if (!is_null($providerRepositoryId)) { - $apiParams['providerRepositoryId'] = $providerRepositoryId; - } + $apiParams['providerRepositoryId'] = $providerRepositoryId; if (!is_null($providerBranch)) { $apiParams['providerBranch'] = $providerBranch; @@ -411,6 +416,10 @@ public function update(string $siteId, string $name, Framework $framework, ?bool */ public function delete(string $siteId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -423,6 +432,7 @@ public function delete(string $siteId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -440,6 +450,10 @@ public function delete(string $siteId): string */ public function updateSiteDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -477,6 +491,10 @@ public function updateSiteDeployment(string $siteId, string $deploymentId): \App */ public function listDeployments(string $siteId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\DeploymentList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -525,6 +543,10 @@ public function listDeployments(string $siteId, ?array $queries = null, ?string */ public function createDeployment(string $siteId, InputFile $code, ?string $installCommand = null, ?string $buildCommand = null, ?string $outputDirectory = null, ?bool $activate = null, ?callable $onProgress = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -555,9 +577,6 @@ public function createDeployment(string $siteId, InputFile $code, ?string $insta $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($code->getPath() ?? null)) { $size = strlen($code->getData()); $mimeType = $code->getMimeType(); @@ -711,6 +730,10 @@ public function createDeployment(string $siteId, InputFile $code, ?string $insta */ public function createDuplicateDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -751,6 +774,10 @@ public function createDuplicateDeployment(string $siteId, string $deploymentId): */ public function createTemplateDeployment(string $siteId, string $repository, string $owner, string $rootDirectory, TemplateReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -797,6 +824,10 @@ public function createTemplateDeployment(string $siteId, string $repository, str */ public function createVcsDeployment(string $siteId, VCSReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -838,6 +869,14 @@ public function createVcsDeployment(string $siteId, VCSReferenceType $type, stri */ public function getDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -873,6 +912,14 @@ public function getDeployment(string $siteId, string $deploymentId): \Appwrite\M */ public function deleteDeployment(string $siteId, string $deploymentId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -886,6 +933,7 @@ public function deleteDeployment(string $siteId, string $deploymentId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -904,6 +952,14 @@ public function deleteDeployment(string $siteId, string $deploymentId): string */ public function getDeploymentDownload(string $siteId, string $deploymentId, ?DeploymentDownloadType $type = null, ?string $token = null): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -945,6 +1001,14 @@ public function getDeploymentDownload(string $siteId, string $deploymentId, ?Dep */ public function updateDeploymentStatus(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -982,6 +1046,10 @@ public function updateDeploymentStatus(string $siteId, string $deploymentId): \A */ public function listLogs(string $siteId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ExecutionList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1024,6 +1092,14 @@ public function listLogs(string $siteId, ?array $queries = null, ?bool $total = */ public function getLog(string $siteId, string $logId): \Appwrite\Models\Execution { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($logId === '') { + throw new AppwriteException('Missing required parameter: "logId"'); + } + $apiPath = str_replace( ['{siteId}', '{logId}'], [$siteId, $logId], @@ -1059,6 +1135,14 @@ public function getLog(string $siteId, string $logId): \Appwrite\Models\Executio */ public function deleteLog(string $siteId, string $logId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($logId === '') { + throw new AppwriteException('Missing required parameter: "logId"'); + } + $apiPath = str_replace( ['{siteId}', '{logId}'], [$siteId, $logId], @@ -1089,6 +1173,10 @@ public function deleteLog(string $siteId, string $logId): string */ public function listVariables(string $siteId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\VariableList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1132,6 +1220,10 @@ public function listVariables(string $siteId, ?array $queries = null, ?bool $tot */ public function createVariable(string $siteId, string $variableId, string $key, string $value, ?bool $secret = null): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1174,6 +1266,14 @@ public function createVariable(string $siteId, string $variableId, string $key, */ public function getVariable(string $siteId, string $variableId): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1209,6 +1309,14 @@ public function getVariable(string $siteId, string $variableId): \Appwrite\Model */ public function updateVariable(string $siteId, string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1248,6 +1356,14 @@ public function updateVariable(string $siteId, string $variableId, ?string $key */ public function deleteVariable(string $siteId, string $variableId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1261,6 +1377,7 @@ public function deleteVariable(string $siteId, string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index ed3a2e93..2382a1f4 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -138,6 +138,10 @@ public function createBucket(string $bucketId, string $name, ?array $permissions */ public function getBucket(string $bucketId): \Appwrite\Models\Bucket { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -172,6 +176,10 @@ public function getBucket(string $bucketId): \Appwrite\Models\Bucket */ public function updateBucket(string $bucketId, string $name, ?array $permissions = null, ?bool $fileSecurity = null, ?bool $enabled = null, ?int $maximumFileSize = null, ?array $allowedFileExtensions = null, ?Compression $compression = null, ?bool $encryption = null, ?bool $antivirus = null, ?bool $transformations = null): \Appwrite\Models\Bucket { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -190,22 +198,13 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - - if (!is_null($maximumFileSize)) { - $apiParams['maximumFileSize'] = $maximumFileSize; - } + $apiParams['maximumFileSize'] = $maximumFileSize; if (!is_null($allowedFileExtensions)) { $apiParams['allowedFileExtensions'] = $allowedFileExtensions; } - - if (!is_null($compression)) { - $apiParams['compression'] = $compression; - } - - if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; - } + $apiParams['compression'] = $compression; + $apiParams['encryption'] = $encryption; if (!is_null($antivirus)) { $apiParams['antivirus'] = $antivirus; @@ -241,6 +240,10 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions */ public function deleteBucket(string $bucketId): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -253,6 +256,7 @@ public function deleteBucket(string $bucketId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -270,6 +274,10 @@ public function deleteBucket(string $bucketId): string */ public function listFiles(string $bucketId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\FileList { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -332,6 +340,10 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea */ public function createFile(string $bucketId, string $fileId, InputFile $file, ?array $permissions = null, ?string $folder = null, ?callable $onProgress = null): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -355,9 +367,6 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($file->getPath() ?? null)) { $size = strlen($file->getData()); $mimeType = $file->getMimeType(); @@ -521,6 +530,14 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a */ public function getFile(string $bucketId, string $fileId): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -557,6 +574,14 @@ public function getFile(string $bucketId, string $fileId): \Appwrite\Models\File */ public function updateFile(string $bucketId, string $fileId, ?string $name = null, ?array $permissions = null): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -599,6 +624,14 @@ public function updateFile(string $bucketId, string $fileId, ?string $name = nul */ public function deleteFile(string $bucketId, string $fileId): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -612,6 +645,7 @@ public function deleteFile(string $bucketId, string $fileId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -630,6 +664,14 @@ public function deleteFile(string $bucketId, string $fileId): string */ public function getFileDownload(string $bucketId, string $fileId, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -667,6 +709,14 @@ public function getFileDownload(string $bucketId, string $fileId, ?string $token */ public function getFilePreview(string $bucketId, string $fileId, ?int $width = null, ?int $height = null, ?ImageGravity $gravity = null, ?int $quality = null, ?int $borderWidth = null, ?string $borderColor = null, ?int $borderRadius = null, ?float $opacity = null, ?int $rotation = null, ?string $background = null, ?ImageFormat $output = null, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -746,6 +796,14 @@ public function getFilePreview(string $bucketId, string $fileId, ?int $width = n */ public function getFileView(string $bucketId, string $fileId, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], diff --git a/src/Appwrite/Services/TablesDB.php b/src/Appwrite/Services/TablesDB.php index 4ec544bd..14a42049 100644 --- a/src/Appwrite/Services/TablesDB.php +++ b/src/Appwrite/Services/TablesDB.php @@ -110,8 +110,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -229,6 +229,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -263,6 +267,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -306,6 +314,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -318,6 +330,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -334,6 +347,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -374,6 +391,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -408,6 +429,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, ?string $name = null, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -455,6 +480,10 @@ public function update(string $databaseId, ?string $name = null, ?bool $enabled */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -467,6 +496,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -491,6 +521,10 @@ public function delete(string $databaseId): string */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -528,6 +562,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listMigrations(string $databaseId): \Appwrite\Models\DatabaseMigrationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -564,6 +602,10 @@ public function listMigrations(string $databaseId): \Appwrite\Models\DatabaseMig */ public function createMigration(string $databaseId, string $specification, ?bool $autoCutover = null): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -604,6 +646,14 @@ public function createMigration(string $databaseId, string $specification, ?bool */ public function getMigration(string $databaseId, string $migrationId): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -640,6 +690,14 @@ public function getMigration(string $databaseId, string $migrationId): \Appwrite */ public function deleteMigration(string $databaseId, string $migrationId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -675,6 +733,14 @@ public function deleteMigration(string $databaseId, string $migrationId): string */ public function createCutover(string $databaseId, string $migrationId): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -714,6 +780,10 @@ public function createCutover(string $databaseId, string $migrationId): \Appwrit */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -761,6 +831,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -797,6 +871,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -832,6 +910,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function listTables(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\TableList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -881,6 +963,10 @@ public function listTables(string $databaseId, ?array $queries = null, ?string $ */ public function createTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null, ?array $columns = null, ?array $indexes = null): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -936,6 +1022,14 @@ public function createTable(string $databaseId, string $tableId, string $name, ? */ public function getTable(string $databaseId, string $tableId): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -971,6 +1065,14 @@ public function getTable(string $databaseId, string $tableId): \Appwrite\Models\ */ public function updateTable(string $databaseId, string $tableId, ?string $name = null, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1025,6 +1127,14 @@ public function updateTable(string $databaseId, string $tableId, ?string $name = */ public function deleteTable(string $databaseId, string $tableId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1038,6 +1148,7 @@ public function deleteTable(string $databaseId, string $tableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1054,6 +1165,14 @@ public function deleteTable(string $databaseId, string $tableId): string */ public function listColumns(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ColumnList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1098,6 +1217,14 @@ public function listColumns(string $databaseId, string $tableId, ?array $queries */ public function createBigIntColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1144,6 +1271,18 @@ public function createBigIntColumn(string $databaseId, string $tableId, string $ */ public function updateBigIntColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\ColumnBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1186,6 +1325,14 @@ public function updateBigIntColumn(string $databaseId, string $tableId, string $ */ public function createBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1230,6 +1377,18 @@ public function createBooleanColumn(string $databaseId, string $tableId, string */ public function updateBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1270,6 +1429,14 @@ public function updateBooleanColumn(string $databaseId, string $tableId, string */ public function createDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1314,6 +1481,18 @@ public function createDatetimeColumn(string $databaseId, string $tableId, string */ public function updateDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1354,6 +1533,14 @@ public function updateDatetimeColumn(string $databaseId, string $tableId, string */ public function createEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1398,6 +1585,18 @@ public function createEmailColumn(string $databaseId, string $tableId, string $k */ public function updateEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1439,6 +1638,14 @@ public function updateEmailColumn(string $databaseId, string $tableId, string $k */ public function createEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1484,6 +1691,18 @@ public function createEnumColumn(string $databaseId, string $tableId, string $ke */ public function updateEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1526,6 +1745,14 @@ public function updateEnumColumn(string $databaseId, string $tableId, string $ke */ public function createFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1572,6 +1799,18 @@ public function createFloatColumn(string $databaseId, string $tableId, string $k */ public function updateFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): \Appwrite\Models\ColumnFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1615,6 +1854,14 @@ public function updateFloatColumn(string $databaseId, string $tableId, string $k */ public function createIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1661,6 +1908,18 @@ public function createIntegerColumn(string $databaseId, string $tableId, string */ public function updateIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\ColumnInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1703,6 +1962,14 @@ public function updateIntegerColumn(string $databaseId, string $tableId, string */ public function createIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1747,6 +2014,18 @@ public function createIpColumn(string $databaseId, string $tableId, string $key, */ public function updateIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1787,6 +2066,14 @@ public function updateIpColumn(string $databaseId, string $tableId, string $key, */ public function createLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1827,6 +2114,18 @@ public function createLineColumn(string $databaseId, string $tableId, string $ke */ public function updateLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1867,6 +2166,14 @@ public function updateLineColumn(string $databaseId, string $tableId, string $ke */ public function createLongtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1915,6 +2222,18 @@ public function createLongtextColumn(string $databaseId, string $tableId, string */ public function updateLongtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1955,6 +2274,14 @@ public function updateLongtextColumn(string $databaseId, string $tableId, string */ public function createMediumtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2003,6 +2330,18 @@ public function createMediumtextColumn(string $databaseId, string $tableId, stri */ public function updateMediumtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2043,6 +2382,14 @@ public function updateMediumtextColumn(string $databaseId, string $tableId, stri */ public function createPointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnPoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2083,6 +2430,18 @@ public function createPointColumn(string $databaseId, string $tableId, string $k */ public function updatePointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnPoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2123,6 +2482,14 @@ public function updatePointColumn(string $databaseId, string $tableId, string $k */ public function createPolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnPolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2163,6 +2530,18 @@ public function createPolygonColumn(string $databaseId, string $tableId, string */ public function updatePolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnPolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2204,6 +2583,14 @@ public function updatePolygonColumn(string $databaseId, string $tableId, string */ public function createRelationshipColumn(string $databaseId, string $tableId, string $relatedTableId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): \Appwrite\Models\ColumnRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2245,6 +2632,58 @@ public function createRelationshipColumn(string $databaseId, string $tableId, st return \Appwrite\Models\ColumnRelationship::from($response); } + /** + * Update relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * @throws AppwriteException + */ + public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\ColumnRelationship + { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['onDelete'] = $onDelete; + $apiParams['newKey'] = $newKey; + + $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\ColumnRelationship::from($response); + } + /** * Create a string column. * @@ -2255,6 +2694,14 @@ public function createRelationshipColumn(string $databaseId, string $tableId, st */ public function createStringColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2307,6 +2754,18 @@ public function createStringColumn(string $databaseId, string $tableId, string $ */ public function updateStringColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2348,6 +2807,14 @@ public function updateStringColumn(string $databaseId, string $tableId, string $ */ public function createTextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2396,6 +2863,18 @@ public function createTextColumn(string $databaseId, string $tableId, string $ke */ public function updateTextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2436,6 +2915,14 @@ public function updateTextColumn(string $databaseId, string $tableId, string $ke */ public function createUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2480,6 +2967,18 @@ public function createUrlColumn(string $databaseId, string $tableId, string $key */ public function updateUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2520,6 +3019,14 @@ public function updateUrlColumn(string $databaseId, string $tableId, string $key */ public function createVarcharColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2569,6 +3076,18 @@ public function createVarcharColumn(string $databaseId, string $tableId, string */ public function updateVarcharColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\ColumnVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2608,8 +3127,20 @@ public function updateVarcharColumn(string $databaseId, string $tableId, string * * @throws AppwriteException */ - public function getColumn(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnBoolean|\Appwrite\Models\ColumnInteger|\Appwrite\Models\ColumnFloat|\Appwrite\Models\ColumnEmail|\Appwrite\Models\ColumnEnum|\Appwrite\Models\ColumnUrl|\Appwrite\Models\ColumnIp|\Appwrite\Models\ColumnDatetime|\Appwrite\Models\ColumnRelationship|\Appwrite\Models\ColumnString + public function getColumn(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnBoolean|\Appwrite\Models\ColumnBigint|\Appwrite\Models\ColumnInteger|\Appwrite\Models\ColumnFloat|\Appwrite\Models\ColumnEmail|\Appwrite\Models\ColumnEnum|\Appwrite\Models\ColumnUrl|\Appwrite\Models\ColumnIp|\Appwrite\Models\ColumnDatetime|\Appwrite\Models\ColumnRelationship|\Appwrite\Models\ColumnPoint|\Appwrite\Models\ColumnLine|\Appwrite\Models\ColumnPolygon|\Appwrite\Models\ColumnVarchar|\Appwrite\Models\ColumnText|\Appwrite\Models\ColumnMediumtext|\Appwrite\Models\ColumnLongtext|\Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2656,6 +3187,10 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap return \Appwrite\Models\ColumnBoolean::from($response); } + if (($response['type'] ?? null) === 'bigint') { + return \Appwrite\Models\ColumnBigint::from($response); + } + if (($response['type'] ?? null) === 'integer') { return \Appwrite\Models\ColumnInteger::from($response); } @@ -2672,6 +3207,34 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap return \Appwrite\Models\ColumnRelationship::from($response); } + if (($response['type'] ?? null) === 'point') { + return \Appwrite\Models\ColumnPoint::from($response); + } + + if (($response['type'] ?? null) === 'linestring') { + return \Appwrite\Models\ColumnLine::from($response); + } + + if (($response['type'] ?? null) === 'polygon') { + return \Appwrite\Models\ColumnPolygon::from($response); + } + + if (($response['type'] ?? null) === 'varchar') { + return \Appwrite\Models\ColumnVarchar::from($response); + } + + if (($response['type'] ?? null) === 'text') { + return \Appwrite\Models\ColumnText::from($response); + } + + if (($response['type'] ?? null) === 'mediumtext') { + return \Appwrite\Models\ColumnMediumtext::from($response); + } + + if (($response['type'] ?? null) === 'longtext') { + return \Appwrite\Models\ColumnLongtext::from($response); + } + if (($response['type'] ?? null) === 'string') { return \Appwrite\Models\ColumnString::from($response); } @@ -2686,67 +3249,40 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap */ public function deleteColumn(string $databaseId, string $tableId, string $key): string { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['content-type'] = 'application/json'; + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } - /** - * Update relationship column. [Learn more about relationship - * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * @throws AppwriteException - */ - public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\ColumnRelationship - { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' ); $apiParams = []; $apiParams['databaseId'] = $databaseId; $apiParams['tableId'] = $tableId; $apiParams['key'] = $key; - $apiParams['onDelete'] = $onDelete; - $apiParams['newKey'] = $newKey; $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, + return $this->client->call( + Client::METHOD_DELETE, $apiPath, $apiHeaders, $apiParams ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\ColumnRelationship::from($response); } /** @@ -2756,6 +3292,14 @@ public function updateRelationshipColumn(string $databaseId, string $tableId, st */ public function listIndexes(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ColumnIndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2795,12 +3339,22 @@ public function listIndexes(string $databaseId, string $tableId, ?array $queries /** * Creates an index on the columns listed. Your index should include all the * columns you will query in a single request. - * Type can be `key`, `fulltext`, or `unique`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + * is only available on PostgreSQL and lets `contains`, `startsWith`, and + * `endsWith` queries on string columns use an index. * * @throws AppwriteException */ public function createIndex(string $databaseId, string $tableId, string $key, TablesDBIndexType $type, array $columns, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\ColumnIndex { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2848,6 +3402,18 @@ public function createIndex(string $databaseId, string $tableId, string $key, Ta */ public function getIndex(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnIndex { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2884,6 +3450,18 @@ public function getIndex(string $databaseId, string $tableId, string $key): \App */ public function deleteIndex(string $databaseId, string $tableId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2898,6 +3476,7 @@ public function deleteIndex(string $databaseId, string $tableId, string $key): s $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2915,6 +3494,14 @@ public function deleteIndex(string $databaseId, string $tableId, string $key): s */ public function listRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2969,6 +3556,14 @@ public function listRows(string $databaseId, string $tableId, ?array $queries = */ public function createRow(string $databaseId, string $tableId, string $rowId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3012,6 +3607,14 @@ public function createRow(string $databaseId, string $tableId, string $rowId, ar */ public function createRows(string $databaseId, string $tableId, array $rows, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3053,6 +3656,14 @@ public function createRows(string $databaseId, string $tableId, array $rows, ?st */ public function upsertRows(string $databaseId, string $tableId, array $rows, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3092,6 +3703,14 @@ public function upsertRows(string $databaseId, string $tableId, array $rows, ?st */ public function updateRows(string $databaseId, string $tableId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3138,6 +3757,14 @@ public function updateRows(string $databaseId, string $tableId, ?array $data = n */ public function deleteRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3183,6 +3810,18 @@ public function deleteRows(string $databaseId, string $tableId, ?array $queries */ public function getRow(string $databaseId, string $tableId, string $rowId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3230,6 +3869,18 @@ public function getRow(string $databaseId, string $tableId, string $rowId, ?arra */ public function upsertRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3274,6 +3925,18 @@ public function upsertRow(string $databaseId, string $tableId, string $rowId, ?a */ public function updateRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3317,6 +3980,18 @@ public function updateRow(string $databaseId, string $tableId, string $rowId, ?a */ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3335,6 +4010,7 @@ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?s $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -3351,6 +4027,22 @@ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?s */ public function decrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if ($column === '') { + throw new AppwriteException('Missing required parameter: "column"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}', '{column}'], [$databaseId, $tableId, $rowId, $column], @@ -3395,6 +4087,22 @@ public function decrementRowColumn(string $databaseId, string $tableId, string $ */ public function incrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if ($column === '') { + throw new AppwriteException('Missing required parameter: "column"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}', '{column}'], [$databaseId, $tableId, $rowId, $column], diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index 3aad4091..e963c412 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -105,6 +105,10 @@ public function create(string $teamId, string $name, ?array $roles = null): \App */ public function get(string $teamId): \Appwrite\Models\Team { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -139,6 +143,10 @@ public function get(string $teamId): \Appwrite\Models\Team */ public function updateName(string $teamId, string $name): \Appwrite\Models\Team { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -176,6 +184,10 @@ public function updateName(string $teamId, string $name): \Appwrite\Models\Team */ public function delete(string $teamId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -188,6 +200,7 @@ public function delete(string $teamId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -204,6 +217,10 @@ public function delete(string $teamId): string */ public function listInstallations(string $teamId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppInstallationList { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -249,6 +266,10 @@ public function listInstallations(string $teamId, ?array $queries = null, ?bool */ public function createInstallation(string $teamId, string $appId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -290,6 +311,14 @@ public function createInstallation(string $teamId, string $appId, ?string $autho */ public function getInstallation(string $teamId, string $installationId): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -328,6 +357,14 @@ public function getInstallation(string $teamId, string $installationId): \Appwri */ public function updateInstallation(string $teamId, string $installationId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -367,6 +404,14 @@ public function updateInstallation(string $teamId, string $installationId, ?stri */ public function deleteInstallation(string $teamId, string $installationId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -399,6 +444,10 @@ public function deleteInstallation(string $teamId, string $installationId): stri */ public function listMemberships(string $teamId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\MembershipList { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -464,6 +513,10 @@ public function listMemberships(string $teamId, ?array $queries = null, ?string */ public function createMembership(string $teamId, array $roles, ?string $email = null, ?string $userId = null, ?string $phone = null, ?string $url = null, ?string $name = null, ?string $membershipId = null): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -526,6 +579,14 @@ public function createMembership(string $teamId, array $roles, ?string $email = */ public function getMembership(string $teamId, string $membershipId): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -563,6 +624,14 @@ public function getMembership(string $teamId, string $membershipId): \Appwrite\M */ public function updateMembership(string $teamId, string $membershipId, array $roles): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -602,6 +671,14 @@ public function updateMembership(string $teamId, string $membershipId, array $ro */ public function deleteMembership(string $teamId, string $membershipId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -615,6 +692,7 @@ public function deleteMembership(string $teamId, string $membershipId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -636,6 +714,14 @@ public function deleteMembership(string $teamId, string $membershipId): string */ public function updateMembershipStatus(string $teamId, string $membershipId, string $userId, string $secret): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -676,6 +762,10 @@ public function updateMembershipStatus(string $teamId, string $membershipId, str */ public function getPrefs(string $teamId): \Appwrite\Models\Preferences { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -712,6 +802,10 @@ public function getPrefs(string $teamId): \Appwrite\Models\Preferences */ public function updatePrefs(string $teamId, array $prefs): \Appwrite\Models\Preferences { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], diff --git a/src/Appwrite/Services/Tokens.php b/src/Appwrite/Services/Tokens.php index 1d2b5137..a5d3bc40 100644 --- a/src/Appwrite/Services/Tokens.php +++ b/src/Appwrite/Services/Tokens.php @@ -18,6 +18,14 @@ class Tokens extends Service */ public function list(string $bucketId, string $fileId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ResourceTokenList { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -62,6 +70,14 @@ public function list(string $bucketId, string $fileId, ?array $queries = null, ? */ public function createFileToken(string $bucketId, string $fileId, ?string $expire = null): \Appwrite\Models\ResourceToken { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -99,6 +115,10 @@ public function createFileToken(string $bucketId, string $fileId, ?string $expir */ public function get(string $tokenId): \Appwrite\Models\ResourceToken { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -134,6 +154,10 @@ public function get(string $tokenId): \Appwrite\Models\ResourceToken */ public function update(string $tokenId, ?string $expire = null): \Appwrite\Models\ResourceToken { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -170,6 +194,10 @@ public function update(string $tokenId, ?string $expire = null): \Appwrite\Model */ public function delete(string $tokenId): string { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -182,6 +210,7 @@ public function delete(string $tokenId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index b0333df3..cbd44020 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -76,10 +76,7 @@ public function create(string $userId, ?string $email = null, ?string $phone = n $apiParams['userId'] = $userId; $apiParams['email'] = $email; $apiParams['phone'] = $phone; - - if (!is_null($password)) { - $apiParams['password'] = $password; - } + $apiParams['password'] = $password; if (!is_null($name)) { $apiParams['name'] = $name; @@ -244,6 +241,10 @@ public function listIdentities(?array $queries = null, ?string $search = null, ? */ public function deleteIdentity(string $identityId): string { + if ($identityId === '') { + throw new AppwriteException('Missing required parameter: "identityId"'); + } + $apiPath = str_replace( ['{identityId}'], [$identityId], @@ -256,6 +257,7 @@ public function deleteIdentity(string $identityId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -505,6 +507,10 @@ public function createSHAUser(string $userId, string $email, string $password, ? */ public function get(string $userId): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -544,6 +550,10 @@ public function get(string $userId): \Appwrite\Models\User */ public function delete(string $userId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -556,6 +566,7 @@ public function delete(string $userId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -572,6 +583,10 @@ public function delete(string $userId): string */ public function updateEmail(string $userId, string $email): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -606,12 +621,19 @@ public function updateEmail(string $userId, string $email): \Appwrite\Models\Use * impersonation headers are used, the request runs as the target user for API * behavior, while internal audit logs still attribute the action to the * original impersonator and store the impersonated target details only in - * internal audit payload data. + * internal audit payload data. Account endpoints are read-only while + * impersonating: they report the target's account, and anything that would + * change it is refused, so an impersonator cannot alter the target's + * credentials or delete their account. * * @throws AppwriteException */ public function updateImpersonator(string $userId, bool $impersonator): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -650,6 +672,10 @@ public function updateImpersonator(string $userId, bool $impersonator): \Appwrit */ public function createJWT(string $userId, ?string $sessionId = null, ?int $duration = null): \Appwrite\Models\Jwt { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -698,6 +724,10 @@ public function createJWT(string $userId, ?string $sessionId = null, ?int $durat */ public function updateLabels(string $userId, array $labels): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -727,48 +757,6 @@ public function updateLabels(string $userId, array $labels): \Appwrite\Models\Us return \Appwrite\Models\User::from($response); } - /** - * Get the user activity logs list by its unique ID. - * - * @throws AppwriteException - */ - public function listLogs(string $userId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - ['{userId}'], - [$userId], - '/users/{userId}/logs' - ); - - $apiParams = []; - $apiParams['userId'] = $userId; - - 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 user membership list by its unique ID. * @@ -776,6 +764,10 @@ public function listLogs(string $userId, ?array $queries = null, ?bool $total = */ public function listMemberships(string $userId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\MembershipList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -822,6 +814,10 @@ public function listMemberships(string $userId, ?array $queries = null, ?string */ public function updateMFA(string $userId, bool $mfa): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -858,6 +854,10 @@ public function updateMFA(string $userId, bool $mfa): \Appwrite\Models\User */ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}', '{type}'], [$userId, (string) $type], @@ -871,6 +871,7 @@ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -888,6 +889,14 @@ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): */ public function getMFAChallenge(string $userId, string $challengeId): \Appwrite\Models\MfaChallengeSecret { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($challengeId === '') { + throw new AppwriteException('Missing required parameter: "challengeId"'); + } + $apiPath = str_replace( ['{userId}', '{challengeId}'], [$userId, $challengeId], @@ -923,6 +932,10 @@ public function getMFAChallenge(string $userId, string $challengeId): \Appwrite\ */ public function listMFAFactors(string $userId): \Appwrite\Models\MfaFactors { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -960,6 +973,10 @@ public function listMFAFactors(string $userId): \Appwrite\Models\MfaFactors */ public function getMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -997,6 +1014,10 @@ public function getMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecover */ public function updateMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1035,6 +1056,10 @@ public function updateMFARecoveryCodes(string $userId): \Appwrite\Models\MfaReco */ public function createMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1070,6 +1095,10 @@ public function createMFARecoveryCodes(string $userId): \Appwrite\Models\MfaReco */ public function updateName(string $userId, string $name): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1279,6 +1308,10 @@ public function deletePasskey(string $userId, string $passkeyId): string */ public function updatePassword(string $userId, string $password): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1315,6 +1348,10 @@ public function updatePassword(string $userId, string $password): \Appwrite\Mode */ public function updatePhone(string $userId, string $number): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1351,6 +1388,10 @@ public function updatePhone(string $userId, string $number): \Appwrite\Models\Us */ public function getPrefs(string $userId): \Appwrite\Models\Preferences { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1387,6 +1428,10 @@ public function getPrefs(string $userId): \Appwrite\Models\Preferences */ public function updatePrefs(string $userId, array $prefs): \Appwrite\Models\Preferences { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1423,6 +1468,10 @@ public function updatePrefs(string $userId, array $prefs): \Appwrite\Models\Pref */ public function listSessions(string $userId, ?bool $total = null): \Appwrite\Models\SessionList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1466,6 +1515,10 @@ public function listSessions(string $userId, ?bool $total = null): \Appwrite\Mod */ public function createSession(string $userId): \Appwrite\Models\Session { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1501,6 +1554,10 @@ public function createSession(string $userId): \Appwrite\Models\Session */ public function deleteSessions(string $userId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1513,6 +1570,7 @@ public function deleteSessions(string $userId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1529,6 +1587,14 @@ public function deleteSessions(string $userId): string */ public function deleteSession(string $userId, string $sessionId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{userId}', '{sessionId}'], [$userId, $sessionId], @@ -1542,6 +1608,7 @@ public function deleteSession(string $userId, string $sessionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1559,6 +1626,10 @@ public function deleteSession(string $userId, string $sessionId): string */ public function updateStatus(string $userId, bool $status): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1595,6 +1666,10 @@ public function updateStatus(string $userId, bool $status): \Appwrite\Models\Use */ public function listTargets(string $userId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\TargetList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1637,6 +1712,10 @@ public function listTargets(string $userId, ?array $queries = null, ?bool $total */ public function createTarget(string $userId, string $targetId, MessagingProviderType $providerType, string $identifier, ?string $providerId = null, ?string $name = null): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1683,6 +1762,14 @@ public function createTarget(string $userId, string $targetId, MessagingProvider */ public function getTarget(string $userId, string $targetId): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1718,6 +1805,14 @@ public function getTarget(string $userId, string $targetId): \Appwrite\Models\Ta */ public function updateTarget(string $userId, string $targetId, ?string $identifier = null, ?string $providerId = null, ?string $name = null): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1766,6 +1861,14 @@ public function updateTarget(string $userId, string $targetId, ?string $identifi */ public function deleteTarget(string $userId, string $targetId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1779,6 +1882,7 @@ public function deleteTarget(string $userId, string $targetId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1798,6 +1902,10 @@ public function deleteTarget(string $userId, string $targetId): string */ public function createToken(string $userId, ?int $length = null, ?int $expire = null): \Appwrite\Models\Token { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1841,6 +1949,10 @@ public function createToken(string $userId, ?int $length = null, ?int $expire = */ public function updateEmailVerification(string $userId, bool $emailVerification): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1877,6 +1989,10 @@ public function updateEmailVerification(string $userId, bool $emailVerification) */ public function updatePhoneVerification(string $userId, bool $phoneVerification): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], diff --git a/src/Appwrite/Services/VectorsDB.php b/src/Appwrite/Services/VectorsDB.php index c2a5c12a..053efccb 100644 --- a/src/Appwrite/Services/VectorsDB.php +++ b/src/Appwrite/Services/VectorsDB.php @@ -104,8 +104,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -223,6 +223,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -257,6 +261,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -300,6 +308,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -312,6 +324,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -328,6 +341,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -368,6 +385,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -402,6 +423,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, string $name, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -446,6 +471,10 @@ public function update(string $databaseId, string $name, ?bool $enabled = null, */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -458,6 +487,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -475,6 +505,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\VectorsdbCollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -524,6 +558,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, int $dimension, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -575,6 +613,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -610,6 +656,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?int $dimension = null, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -632,10 +686,7 @@ public function updateCollection(string $databaseId, string $collectionId, strin if (!is_null($documentSecurity)) { $apiParams['documentSecurity'] = $documentSecurity; } - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } + $apiParams['enabled'] = $enabled; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -664,6 +715,14 @@ public function updateCollection(string $databaseId, string $collectionId, strin */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -677,6 +736,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -694,6 +754,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -748,6 +816,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -797,6 +873,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -841,6 +925,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -884,6 +976,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -933,6 +1033,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -980,6 +1088,14 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function createQuery(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1033,6 +1149,18 @@ public function createQuery(string $databaseId, string $collectionId, ?array $qu */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1080,6 +1208,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1130,6 +1270,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1179,6 +1331,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1197,6 +1361,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1213,6 +1378,14 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1258,6 +1431,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, VectorsDBIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1305,6 +1486,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1341,6 +1534,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1355,6 +1560,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1379,6 +1585,10 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1418,6 +1628,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1465,6 +1679,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1501,6 +1719,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Webhooks.php b/src/Appwrite/Services/Webhooks.php index 2694980a..7563d2ff 100644 --- a/src/Appwrite/Services/Webhooks.php +++ b/src/Appwrite/Services/Webhooks.php @@ -116,6 +116,10 @@ public function create(string $webhookId, string $url, string $name, array $even */ public function get(string $webhookId): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -151,6 +155,10 @@ public function get(string $webhookId): \Appwrite\Models\Webhook */ public function update(string $webhookId, string $name, string $url, array $events, ?bool $enabled = null, ?bool $tls = null, ?string $authUsername = null, ?string $authPassword = null): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -174,10 +182,7 @@ public function update(string $webhookId, string $name, string $url, array $even if (!is_null($authUsername)) { $apiParams['authUsername'] = $authUsername; } - - if (!is_null($authPassword)) { - $apiParams['authPassword'] = $authPassword; - } + $apiParams['authPassword'] = $authPassword; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -206,6 +211,10 @@ public function update(string $webhookId, string $name, string $url, array $even */ public function delete(string $webhookId): string { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -218,6 +227,7 @@ public function delete(string $webhookId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -236,6 +246,10 @@ public function delete(string $webhookId): string */ public function updateSecret(string $webhookId, ?string $secret = null): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], diff --git a/tests/Appwrite/ClientTest.php b/tests/Appwrite/ClientTest.php index 46678475..99d5b6ff 100644 --- a/tests/Appwrite/ClientTest.php +++ b/tests/Appwrite/ClientTest.php @@ -5,9 +5,14 @@ namespace Appwrite; use PHPUnit\Framework\TestCase; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; use ReflectionMethod; use ReflectionProperty; use Utopia\Client\Client as HttpClient; +use Utopia\Psr7\Response; +use Utopia\Psr7\Stream; final class ClientTest extends TestCase { @@ -117,13 +122,6 @@ public function testSetForwardedUserAgentReturnsClient(): void $this->assertSame($client, $result); } - public function testSetDevKeyReturnsClient(): void - { - $client = new Client(); - $result = $client->setDevKey('test-value'); - $this->assertSame($client, $result); - } - public function testSetCookieReturnsClient(): void { $client = new Client(); @@ -185,7 +183,76 @@ public function testSelfSignedAndConnectTimeoutResetHttpClient(): void $this->assertNotSame($afterSelfSigned, $this->httpClient($client, true)); } - private function httpClient(Client $client, bool $followRedirects): HttpClient + public function testInjectedTransportReceivesEncodedRequests(): void + { + $received = []; + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->once())->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request) use (&$received): ResponseInterface { + $received[] = $request; + + return new Response(body: new Stream('{"received":true}')) + ->withHeader('content-type', 'application/json'); + }); + + $client = new Client($transport) + ->setEndpoint('https://example.com/v1') + ->addHeader('x-test', 'injected'); + + $this->assertSame(['received' => true], $client->call(Client::METHOD_POST, '/items', ['content-type' => 'application/json'], ['name' => 'item'])); + $this->assertCount(1, $received); + $this->assertSame('POST', $received[0]->getMethod()); + $this->assertSame('https://example.com/v1/items', (string) $received[0]->getUri()); + $this->assertSame(['name' => 'item'], json_decode((string) $received[0]->getBody(), true)); + $this->assertSame('injected', $received[0]->getHeaderLine('x-test')); + } + + public function testInjectedTransportSurvivesFailureAndConfigurationChanges(): void + { + $received = []; + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->exactly(2))->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request) use (&$received): ResponseInterface { + $received[] = (string) $request->getUri(); + + return count($received) === 1 + ? new Response(503, body: new Stream('{"message":"Unavailable","type":"unavailable"}'))->withHeader('content-type', 'application/json') + : new Response(body: new Stream('null'))->withHeader('content-type', 'application/json'); + }); + $client = new Client($transport)->setEndpoint('https://first.example'); + + $failure = null; + try { + $client->call(Client::METHOD_GET, '/fail'); + } catch (AppwriteException $error) { + $failure = $error; + } + + $client->setEndpoint('https://second.example')->setTimeout(5)->setConnectTimeout(2)->setSelfSigned(true); + $this->assertNull($client->call(Client::METHOD_GET, '/next', params: ['project' => 'project-1'])); + $this->assertInstanceOf(AppwriteException::class, $failure); + $this->assertSame(503, $failure->getCode()); + $this->assertSame(['https://first.example/fail', 'https://second.example/next?project=project-1'], $received); + $this->assertSame($transport, $this->httpClient($client, true)); + $this->assertSame($transport, $this->httpClient($client, false)); + } + + public function testLocationResponseUsesInjectedTransport(): void + { + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->once())->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request): ResponseInterface { + $this->assertSame('GET', $request->getMethod()); + $this->assertSame('https://example.com/redirect', (string) $request->getUri()); + + return new Response(302)->withHeader('location', 'https://storage.example/file'); + }); + + $client = new Client($transport)->setEndpoint('https://example.com'); + $this->assertSame('https://storage.example/file', $client->call(Client::METHOD_GET, '/redirect', responseType: 'location')); + } + + private function httpClient(Client $client, bool $followRedirects): ClientInterface { $method = new ReflectionMethod(Client::class, 'getHttpClient'); diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php index c4a20ad2..eed55b62 100644 --- a/tests/Appwrite/Services/AccountTest.php +++ b/tests/Appwrite/Services/AccountTest.php @@ -333,7 +333,8 @@ public function testMethodListIdentities(): void "providerEmail" => "user@example.com", "providerAccessToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", "providerAccessTokenExpiry" => "2020-10-15T06:38:00.000+00:00", - "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3" + "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerIdToken" => "eyJhbGciOiJSUzI1NiIsImtpZCI6IjBhYzNmMWQwNWExYjhlN2YifQ.eyJzdWIiOiIxMTAxNjk0ODQ0NzQzODYyNzYzMzQifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ] ] ]; @@ -366,49 +367,6 @@ public function testMethodDeleteIdentity(): void $this->assertSame($data, $response); } - public function testMethodListLogs(): void - { - $data = [ - "total" => 5, - "logs" => [ - [ - "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->account->listLogs(); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } public function testMethodUpdateMFA(): void { $data = [ diff --git a/tests/Appwrite/Services/BackupsTest.php b/tests/Appwrite/Services/BackupsTest.php index 353bd0d7..11782077 100644 --- a/tests/Appwrite/Services/BackupsTest.php +++ b/tests/Appwrite/Services/BackupsTest.php @@ -31,9 +31,7 @@ public function testMethodListArchives(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -59,9 +57,7 @@ public function testMethodCreateArchive(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -87,9 +83,7 @@ public function testMethodGetArchive(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -182,7 +176,7 @@ public function testMethodCreatePolicy(): void "", [BackupServices::DATABASES()], 1, - "" + "schedule" ); $this->assertInstanceOf(\Appwrite\Models\BackupPolicy::class, $response); @@ -269,11 +263,10 @@ public function testMethodCreateRestoration(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ]; $this->client @@ -302,11 +295,10 @@ public function testMethodListRestorations(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ] ] ]; @@ -331,11 +323,10 @@ public function testMethodGetRestoration(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ]; $this->client diff --git a/tests/Appwrite/Services/DocumentsDBTest.php b/tests/Appwrite/Services/DocumentsDBTest.php index 183fdefc..9f51a063 100644 --- a/tests/Appwrite/Services/DocumentsDBTest.php +++ b/tests/Appwrite/Services/DocumentsDBTest.php @@ -81,6 +81,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -89,13 +93,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -970,16 +968,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -989,6 +983,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1002,7 +998,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1096,10 +1092,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, diff --git a/tests/Appwrite/Services/FunctionsTest.php b/tests/Appwrite/Services/FunctionsTest.php index 0e950d3a..dc681800 100644 --- a/tests/Appwrite/Services/FunctionsTest.php +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -808,7 +808,7 @@ public function testMethodListExecutions(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ] ] ]; @@ -856,7 +856,7 @@ public function testMethodCreateExecution(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client @@ -902,7 +902,7 @@ public function testMethodGetExecution(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client diff --git a/tests/Appwrite/Services/MongoTest.php b/tests/Appwrite/Services/MongoTest.php index aaa2b0ea..db3fd910 100644 --- a/tests/Appwrite/Services/MongoTest.php +++ b/tests/Appwrite/Services/MongoTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -819,16 +804,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -838,6 +819,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -851,7 +834,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -884,16 +867,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -903,6 +882,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -916,7 +897,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -951,16 +932,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -970,6 +947,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -983,7 +962,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1099,14 +1078,9 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1131,14 +1105,9 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1161,14 +1130,9 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1194,10 +1158,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1240,16 +1200,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1259,6 +1215,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1272,7 +1230,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/MysqlTest.php b/tests/Appwrite/Services/MysqlTest.php index 85f067a6..c413429a 100644 --- a/tests/Appwrite/Services/MysqlTest.php +++ b/tests/Appwrite/Services/MysqlTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -849,16 +834,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -868,6 +849,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -881,7 +864,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -914,16 +897,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -933,6 +912,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -946,7 +927,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -981,16 +962,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1000,6 +977,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1013,7 +992,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1185,14 +1164,9 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1217,14 +1191,9 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1247,14 +1216,9 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1280,10 +1244,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1326,16 +1286,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1345,6 +1301,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1358,7 +1316,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/Oauth2Test.php b/tests/Appwrite/Services/Oauth2Test.php index 3196d5e8..ed0c9360 100644 --- a/tests/Appwrite/Services/Oauth2Test.php +++ b/tests/Appwrite/Services/Oauth2Test.php @@ -80,8 +80,8 @@ public function testMethodCreateDeviceAuthorization(): void $data = [ "device_code" => "5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a", "user_code" => "ABCD-EFGH", - "verification_uri" => "https://cloud.appwrite.io/console/oauth2/device", - "verification_uri_complete" => "https://cloud.appwrite.io/console/oauth2/device?user_code=ABCD-EFGH", + "verification_uri" => "https://appwrite.io/oauth2/device", + "verification_uri_complete" => "https://appwrite.io/oauth2/device?user_code=ABCD-EFGH", "expires_in" => 900, "interval" => 5 ]; diff --git a/tests/Appwrite/Services/OrganizationTest.php b/tests/Appwrite/Services/OrganizationTest.php index 1132dac0..7fa0c08a 100644 --- a/tests/Appwrite/Services/OrganizationTest.php +++ b/tests/Appwrite/Services/OrganizationTest.php @@ -8,7 +8,6 @@ use Mockery; use Mockery\MockInterface; use PHPUnit\Framework\TestCase; -use Appwrite\Enums\OrganizationKeyScopes; use Appwrite\Enums\ProjectKeyScopes; final class OrganizationTest extends TestCase @@ -47,6 +46,7 @@ public function testMethodGet(): void "screenshotsGenerated" => 50, "webhooks" => 25, "wafRules" => 2, + "environments" => 5, "projects" => 2, "platforms" => 3, "users" => 25, @@ -71,72 +71,6 @@ public function testMethodGet(): void "usageLogs" => 30, "projectInactivityDays" => 7, "alertLimit" => 80, - "usage" => [ - "bandwidth" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "executions" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtime" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtimeMessages" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "storage" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "users" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "GBHours" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "imageTransformations" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ] - ], "addons" => [], "budgetCapEnabled" => true, "customSmtp" => true, @@ -166,17 +100,10 @@ public function testMethodGet(): void "buildSize" => 2000, "functionsIntervalMinimum" => 60, "databasesAllowEncrypt" => true, - "group" => "starter", + "group" => "free", "databaseComputeCredit" => 10 ], "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", - "billingTrialDays" => 14, - "billingAggregationId" => "adbc3de4rddfsd", - "billingInvoiceId" => "adbc3de4rddfsd", - "paymentMethodId" => "adbc3de4rddfsd", "status" => "active", "markedForDeletion" => true, "platform" => "imagine", @@ -219,6 +146,7 @@ public function testMethodUpdate(): void "screenshotsGenerated" => 50, "webhooks" => 25, "wafRules" => 2, + "environments" => 5, "projects" => 2, "platforms" => 3, "users" => 25, @@ -243,72 +171,6 @@ public function testMethodUpdate(): void "usageLogs" => 30, "projectInactivityDays" => 7, "alertLimit" => 80, - "usage" => [ - "bandwidth" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "executions" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtime" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtimeMessages" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "storage" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "users" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "GBHours" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "imageTransformations" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ] - ], "addons" => [], "budgetCapEnabled" => true, "customSmtp" => true, @@ -338,17 +200,10 @@ public function testMethodUpdate(): void "buildSize" => 2000, "functionsIntervalMinimum" => 60, "databasesAllowEncrypt" => true, - "group" => "starter", + "group" => "free", "databaseComputeCredit" => 10 ], "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", - "billingTrialDays" => 14, - "billingAggregationId" => "adbc3de4rddfsd", - "billingInvoiceId" => "adbc3de4rddfsd", - "paymentMethodId" => "adbc3de4rddfsd", "status" => "active", "markedForDeletion" => true, "platform" => "imagine", @@ -511,138 +366,6 @@ public function testMethodDeleteInstallation(): void $this->assertSame($data, $response); } - public function testMethodListKeys(): void - { - $data = [ - "total" => 5, - "keys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->listKeys(); - - $this->assertInstanceOf(\Appwrite\Models\KeyList::class, $response); - } - public function testMethodCreateKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->createKey( - "", - "", - [OrganizationKeyScopes::PROJECTSREAD()] - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodGetKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->getKey( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodUpdateKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->updateKey( - "", - "", - [OrganizationKeyScopes::PROJECTSREAD()] - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodDeleteKey(): 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->deleteKey( - "" - ); - - $this->assertSame($data, $response); - } public function testMethodListMemberships(): void { $data = [ @@ -808,18 +531,6 @@ public function testMethodListProjects(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -858,12 +569,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -891,18 +597,6 @@ public function testMethodCreateProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -941,12 +635,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -975,18 +664,6 @@ public function testMethodGetProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -1025,12 +702,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -1058,18 +730,6 @@ public function testMethodUpdateProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -1108,12 +768,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" diff --git a/tests/Appwrite/Services/PostgresqlTest.php b/tests/Appwrite/Services/PostgresqlTest.php index f4204910..f5ef1b99 100644 --- a/tests/Appwrite/Services/PostgresqlTest.php +++ b/tests/Appwrite/Services/PostgresqlTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -877,16 +862,12 @@ public function testMethodCreateExtension(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -896,6 +877,8 @@ public function testMethodCreateExtension(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -909,7 +892,7 @@ public function testMethodCreateExtension(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -943,16 +926,12 @@ public function testMethodDeleteExtension(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -962,6 +941,8 @@ public function testMethodDeleteExtension(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -975,7 +956,7 @@ public function testMethodDeleteExtension(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1009,16 +990,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1028,6 +1005,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1041,7 +1020,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1074,16 +1053,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1093,6 +1068,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1106,7 +1083,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1141,16 +1118,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1160,6 +1133,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1173,7 +1148,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1345,14 +1320,9 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1377,14 +1347,9 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1407,14 +1372,9 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1440,10 +1400,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1486,16 +1442,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1505,6 +1457,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1518,7 +1472,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/ProjectTest.php b/tests/Appwrite/Services/ProjectTest.php index ca05b4f6..5d9b3983 100644 --- a/tests/Appwrite/Services/ProjectTest.php +++ b/tests/Appwrite/Services/ProjectTest.php @@ -36,18 +36,6 @@ public function testMethodGet(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -86,12 +74,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -132,18 +115,6 @@ public function testMethodUpdateAuthMethod(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -182,12 +153,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -219,7 +185,6 @@ public function testMethodListEnvironments(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -258,12 +223,7 @@ public function testMethodListEnvironments(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -291,7 +251,6 @@ public function testMethodCreateEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -330,12 +289,7 @@ public function testMethodCreateEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -364,7 +318,6 @@ public function testMethodGetEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -403,12 +356,7 @@ public function testMethodGetEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -436,7 +384,6 @@ public function testMethodUpdateEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -475,12 +422,7 @@ public function testMethodUpdateEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -657,18 +599,6 @@ public function testMethodUpdateLabels(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -707,12 +637,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -868,18 +793,6 @@ public function testMethodUpdateOAuth2Server(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -918,12 +831,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -971,7 +879,9 @@ public function testMethodUpdateOAuth2Apple(): void "serviceId" => "ip.appwrite.app.web", "keyId" => "P4000000N8", "teamId" => "D4000000R6", - "p8File" => "-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----" + "p8File" => "-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----", + "nativeEnabled" => true, + "nativeClientIds" => [] ]; $this->client @@ -1012,6 +922,7 @@ public function testMethodUpdateOAuth2Auth0(): void "enabled" => true, "clientId" => "OaOkIA000000000000000000005KLSYq", "clientSecret" => "zXz0000-00000000000000000000000000000-00000000000000000000PJafnF", + "prompt" => ["none"], "endpoint" => "example.us.auth0.com" ]; @@ -1173,7 +1084,8 @@ public function testMethodUpdateOAuth2Discord(): void "\$id" => "github", "enabled" => true, "clientId" => "950722000000343754", - "clientSecret" => "YmPXnM000000000000000000002zFg5D" + "clientSecret" => "YmPXnM000000000000000000002zFg5D", + "prompt" => ["none"] ]; $this->client @@ -1314,7 +1226,8 @@ public function testMethodUpdateOAuth2GitHub(): void "\$id" => "github", "enabled" => true, "clientId" => "e4d87900000000540733", - "clientSecret" => "5e07c00000000000000000000000000000198bcc" + "clientSecret" => "5e07c00000000000000000000000000000198bcc", + "prompt" => ["select_account"] ]; $this->client @@ -1356,7 +1269,9 @@ public function testMethodUpdateOAuth2Google(): void "enabled" => true, "clientId" => "120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com", "clientSecret" => "GOCSPX-2k8gsR0000000000000000VNahJj", - "prompt" => ["none"] + "prompt" => ["none"], + "nativeEnabled" => true, + "nativeClientIds" => [] ]; $this->client @@ -1480,6 +1395,7 @@ public function testMethodUpdateOAuth2Microsoft(): void "enabled" => true, "applicationId" => "00001111-aaaa-2222-bbbb-3333cccc4444", "applicationSecret" => "A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u", + "prompt" => ["none"], "tenant" => "common" ]; @@ -1521,11 +1437,11 @@ public function testMethodUpdateOAuth2Oidc(): void "enabled" => true, "clientId" => "qibI2x0000000000000000000000000006L2YFoG", "clientSecret" => "Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV", + "prompt" => ["none"], "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", - "prompt" => ["none"] + "userInfoURL" => "https://myoauth.com/oauth2/userinfo" ]; $this->client @@ -1546,6 +1462,7 @@ public function testMethodUpdateOAuth2Okta(): void "enabled" => true, "clientId" => "0oa00000000000000698", "clientSecret" => "Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV", + "prompt" => ["none"], "domain" => "trial-6400025.okta.com", "authorizationServerId" => "aus000000000000000h7z" ]; @@ -1647,7 +1564,8 @@ public function testMethodUpdateOAuth2Salesforce(): void "\$id" => "github", "enabled" => true, "customerKey" => "3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq", - "customerSecret" => "3w000000000000e2" + "customerSecret" => "3w000000000000e2", + "prompt" => ["login"] ]; $this->client @@ -1907,7 +1825,8 @@ public function testMethodUpdateOAuth2Zoho(): void "\$id" => "github", "enabled" => true, "clientId" => "1000.83C178000000000000000000RPNX0B", - "clientSecret" => "fb5cac000000000000000000000000000000a68f6e" + "clientSecret" => "fb5cac000000000000000000000000000000a68f6e", + "prompt" => ["consent"] ]; $this->client @@ -1995,7 +1914,8 @@ public function testMethodCreateAndroidPlatform(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "My Web App", "type" => "windows", - "applicationId" => "com.company.appname" + "applicationId" => "com.company.appname", + "fingerprints" => [] ]; $this->client @@ -2021,7 +1941,8 @@ public function testMethodUpdateAndroidPlatform(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "My Web App", "type" => "windows", - "applicationId" => "com.company.appname" + "applicationId" => "com.company.appname", + "fingerprints" => [] ]; $this->client @@ -2320,18 +2241,6 @@ public function testMethodUpdateDenyAliasedEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2370,12 +2279,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2403,18 +2307,6 @@ public function testMethodUpdateDenyCorporateEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2453,12 +2345,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2486,18 +2373,6 @@ public function testMethodUpdateDenyDisposableEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2536,12 +2411,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2569,18 +2439,6 @@ public function testMethodUpdateDenyFreeEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2619,12 +2477,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2652,18 +2505,6 @@ public function testMethodUpdateMembershipPrivacyPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2702,12 +2543,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2733,18 +2569,6 @@ public function testMethodUpdateMFAFactorsPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2783,12 +2607,7 @@ public function testMethodUpdateMFAFactorsPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2814,18 +2633,6 @@ public function testMethodUpdatePasskeyPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2864,12 +2671,7 @@ public function testMethodUpdatePasskeyPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2897,18 +2699,6 @@ public function testMethodUpdatePasswordDictionaryPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2947,12 +2737,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2980,18 +2765,6 @@ public function testMethodUpdatePasswordHistoryPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3030,12 +2803,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3063,18 +2831,6 @@ public function testMethodUpdatePasswordPersonalDataPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3113,12 +2869,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3146,7 +2897,6 @@ public function testMethodUpdatePasswordPwnedPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3185,12 +2935,7 @@ public function testMethodUpdatePasswordPwnedPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3216,7 +2961,6 @@ public function testMethodUpdatePasswordRotationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3255,12 +2999,7 @@ public function testMethodUpdatePasswordRotationPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3308,18 +3047,6 @@ public function testMethodUpdateSessionAlertPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3358,12 +3085,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3391,18 +3113,6 @@ public function testMethodUpdateSessionDurationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3441,12 +3151,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3474,18 +3179,6 @@ public function testMethodUpdateSessionInvalidationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3524,12 +3217,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3557,18 +3245,6 @@ public function testMethodUpdateSessionLimitPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3607,12 +3283,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3640,18 +3311,6 @@ public function testMethodUpdateUserLimitPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3690,12 +3349,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3749,18 +3403,6 @@ public function testMethodUpdateProtocol(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3799,12 +3441,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3833,18 +3470,6 @@ public function testMethodUpdateService(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3883,12 +3508,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3917,18 +3537,6 @@ public function testMethodUpdateSMTP(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3967,12 +3575,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" diff --git a/tests/Appwrite/Services/SitesTest.php b/tests/Appwrite/Services/SitesTest.php index 1dd5e5aa..0b0f8581 100644 --- a/tests/Appwrite/Services/SitesTest.php +++ b/tests/Appwrite/Services/SitesTest.php @@ -829,7 +829,7 @@ public function testMethodListLogs(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ] ] ]; @@ -877,7 +877,7 @@ public function testMethodGetLog(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client diff --git a/tests/Appwrite/Services/TablesDBTest.php b/tests/Appwrite/Services/TablesDBTest.php index 51b883a9..5ef55c32 100644 --- a/tests/Appwrite/Services/TablesDBTest.php +++ b/tests/Appwrite/Services/TablesDBTest.php @@ -82,6 +82,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -90,13 +94,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -321,16 +319,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -340,6 +334,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -353,7 +349,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -613,10 +609,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1651,6 +1643,39 @@ public function testMethodCreateRelationshipColumn(): void $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); } + public function testMethodUpdateRelationshipColumn(): void + { + $data = [ + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "relatedTable" => "table", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->tablesDB->updateRelationshipColumn( + "", + "", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); + } public function testMethodCreateStringColumn(): void { $data = [ @@ -1939,39 +1964,6 @@ public function testMethodDeleteColumn(): void $this->assertSame($data, $response); } - public function testMethodUpdateRelationshipColumn(): void - { - $data = [ - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "relatedTable" => "table", - "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", - "twoWay" => true, - "twoWayKey" => "string", - "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child" - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->tablesDB->updateRelationshipColumn( - "", - "", - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); - } public function testMethodListIndexes(): void { $data = [ diff --git a/tests/Appwrite/Services/UsersTest.php b/tests/Appwrite/Services/UsersTest.php index 4179bae7..34677d39 100644 --- a/tests/Appwrite/Services/UsersTest.php +++ b/tests/Appwrite/Services/UsersTest.php @@ -224,7 +224,8 @@ public function testMethodListIdentities(): void "providerEmail" => "user@example.com", "providerAccessToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", "providerAccessTokenExpiry" => "2020-10-15T06:38:00.000+00:00", - "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3" + "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerIdToken" => "eyJhbGciOiJSUzI1NiIsImtpZCI6IjBhYzNmMWQwNWExYjhlN2YifQ.eyJzdWIiOiIxMTAxNjk0ODQ0NzQzODYyNzYzMzQifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ] ] ]; @@ -719,51 +720,6 @@ public function testMethodUpdateLabels(): void $this->assertInstanceOf(\Appwrite\Models\User::class, $response); } - public function testMethodListLogs(): void - { - $data = [ - "total" => 5, - "logs" => [ - [ - "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->users->listLogs( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } public function testMethodListMemberships(): void { $data = [ diff --git a/tests/Appwrite/Services/VectorsDBTest.php b/tests/Appwrite/Services/VectorsDBTest.php index fdb22e76..70fb88c4 100644 --- a/tests/Appwrite/Services/VectorsDBTest.php +++ b/tests/Appwrite/Services/VectorsDBTest.php @@ -81,6 +81,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -89,13 +93,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -950,16 +948,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -969,6 +963,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -982,7 +978,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1076,10 +1072,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, From ee0e0e633d7c132e6a9b5fa57cb36696ac23dfa3 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 14 Oct 2026 18:20:23 +0100 Subject: [PATCH 2/4] feat: SDK update for the 2.5.x majors --- CHANGELOG.md | 15 + README.md | 31 +- composer.json | 1 + docs/account.md | 22 +- docs/apps.md | 2 +- docs/avatars.md | 4 +- docs/databases.md | 4 +- docs/documentsdb.md | 2 +- docs/examples/account/list-logs.md | 18 - docs/examples/avatars/get-screenshot.md | 3 +- docs/examples/databases/create-documents.md | 11 +- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/delete-documents.md | 2 +- docs/examples/databases/upsert-documents.md | 11 +- docs/examples/documentsdb/create-documents.md | 11 +- docs/examples/documentsdb/create-index.md | 2 +- docs/examples/documentsdb/delete-documents.md | 2 +- docs/examples/documentsdb/upsert-documents.md | 11 +- .../embeddings/create-text-embeddings.md | 2 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/oauth2/approve.md | 4 +- docs/examples/oauth2/authorize-post.md | 6 +- docs/examples/oauth2/authorize.md | 6 +- .../oauth2/create-device-authorization.md | 6 +- docs/examples/oauth2/create-grant.md | 4 +- docs/examples/oauth2/create-par.md | 6 +- docs/examples/oauth2/create-token.md | 6 +- docs/examples/oauth2/get-grant.md | 4 +- docs/examples/oauth2/list-organizations.md | 4 +- docs/examples/oauth2/list-projects.md | 4 +- docs/examples/oauth2/reject.md | 4 +- docs/examples/oauth2/revoke.md | 4 +- docs/examples/organization/create-key.md | 21 - docs/examples/organization/delete-key.md | 17 - docs/examples/organization/get-key.md | 17 - docs/examples/organization/list-keys.md | 18 - docs/examples/organization/update-key.md | 21 - docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 2 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 2 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/create-rows.md | 11 +- docs/examples/tablesdb/delete-rows.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 11 +- docs/examples/teams/create-membership.md | 2 +- docs/examples/teams/update-membership.md | 2 +- docs/examples/users/list-logs.md | 19 - docs/examples/users/update-labels.md | 2 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-documents.md | 15 +- docs/examples/vectorsdb/create-index.md | 2 +- docs/examples/vectorsdb/create-operations.md | 10 +- docs/examples/vectorsdb/delete-documents.md | 2 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 15 +- docs/examples/webhooks/create.md | 2 +- docs/examples/webhooks/update.md | 2 +- docs/messaging.md | 14 +- docs/mongo.md | 6 +- docs/mysql.md | 6 +- docs/oauth2.md | 10 +- docs/organization.md | 74 +- docs/postgresql.md | 6 +- docs/project.md | 12 +- docs/proxy.md | 4 +- docs/storage.md | 2 +- docs/tablesdb.md | 42 +- docs/teams.md | 2 +- docs/users.md | 19 +- docs/vectorsdb.md | 2 +- docs/webhooks.md | 8 +- src/Appwrite/Client.php | 33 +- src/Appwrite/Enums/BillingPlanGroup.php | 8 - src/Appwrite/Enums/OrganizationKeyScopes.php | 162 ---- src/Appwrite/Models/ActivityEventList.php | 5 +- src/Appwrite/Models/App.php | 5 +- src/Appwrite/Models/AppInstallationList.php | 5 +- src/Appwrite/Models/AppKeyList.php | 5 +- src/Appwrite/Models/AppScopeList.php | 5 +- src/Appwrite/Models/AppSecretList.php | 5 +- src/Appwrite/Models/AppsList.php | 5 +- src/Appwrite/Models/AttributeEnum.php | 4 +- src/Appwrite/Models/AttributeList.php | 5 +- src/Appwrite/Models/BackupArchive.php | 27 +- src/Appwrite/Models/BackupArchiveList.php | 5 +- src/Appwrite/Models/BackupPolicy.php | 9 +- src/Appwrite/Models/BackupPolicyList.php | 5 +- src/Appwrite/Models/BackupRestoration.php | 24 +- src/Appwrite/Models/BackupRestorationList.php | 5 +- src/Appwrite/Models/BillingPlan.php | 16 +- src/Appwrite/Models/Block.php | 42 +- src/Appwrite/Models/BucketList.php | 5 +- src/Appwrite/Models/Collection.php | 13 +- src/Appwrite/Models/CollectionList.php | 5 +- src/Appwrite/Models/ColumnEnum.php | 4 +- src/Appwrite/Models/ColumnIndexList.php | 5 +- src/Appwrite/Models/ColumnList.php | 5 +- src/Appwrite/Models/ContinentList.php | 5 +- src/Appwrite/Models/CountryList.php | 5 +- src/Appwrite/Models/CurrencyList.php | 5 +- src/Appwrite/Models/Database.php | 2 +- src/Appwrite/Models/DatabaseList.php | 5 +- src/Appwrite/Models/DatabaseMigrationList.php | 5 +- src/Appwrite/Models/DatabaseStatus.php | 18 +- src/Appwrite/Models/DedicatedDatabase.php | 55 +- .../Models/DedicatedDatabaseBackupList.php | 5 +- .../Models/DedicatedDatabaseBranch.php | 14 +- .../Models/DedicatedDatabaseBranchList.php | 5 +- .../Models/DedicatedDatabaseExecution.php | 5 +- .../Models/DedicatedDatabaseExtensions.php | 5 +- src/Appwrite/Models/DedicatedDatabaseList.php | 5 +- .../Models/DedicatedDatabaseOperationList.php | 5 +- .../Models/DedicatedDatabaseReplicas.php | 5 +- .../Models/DedicatedDatabaseRestoration.php | 50 +- .../DedicatedDatabaseRestorationList.php | 5 +- .../Models/DedicatedDatabaseSpecification.php | 32 +- .../DedicatedDatabaseSpecificationList.php | 18 +- .../DedicatedDatabaseSpecificationPricing.php | 70 -- src/Appwrite/Models/DeploymentList.php | 5 +- src/Appwrite/Models/DevKey.php | 98 --- src/Appwrite/Models/Document.php | 5 +- src/Appwrite/Models/DocumentList.php | 5 +- src/Appwrite/Models/EmailTemplateList.php | 5 +- src/Appwrite/Models/EmbeddingList.php | 5 +- src/Appwrite/Models/EphemeralKey.php | 5 +- src/Appwrite/Models/Execution.php | 14 +- src/Appwrite/Models/ExecutionList.php | 5 +- src/Appwrite/Models/FileList.php | 5 +- src/Appwrite/Models/Framework.php | 9 +- src/Appwrite/Models/FrameworkList.php | 5 +- src/Appwrite/Models/FunctionList.php | 5 +- src/Appwrite/Models/FunctionModel.php | 5 +- src/Appwrite/Models/Identity.php | 7 +- src/Appwrite/Models/IdentityList.php | 5 +- src/Appwrite/Models/IndexList.php | 5 +- src/Appwrite/Models/Insight.php | 5 +- src/Appwrite/Models/InsightList.php | 5 +- src/Appwrite/Models/Key.php | 5 +- src/Appwrite/Models/KeyList.php | 5 +- src/Appwrite/Models/LanguageList.php | 5 +- src/Appwrite/Models/LocaleCodeList.php | 5 +- src/Appwrite/Models/Log.php | 196 ----- src/Appwrite/Models/LogList.php | 61 -- src/Appwrite/Models/MembershipList.php | 5 +- src/Appwrite/Models/Message.php | 13 +- src/Appwrite/Models/MessageList.php | 5 +- src/Appwrite/Models/MockNumberList.php | 5 +- src/Appwrite/Models/OAuth2Apple.php | 14 +- src/Appwrite/Models/OAuth2Auth0.php | 23 +- src/Appwrite/Models/OAuth2Discord.php | 19 +- src/Appwrite/Models/OAuth2Github.php | 19 +- src/Appwrite/Models/OAuth2Google.php | 14 +- src/Appwrite/Models/OAuth2Microsoft.php | 23 +- src/Appwrite/Models/OAuth2Oidc.php | 16 +- src/Appwrite/Models/OAuth2Okta.php | 25 +- src/Appwrite/Models/OAuth2ProviderList.php | 5 +- src/Appwrite/Models/OAuth2Salesforce.php | 19 +- src/Appwrite/Models/OAuth2Zoho.php | 19 +- src/Appwrite/Models/Oauth2ConsentList.php | 5 +- .../Models/Oauth2ConsentTokenList.php | 5 +- .../Models/Oauth2OrganizationList.php | 5 +- src/Appwrite/Models/Oauth2ProjectList.php | 5 +- src/Appwrite/Models/Organization.php | 63 +- src/Appwrite/Models/Passkey.php | 22 +- src/Appwrite/Models/PasskeyChallenge.php | 22 +- src/Appwrite/Models/PasskeyList.php | 10 +- src/Appwrite/Models/PhoneList.php | 5 +- src/Appwrite/Models/PlatformAndroid.php | 7 +- src/Appwrite/Models/PlatformList.php | 5 +- src/Appwrite/Models/PolicyList.php | 5 +- src/Appwrite/Models/PolicyPasskey.php | 14 +- src/Appwrite/Models/Presence.php | 5 +- src/Appwrite/Models/PresenceList.php | 5 +- src/Appwrite/Models/Project.php | 29 +- src/Appwrite/Models/ProjectList.php | 5 +- src/Appwrite/Models/ProviderList.php | 5 +- src/Appwrite/Models/ProxyRule.php | 2 +- src/Appwrite/Models/ProxyRuleList.php | 5 +- src/Appwrite/Models/Report.php | 5 +- src/Appwrite/Models/ReportList.php | 5 +- src/Appwrite/Models/ResourceTokenList.php | 5 +- src/Appwrite/Models/Row.php | 5 +- src/Appwrite/Models/RowList.php | 5 +- src/Appwrite/Models/Runtime.php | 5 +- src/Appwrite/Models/RuntimeList.php | 5 +- src/Appwrite/Models/SessionList.php | 5 +- src/Appwrite/Models/Site.php | 4 +- src/Appwrite/Models/SiteList.php | 5 +- src/Appwrite/Models/SpecificationList.php | 5 +- src/Appwrite/Models/SubscriberList.php | 5 +- src/Appwrite/Models/Table.php | 13 +- src/Appwrite/Models/TableList.php | 5 +- src/Appwrite/Models/TargetList.php | 5 +- src/Appwrite/Models/TeamList.php | 5 +- src/Appwrite/Models/TokenSecret.php | 26 +- src/Appwrite/Models/Topic.php | 2 +- src/Appwrite/Models/TopicList.php | 5 +- src/Appwrite/Models/TransactionList.php | 5 +- src/Appwrite/Models/UsageBillingPlan.php | 72 +- src/Appwrite/Models/User.php | 4 +- src/Appwrite/Models/UserList.php | 5 +- src/Appwrite/Models/VariableList.php | 5 +- src/Appwrite/Models/VectorsdbCollection.php | 13 +- .../Models/VectorsdbCollectionList.php | 5 +- src/Appwrite/Models/Webhook.php | 2 +- src/Appwrite/Models/WebhookList.php | 5 +- src/Appwrite/ResolvedTopic.php | 43 + src/Appwrite/Services/Account.php | 100 ++- src/Appwrite/Services/Activities.php | 4 + src/Appwrite/Services/Advisor.php | 21 + src/Appwrite/Services/Apps.php | 100 +++ src/Appwrite/Services/Avatars.php | 6 +- src/Appwrite/Services/Backups.php | 24 + src/Appwrite/Services/Databases.php | 664 ++++++++++++++- src/Appwrite/Services/DocumentsDB.php | 253 +++++- src/Appwrite/Services/Functions.php | 131 ++- src/Appwrite/Services/Messaging.php | 125 ++- src/Appwrite/Services/Mongo.php | 149 +++- src/Appwrite/Services/Mysql.php | 161 +++- src/Appwrite/Services/Oauth2.php | 14 +- src/Appwrite/Services/Organization.php | 222 +---- src/Appwrite/Services/Postgresql.php | 177 +++- src/Appwrite/Services/Presences.php | 17 + src/Appwrite/Services/Project.php | 77 +- src/Appwrite/Services/Proxy.php | 15 + src/Appwrite/Services/Sites.php | 131 ++- src/Appwrite/Services/Storage.php | 88 +- src/Appwrite/Services/TablesDB.php | 794 +++++++++++++++++- src/Appwrite/Services/Teams.php | 94 +++ src/Appwrite/Services/Tokens.php | 29 + src/Appwrite/Services/Users.php | 210 +++-- src/Appwrite/Services/VectorsDB.php | 234 +++++- src/Appwrite/Services/Webhooks.php | 22 +- src/Appwrite/Topic.php | 144 ++++ tests/Appwrite/ClientTest.php | 83 +- tests/Appwrite/Services/AccountTest.php | 46 +- tests/Appwrite/Services/BackupsTest.php | 17 +- tests/Appwrite/Services/DocumentsDBTest.php | 24 +- tests/Appwrite/Services/FunctionsTest.php | 6 +- tests/Appwrite/Services/MongoTest.php | 114 +-- tests/Appwrite/Services/MysqlTest.php | 114 +-- tests/Appwrite/Services/Oauth2Test.php | 4 +- tests/Appwrite/Services/OrganizationTest.php | 361 +------- tests/Appwrite/Services/PostgresqlTest.php | 130 +-- tests/Appwrite/Services/ProjectTest.php | 499 ++--------- tests/Appwrite/Services/SitesTest.php | 4 +- tests/Appwrite/Services/TablesDBTest.php | 90 +- tests/Appwrite/Services/UsersTest.php | 48 +- tests/Appwrite/Services/VectorsDBTest.php | 24 +- tests/Appwrite/TopicTest.php | 68 ++ 254 files changed, 4716 insertions(+), 3515 deletions(-) delete mode 100644 docs/examples/account/list-logs.md delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/delete-key.md delete mode 100644 docs/examples/organization/get-key.md delete mode 100644 docs/examples/organization/list-keys.md delete mode 100644 docs/examples/organization/update-key.md delete mode 100644 docs/examples/users/list-logs.md delete mode 100644 src/Appwrite/Enums/OrganizationKeyScopes.php delete mode 100644 src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php delete mode 100644 src/Appwrite/Models/DevKey.php delete mode 100644 src/Appwrite/Models/Log.php delete mode 100644 src/Appwrite/Models/LogList.php create mode 100644 src/Appwrite/ResolvedTopic.php create mode 100644 src/Appwrite/Topic.php create mode 100644 tests/Appwrite/TopicTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 7353dbb9..36a0bfa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Change Log +## 31.0.0 + +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `Account::listLogs`, `Users::listLogs` and the `Log`/`LogList` models +* Breaking: removed `Organization::createKey`, `listKeys`, `updateKey` and `OrganizationKeyScopes`; use project keys +* Breaking: removed `Client::setDevKey`, the `DevKey` model and `Project::$devKeys` +* Breaking: removed `BillingPlanGroup::STARTER()` +* Breaking: removed the `DedicatedDatabaseSpecificationPricing` model and `DedicatedDatabaseSpecificationList::$pricing` +* Breaking: removed `Block` fields `reason`, `projectName`, `region`, `organizationName`, `organizationId` and `billingPlan` +* Breaking: OAuth2 `resource` params now take `?array` +* Breaking: `Project::updateOAuth2Kakao` takes `$enabled` before `$prompt` +* Breaking: `BackupRestoration::$options` is now an array +* Breaking: some response fields became nullable, such as `BillingPlan::$usage` and `DedicatedDatabase::$engine` +* Added: `Topic` helper to build MQTT topics for push messages + ## 30.4.0 * Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones diff --git a/README.md b/README.md index bd76997b..b1df143c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square&v=1) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 1.9.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-php/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-php/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -22,6 +22,33 @@ composer require appwrite/appwrite Requires PHP 8.5 or later. +### Custom HTTP transport + +For applications that configure their own HTTP transport, pass any PSR-18 client to the constructor. Hosts that run SDK calls concurrently, such as Swoole coroutines, should pass a pooled client so no cURL handle is shared between coroutines: + +```php +use Appwrite\Client; +use Utopia\Client\Adapter\SwooleCoroutine\Client as SwooleAdapter; +use Utopia\Client\Client as HttpClient; +use Utopia\Client\Pool as PooledClient; +use Utopia\Pools\Adapter\Swoole as SwoolePool; +use Utopia\Pools\Pool; + +$client = new Client(new PooledClient(new Pool( + new SwoolePool(), + 'appwrite', + 128, + fn (): HttpClient => new HttpClient(new SwooleAdapter()) + ->withConnectionReuse() + ->withTimeout(5) + ->withConnectTimeout(2), + timeout: 3.0, +))); +$client->setEndpoint('https://cloud.appwrite.io/v1'); +``` + +Configure timeouts, TLS, redirects, and connection reuse on the injected transport. The SDK's `setTimeout()`, `setConnectTimeout()`, and `setSelfSigned()` methods only configure the default cURL transport. Endpoint, authentication, headers, request encoding, and response handling remain the SDK's responsibility. A transport used with `responseType: 'location'` must have redirect following disabled. + ## Getting Started diff --git a/composer.json b/composer.json index 21faff5f..135f6928 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "php": ">=8.5", "ext-curl": "*", "ext-json": "*", + "psr/http-client": "^1.0", "utopia-php/client": "^0.6", "adhocore/jwt": "^1.1" }, diff --git a/docs/account.md b/docs/account.md index 80e592a5..efbee573 100644 --- a/docs/account.md +++ b/docs/account.md @@ -150,20 +150,6 @@ DELETE https://cloud.appwrite.io/v1/account/identities/{identityId} | identityId | string | **Required** Identity ID. | | -```http request -GET https://cloud.appwrite.io/v1/account/logs -``` - -** Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. ** - -### 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). 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 PATCH https://cloud.appwrite.io/v1/account/mfa ``` @@ -591,7 +577,7 @@ GET https://cloud.appwrite.io/v1/account/sessions DELETE https://cloud.appwrite.io/v1/account/sessions ``` -** Delete all sessions from the user account and remove any sessions cookies from the end client. ** +** Delete all sessions from the user account and remove any sessions cookies from the end client. Pass `current` as false to keep the session making the request and sign out of every other session. ** ### Parameters @@ -611,7 +597,7 @@ POST https://cloud.appwrite.io/v1/account/sessions/anonymous POST https://cloud.appwrite.io/v1/account/sessions/email ``` -** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. +** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. Use the optional `duration` parameter to create a shorter session, for example when the user doesn't choose "remember me". It must be at least 60 seconds and cannot exceed the project maximum session length. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). ** @@ -786,13 +772,15 @@ GET https://cloud.appwrite.io/v1/account/tokens/oauth2/{provider} If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. +If there is already an active session, the OAuth2 identity is attached to the logged-in account and that session stays active until the token is exchanged for a new one. + A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). ** ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| provider | string | **Required** OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, 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, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, 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/apps.md b/docs/apps.md index fde01429..60c5d7f5 100644 --- a/docs/apps.md +++ b/docs/apps.md @@ -242,7 +242,7 @@ PUT https://cloud.appwrite.io/v1/apps/{appId}/labels | Field Name | Type | Description | Default | | --- | --- | --- | --- | | appId | string | **Required** Application unique ID. | | -| labels | array | Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | | +| labels | array | Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. Reserved labels are rejected. | | ```http request diff --git a/docs/avatars.md b/docs/avatars.md index 7b9377d2..d5713014 100644 --- a/docs/avatars.md +++ b/docs/avatars.md @@ -116,7 +116,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre GET https://cloud.appwrite.io/v1/avatars/photo ``` -** Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. +** Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: a custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. Passing `userId` — `current()` for the authenticated user — resolves the photo from everything known about that user: identity photos, email, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. ** @@ -186,7 +186,7 @@ When width and height are specified, the image is resized accordingly. If both d | Field Name | Type | Description | Default | | --- | --- | --- | --- | | url | string | **Required** Website URL which you want to capture. | | -| headers | object | HTTP headers to send with the browser request. Defaults to empty. | {} | +| headers | object | HTTP headers to send with the browser request. Only Accept and Accept-Language are allowed. Defaults to empty. | {} | | viewportWidth | integer | Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. | 1280 | | viewportHeight | integer | Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. | 720 | | scale | number | Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. | 1 | diff --git a/docs/databases.md b/docs/databases.md index 1b1f7bf6..042e19e4 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -188,7 +188,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections | documentSecurity | boolean | Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. | 1 | | attributes | array | Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. | [] | -| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | +| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | ```http request @@ -1210,7 +1210,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection ``` ** Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. -Attributes can be `key`, `fulltext`, and `unique`. ** +Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use an index. ** ### Parameters diff --git a/docs/documentsdb.md b/docs/documentsdb.md index 4f650b12..24756cc1 100644 --- a/docs/documentsdb.md +++ b/docs/documentsdb.md @@ -38,7 +38,7 @@ POST https://cloud.appwrite.io/v1/documentsdb GET https://cloud.appwrite.io/v1/documentsdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 17e51352..00000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,18 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with - -$account = new Account($client); - -$result = $account->listLogs( - queries: [], // optional - total: false // optional -); -``` diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 59fbd663..a5eb5e99 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -18,8 +18,7 @@ $avatars = new Avatars($client); $result = $avatars->getScreenshot( url: 'https://example.com', headers: [ - 'Authorization' => 'Bearer token123', - 'X-Custom-Header' => 'value' + 'Accept-Language' => 'en-US,en;q=0.9' ], // optional viewportWidth: 1920, // optional viewportHeight: 1080, // optional diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 1f64387b..de0fae2b 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -14,7 +14,16 @@ $databases = new Databases($client); $result = $databases->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 1005239e..cd5e8c0c 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -18,7 +18,7 @@ $result = $databases->createIndex( collectionId: '', key: '', type: DatabasesIndexType::KEY(), - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index f39cbfe0..5d586039 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -14,7 +14,7 @@ $databases = new Databases($client); $result = $databases->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 0049fdc6..60877dc3 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -14,7 +14,16 @@ $databases = new Databases($client); $result = $databases->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index ec6a4355..ce85177c 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -14,7 +14,16 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index b64d1f8a..68506db4 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -18,7 +18,7 @@ $result = $documentsDB->createIndex( collectionId: '', key: '', type: DocumentsDBIndexType::KEY(), - attributes: [], + attributes: ["username"], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index b77b3756..f005fea3 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -14,7 +14,7 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index 09021e0a..95ed28a7 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -14,7 +14,16 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 70f0f7e1..476f9741 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -13,7 +13,7 @@ $client = (new Client()) $embeddings = new Embeddings($client); $result = $embeddings->createTextEmbeddings( - texts: [], + texts: ["Appwrite helps developers build applications.", "Find documents with semantic search."], model: EmbeddingModel::NOMICEMBEDTEXT() // optional ); ``` diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index c2f1b989..26792681 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -12,6 +12,8 @@ $client = (new Client()) $graphql = new Graphql($client); $result = $graphql->mutation( - query: [] + query: [ + 'query' => 'mutation { accountUpdateName(name: "Walter") { name } }' + ] ); ``` diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 9731e998..f5e562c1 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -12,6 +12,8 @@ $client = (new Client()) $graphql = new Graphql($client); $result = $graphql->query( - query: [] + query: [ + 'query' => 'query { localeGet { ip } }' + ] ); ``` diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 568d28d9..4f96e8ac 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -14,7 +14,7 @@ $messaging = new Messaging($client); $result = $messaging->createTwilioProvider( providerId: '', name: '', - from: '+12065550100', // optional + from: '', // optional accountSid: '', // optional authToken: '', // optional enabled: false // optional diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 5540b110..2a9f07aa 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index d7a465ad..a99f3604 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->authorizePost( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '' // optional ); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index ad373715..3765b5a3 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->authorize( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '' // optional ); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index 00358d8a..6385a1a1 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -15,7 +15,7 @@ $result = $oauth2->createDeviceAuthorization( clientId: '', // optional scope: '', // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 95467652..a0328e69 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index ddb3d7d6..9c57b1df 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->createPAR( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index a4be2d6f..8ec9d22f 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -20,7 +20,7 @@ $result = $oauth2->createToken( clientSecret: '', // optional codeVerifier: '', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index a6469c30..d83efe8f 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index 49c1f499..7237c3f8 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 3bbcf901..9abc1548 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index bd98d721..0cc9cf7f 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 7122ed7f..1e823003 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index c7cb7dde..00000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,21 +0,0 @@ -```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->createKey( - keyId: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTSREAD()], - expire: '2020-10-15T06:38:00.000+00:00' // optional -); -``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/organization/delete-key.md deleted file mode 100644 index ca72f3dd..00000000 --- a/docs/examples/organization/delete-key.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 - -$organization = new Organization($client); - -$result = $organization->deleteKey( - keyId: '' -); -``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/organization/get-key.md deleted file mode 100644 index bf651e9e..00000000 --- a/docs/examples/organization/get-key.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 - -$organization = new Organization($client); - -$result = $organization->getKey( - keyId: '' -); -``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/organization/list-keys.md deleted file mode 100644 index dbe27502..00000000 --- a/docs/examples/organization/list-keys.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 - -$organization = new Organization($client); - -$result = $organization->listKeys( - queries: [], // optional - total: false // optional -); -``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index 575e6119..00000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,21 +0,0 @@ -```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->updateKey( - keyId: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTSREAD()], - expire: '2020-10-15T06:38:00.000+00:00' // optional -); -``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 224dc841..763800e6 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -13,7 +13,7 @@ $client = (new Client()) $project = new Project($client); $result = $project->createEphemeralKey( - scopes: [ProjectKeyScopes::PROJECTREAD()], + scopes: [ProjectKeyScopes::USERSREAD()], duration: 600 ); ``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index a16026a8..e0045750 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -12,6 +12,6 @@ $client = (new Client()) $project = new Project($client); $result = $project->createSMTPTest( - emails: [] + emails: ["recipient@example.com"] ); ``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index db883945..ae2996b7 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -15,7 +15,7 @@ $project = new Project($client); $result = $project->updateKey( keyId: '', name: '', - scopes: [ProjectKeyScopes::PROJECTREAD()], + scopes: [ProjectKeyScopes::USERSREAD()], expire: '2020-10-15T06:38:00.000+00:00' // optional ); ``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index aace3165..1aba5430 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -12,6 +12,6 @@ $client = (new Client()) $project = new Project($client); $result = $project->updateLabels( - labels: [] + labels: ["production"] ); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index 78fe1cbd..7f88288e 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -15,7 +15,7 @@ $project = new Project($client); $result = $project->updateOAuth2Kakao( clientId: '', // optional clientSecret: '', // optional - prompt: [ProjectOAuth2KakaoPrompt::NONE()], // optional - enabled: false // optional + enabled: false, // optional + prompt: [ProjectOAuth2KakaoPrompt::NONE()] // optional ); ``` diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 2b840eb3..89e4650c 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -18,7 +18,7 @@ $result = $tablesDB->createIndex( tableId: '', key: '', type: TablesDBIndexType::KEY(), - columns: [], + columns: ["username"], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 6ae0f802..240ddc08 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -14,7 +14,16 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->createRows( databaseId: '', tableId: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 2b13b6c7..192f5276 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -14,7 +14,7 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->deleteRows( databaseId: '', tableId: '', - queries: [], // optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index 56aa2657..6150f35e 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -14,7 +14,16 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->upsertRows( databaseId: '', tableId: '', - rows: [], + rows: [ + { + "$id": "example1", + "username": "walter.obrien", + "email": "walter.obrien@example.com", + "fullName": "Walter O'Brien", + "age": 30, + "isAdmin": false + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index cd9524a7..01879bde 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -13,7 +13,7 @@ $teams = new Teams($client); $result = $teams->createMembership( teamId: '', - roles: [], + roles: ["editor"], email: 'email@example.com', // optional userId: '', // optional phone: '+12065550100', // optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 87741774..3cdab5a0 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -14,6 +14,6 @@ $teams = new Teams($client); $result = $teams->updateMembership( teamId: '', membershipId: '', - roles: [] + roles: ["editor"] ); ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/users/list-logs.md deleted file mode 100644 index b050bab0..00000000 --- a/docs/examples/users/list-logs.md +++ /dev/null @@ -1,19 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$users = new Users($client); - -$result = $users->listLogs( - userId: '', - queries: [], // optional - total: false // optional -); -``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 7ac457f5..b8e573c1 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -13,6 +13,6 @@ $users = new Users($client); $result = $users->updateLabels( userId: '', - labels: [] + labels: ["subscriber"] ); ``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index c3ed6628..3bbdb076 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -17,7 +17,7 @@ $result = $vectorsDB->createCollection( databaseId: '', collectionId: '', name: '', - dimension: 1, + dimension: 4, permissions: [Permission::read(Role::any())], // optional documentSecurity: false, // optional enabled: false // optional diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 2d1c9c2f..054d3b35 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -14,7 +14,20 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index d3e699cb..369f018b 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -18,7 +18,7 @@ $result = $vectorsDB->createIndex( collectionId: '', key: '', type: VectorsDBIndexType::HNSWEUCLIDEAN(), - attributes: [], + attributes: ["embeddings"], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index c311d5e4..fa3d9769 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -20,7 +20,15 @@ $result = $vectorsDB->createOperations( "collectionId": "", "documentId": "", "data": { - "name": "Walter O'Brien" + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } } } ] // optional diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index 17b0831d..fbca7fd4 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -14,7 +14,7 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: ["{\"method\":\"equal\", \"attribute\":\"$id\", \"values\":[\"\"]}"], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 7898ee03..d9815b61 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -17,7 +17,7 @@ $result = $vectorsDB->updateCollection( databaseId: '', collectionId: '', name: '', - dimension: 1, // optional + dimension: 4, // optional permissions: [Permission::read(Role::any())], // optional documentSecurity: false, // optional enabled: false // optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index 11e5d31f..516b6878 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -14,7 +14,20 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + { + "$id": "example1", + "embeddings": [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + "metadata": { + "name": "First document" + } + } + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 2b437a54..536657d0 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -15,7 +15,7 @@ $result = $webhooks->create( webhookId: '', url: 'https://example.com/webhook', name: '', - events: [], + events: ["users.*.create"], enabled: false, // optional tls: false, // optional authUsername: '', // optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 95dafcf0..7ea370e9 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -15,7 +15,7 @@ $result = $webhooks->update( webhookId: '', name: '', url: 'https://example.com/webhook', - events: [], + events: ["users.*.create"], enabled: false, // optional tls: false, // optional authUsername: '', // optional diff --git a/docs/messaging.md b/docs/messaging.md index e2d897da..5dbed35d 100644 --- a/docs/messaging.md +++ b/docs/messaging.md @@ -11,7 +11,7 @@ GET https://cloud.appwrite.io/v1/messaging/messages | 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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType | [] | +| 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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType, users, targets | [] | | 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 | @@ -363,7 +363,7 @@ POST https://cloud.appwrite.io/v1/messaging/providers/appwrite | name | string | Provider name. | | | enabled | boolean | Set as enabled. | | | qos | integer | Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. | | -| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. | | ```http request @@ -380,7 +380,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/providers/appwrite/{providerId} | name | string | Provider name. | | | enabled | boolean | Set as enabled. | | | qos | integer | Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. | | -| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. | | ```http request @@ -839,7 +839,7 @@ POST https://cloud.appwrite.io/v1/messaging/providers/twilio | --- | --- | --- | --- | | providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | name | string | Provider name. | | -| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| from | string | Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. | | | accountSid | string | Twilio account secret ID. | | | authToken | string | Twilio authentication token. | | | enabled | boolean | Set as enabled. | | @@ -860,7 +860,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/providers/twilio/{providerId} | enabled | boolean | Set as enabled. | | | accountSid | string | Twilio account secret ID. | | | authToken | string | Twilio authentication token. | | -| from | string | Sender number. | | +| from | string | Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. | | ```http request @@ -955,7 +955,7 @@ POST https://cloud.appwrite.io/v1/messaging/topics | name | string | Topic Name. | | | subscribe | array | An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | ["users"] | | qos | integer | MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. | | -| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. | | ```http request @@ -987,7 +987,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/topics/{topicId} | name | string | Topic Name. | | | subscribe | array | An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | | | qos | integer | MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. | | -| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. | | ```http request diff --git a/docs/mongo.md b/docs/mongo.md index 084c9fca..b1b6fcec 100644 --- a/docs/mongo.md +++ b/docs/mongo.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/mongo | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/mongo/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/mysql.md b/docs/mysql.md index ced7ecea..ceee8070 100644 --- a/docs/mysql.md +++ b/docs/mysql.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/mysql | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/mysql/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/oauth2.md b/docs/oauth2.md index 46c3bc67..e9928cbf 100644 --- a/docs/oauth2.md +++ b/docs/oauth2.md @@ -39,7 +39,7 @@ GET https://cloud.appwrite.io/v1/oauth2/{project_id}/authorize | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | | request_uri | string | OAuth2 authorization request handle returned by the pushed authorization request endpoint. | | @@ -66,7 +66,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/authorize | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | | request_uri | string | OAuth2 authorization request handle returned by the pushed authorization request endpoint. | | @@ -85,7 +85,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/device_authorization | client_id | string | OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. | | | scope | string | Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | @@ -172,7 +172,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/par | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age parameter for customization of consent screen. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | @@ -242,6 +242,6 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/token | client_secret | string | OAuth2 client secret. Required for confidential apps. | | | code_verifier | string | PKCE code verifier. Required for public apps. | | | redirect_uri | string | Redirect URI. Required for `authorization_code` grant type. | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | diff --git a/docs/organization.md b/docs/organization.md index dc3895c1..350a7d14 100644 --- a/docs/organization.md +++ b/docs/organization.md @@ -96,78 +96,6 @@ DELETE https://cloud.appwrite.io/v1/organization/installations/{installationId} | installationId | string | **Required** Installation unique ID. | | -```http request -GET https://cloud.appwrite.io/v1/organization/keys -``` - -** Get a list of all API keys 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: expire, accessedAt, name, scopes | [] | -| 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/keys -``` - -** Create a new organization API key. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| 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 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. | | - - -```http request -GET https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including its scopes. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | - - -```http request -PUT https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | -| name | string | Key name. Max length: 128 chars. | | -| 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. | | - - -```http request -DELETE https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | - - ```http request GET https://cloud.appwrite.io/v1/organization/memberships ``` @@ -268,7 +196,7 @@ POST https://cloud.appwrite.io/v1/organization/projects | --- | --- | --- | --- | | projectId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. | | | name | string | Project name. Max length: 128 chars. | | -| region | string | Project Region. | default | +| region | string | Project Region. | | ```http request diff --git a/docs/postgresql.md b/docs/postgresql.md index d1af41f3..e3551c8c 100644 --- a/docs/postgresql.md +++ b/docs/postgresql.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/postgresql | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/postgresql/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/project.md b/docs/project.md index add475e8..df5337f8 100644 --- a/docs/project.md +++ b/docs/project.md @@ -25,7 +25,7 @@ PATCH https://cloud.appwrite.io/v1/project/auth-methods/{methodId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| methodId | string | **Required** Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone | | +| methodId | string | **Required** Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey | | | enabled | boolean | Auth method status. | | @@ -648,8 +648,8 @@ PATCH https://cloud.appwrite.io/v1/project/oauth2/kakao | --- | --- | --- | --- | | clientId | string | 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de | | | clientSecret | string | 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled | | -| prompt | array | Array of Kakao OAuth2 prompt values. 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. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. | | | 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. | | +| prompt | array | Array of Kakao OAuth2 prompt values. 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. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. | | ```http request @@ -1104,7 +1104,7 @@ POST https://cloud.appwrite.io/v1/project/platforms/android PUT https://cloud.appwrite.io/v1/project/platforms/android/{platformId} ``` -** Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. ** +** Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. ** ### Parameters @@ -1537,7 +1537,7 @@ GET https://cloud.appwrite.io/v1/project/policies/{policyId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| policyId | string | **Required** Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. | | +| policyId | string | **Required** Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. | | ```http request @@ -1627,7 +1627,7 @@ PATCH https://cloud.appwrite.io/v1/project/templates/email | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| templateId | string | Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession | | +| templateId | string | Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery | | | locale | string | Custom email template locale. If left empty, the fallback locale (en) will be used. | | | subject | string | Subject of the email template. Can be up to 255 characters. | | | message | string | Plain or HTML body of the email template message. Can be up to 10MB of content. | | @@ -1647,7 +1647,7 @@ GET https://cloud.appwrite.io/v1/project/templates/email/{templateId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| templateId | string | **Required** Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession | | +| templateId | string | **Required** Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery | | | locale | string | Custom email template locale. If left empty, the fallback locale (en) will be used. | | diff --git a/docs/proxy.md b/docs/proxy.md index baf24feb..1ad44349 100644 --- a/docs/proxy.md +++ b/docs/proxy.md @@ -7,7 +7,9 @@ POST https://cloud.appwrite.io/v1/proxy/invalidations ** Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. -Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. ** +Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. + +Domains that route to a function do not support cache invalidation. ** ### Parameters diff --git a/docs/storage.md b/docs/storage.md index cecf8af3..e24fa98a 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -201,7 +201,7 @@ GET https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId}/previ | fileId | string | **Required** File ID | | | width | integer | Resize preview image width, Pass an integer between 0 to 4000. | 0 | | height | integer | Resize preview image height, Pass an integer between 0 to 4000. | 0 | -| gravity | string | Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right | center | +| gravity | string | Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right | center | | quality | integer | Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. | -1 | | borderWidth | integer | Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. | 0 | | borderColor | string | Preview image border color. Use a valid HEX color, no # is needed for prefix. | | diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 4f2816ef..cd9fa038 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -39,7 +39,7 @@ POST https://cloud.appwrite.io/v1/tablesdb GET https://cloud.appwrite.io/v1/tablesdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request @@ -327,7 +327,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables | rowSecurity | boolean | Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. | 1 | | columns | array | Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. | [] | -| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | +| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | ```http request @@ -911,6 +911,24 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | restrict | +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key} +``` + +** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | | +| newKey | string | New Column Key. | | + + ```http request POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/string ``` @@ -1100,24 +1118,6 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/colum | key | string | **Required** Column Key. | | -```http request -PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship -``` - -** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | | -| newKey | string | New Column Key. | | - - ```http request GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes ``` @@ -1139,7 +1139,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes ``` ** Creates an index on the columns listed. Your index should include all the columns you will query in a single request. -Type can be `key`, `fulltext`, or `unique`. ** +Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. ** ### Parameters diff --git a/docs/teams.md b/docs/teams.md index c08fa9b7..d7477399 100644 --- a/docs/teams.md +++ b/docs/teams.md @@ -28,7 +28,7 @@ POST https://cloud.appwrite.io/v1/teams | --- | --- | --- | --- | | teamId | string | Team 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 | Team name. Max length: 128 chars. | | -| roles | array | Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. | ["owner"] | +| roles | array | Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. 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. | ["owner"] | ```http request diff --git a/docs/users.md b/docs/users.md index 17e7c54d..4c70df69 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, accessedAt | [] | +| 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, passwordPwned, 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 | @@ -226,7 +226,7 @@ PATCH https://cloud.appwrite.io/v1/users/{userId}/email PATCH https://cloud.appwrite.io/v1/users/{userId}/impersonator ``` -** Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. +** Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. Account endpoints are read-only while impersonating: they report the target's account, and anything that would change it is refused, so an impersonator cannot alter the target's credentials or delete their account. ** ### Parameters @@ -268,21 +268,6 @@ Labels can be used to grant access to resources. While teams are a way for user' | labels | array | Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | | -```http request -GET https://cloud.appwrite.io/v1/users/{userId}/logs -``` - -** Get the user activity logs list by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User 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/users/{userId}/memberships ``` diff --git a/docs/vectorsdb.md b/docs/vectorsdb.md index 70da401a..d94cc7b0 100644 --- a/docs/vectorsdb.md +++ b/docs/vectorsdb.md @@ -38,7 +38,7 @@ POST https://cloud.appwrite.io/v1/vectorsdb GET https://cloud.appwrite.io/v1/vectorsdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/webhooks.md b/docs/webhooks.md index c8b7ec5c..5ed6ad59 100644 --- a/docs/webhooks.md +++ b/docs/webhooks.md @@ -31,8 +31,8 @@ POST https://cloud.appwrite.io/v1/webhooks | events | array | Events list. Maximum of 100 events are allowed. | | | enabled | boolean | Enable or disable a webhook. | 1 | | tls | boolean | Certificate verification, false for disabled or true for enabled. | | -| authUsername | string | Webhook HTTP user. Max length: 256 chars. | | -| authPassword | string | Webhook HTTP password. Max length: 256 chars. | | +| authUsername | string | Webhook HTTP user. Max length: 255 chars. | | +| authPassword | string | Webhook HTTP password. Max length: 2048 chars. | | | secret | string | Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. | | @@ -65,8 +65,8 @@ PUT https://cloud.appwrite.io/v1/webhooks/{webhookId} | events | array | Events list. Maximum of 100 events are allowed. | | | enabled | boolean | Enable or disable a webhook. | 1 | | tls | boolean | Certificate verification, false for disabled or true for enabled. | | -| authUsername | string | Webhook HTTP user. Max length: 256 chars. | | -| authPassword | string | Webhook HTTP password. Max length: 256 chars. | | +| authUsername | string | Webhook HTTP user. Max length: 255 chars. | | +| authPassword | string | Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. | | ```http request diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 7aaf3809..aad6396c 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -6,6 +6,7 @@ use Ahc\Jwt\JWT; use Psr\Http\Client\ClientExceptionInterface; +use Psr\Http\Client\ClientInterface; use Utopia\Client\Adapter\Curl\Client as CurlAdapter; use Utopia\Client\Client as HttpClient; use Utopia\Psr7\Request\Factory as RequestFactory; @@ -43,11 +44,11 @@ class Client * */ protected array $headers = [ - 'user-agent' => 'AppwritePHPSDK/30.4.0 ()', + 'user-agent' => 'AppwritePHPSDK/31.0.0 ()', 'x-sdk-name' => 'PHP', 'x-sdk-platform' => 'server', 'x-sdk-language' => 'php', - 'x-sdk-version' => '30.4.0', + 'x-sdk-version' => '31.0.0', ]; /** @@ -105,12 +106,13 @@ class Client protected RequestFactory $requestFactory; /** - * Client constructor. + * An injected PSR-18 transport owns its timeout, TLS, connection reuse and + * redirect configuration. Without one, the SDK configures its cURL client. */ - public function __construct() + public function __construct(private readonly ?ClientInterface $transport = null) { $this->requestFactory = new RequestFactory(); - $this->headers['X-Appwrite-Response-Format'] = '2.0.0'; + $this->headers['X-Appwrite-Response-Format'] = '2.5.0'; } /** @@ -233,21 +235,6 @@ public function setForwardedUserAgent(string $value): Client return $this; } - /** - * Set DevKey - * - * Your secret dev API key - * - * - */ - public function setDevKey(string $value): Client - { - $this->addHeader('X-Appwrite-Dev-Key', $value); - $this->config['devkey'] = $value; - - return $this; - } - /** * Set Cookie * @@ -578,8 +565,12 @@ protected function toMultipartParts(array $data): array return $parts; } - protected function getHttpClient(bool $followRedirects): HttpClient + protected function getHttpClient(bool $followRedirects): ClientInterface { + if ($this->transport instanceof ClientInterface) { + return $this->transport; + } + if ($followRedirects) { return $this->httpClient ??= $this->createHttpClient(true); } diff --git a/src/Appwrite/Enums/BillingPlanGroup.php b/src/Appwrite/Enums/BillingPlanGroup.php index 59b1adab..c3a69534 100644 --- a/src/Appwrite/Enums/BillingPlanGroup.php +++ b/src/Appwrite/Enums/BillingPlanGroup.php @@ -9,7 +9,6 @@ class BillingPlanGroup implements JsonSerializable, Stringable { - private static BillingPlanGroup $STARTER; private static BillingPlanGroup $FREE; private static BillingPlanGroup $START; private static BillingPlanGroup $PRO; @@ -29,12 +28,6 @@ public function jsonSerialize(): string return $this->value; } - public static function STARTER(): BillingPlanGroup - { - self::$STARTER ??= new BillingPlanGroup('starter'); - - return self::$STARTER; - } public static function FREE(): BillingPlanGroup { self::$FREE ??= new BillingPlanGroup('free'); @@ -63,7 +56,6 @@ public static function SCALE(): BillingPlanGroup public static function from(string $value): self { return match ($value) { - 'starter' => self::STARTER(), 'free' => self::FREE(), 'start' => self::START(), 'pro' => self::PRO(), diff --git a/src/Appwrite/Enums/OrganizationKeyScopes.php b/src/Appwrite/Enums/OrganizationKeyScopes.php deleted file mode 100644 index b28e58e9..00000000 --- a/src/Appwrite/Enums/OrganizationKeyScopes.php +++ /dev/null @@ -1,162 +0,0 @@ -value; - } - - public function jsonSerialize(): string - { - return $this->value; - } - - public static function PROJECTSREAD(): OrganizationKeyScopes - { - self::$PROJECTSREAD ??= new OrganizationKeyScopes('projects.read'); - - return self::$PROJECTSREAD; - } - public static function PROJECTSWRITE(): OrganizationKeyScopes - { - self::$PROJECTSWRITE ??= new OrganizationKeyScopes('projects.write'); - - return self::$PROJECTSWRITE; - } - public static function DEVKEYSREAD(): OrganizationKeyScopes - { - self::$DEVKEYSREAD ??= new OrganizationKeyScopes('devKeys.read'); - - return self::$DEVKEYSREAD; - } - public static function DEVKEYSWRITE(): OrganizationKeyScopes - { - self::$DEVKEYSWRITE ??= new OrganizationKeyScopes('devKeys.write'); - - return self::$DEVKEYSWRITE; - } - public static function ORGANIZATIONKEYSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONKEYSREAD ??= new OrganizationKeyScopes('organization.keys.read'); - - return self::$ORGANIZATIONKEYSREAD; - } - public static function ORGANIZATIONKEYSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONKEYSWRITE ??= new OrganizationKeyScopes('organization.keys.write'); - - return self::$ORGANIZATIONKEYSWRITE; - } - public static function ORGANIZATIONINSTALLATIONSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONINSTALLATIONSREAD ??= new OrganizationKeyScopes('organization.installations.read'); - - return self::$ORGANIZATIONINSTALLATIONSREAD; - } - public static function ORGANIZATIONINSTALLATIONSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONINSTALLATIONSWRITE ??= new OrganizationKeyScopes('organization.installations.write'); - - return self::$ORGANIZATIONINSTALLATIONSWRITE; - } - public static function ORGANIZATIONMEMBERSHIPSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONMEMBERSHIPSREAD ??= new OrganizationKeyScopes('organization.memberships.read'); - - return self::$ORGANIZATIONMEMBERSHIPSREAD; - } - public static function ORGANIZATIONMEMBERSHIPSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONMEMBERSHIPSWRITE ??= new OrganizationKeyScopes('organization.memberships.write'); - - return self::$ORGANIZATIONMEMBERSHIPSWRITE; - } - public static function ORGANIZATIONREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONREAD ??= new OrganizationKeyScopes('organization.read'); - - return self::$ORGANIZATIONREAD; - } - public static function ORGANIZATIONWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONWRITE ??= new OrganizationKeyScopes('organization.write'); - - return self::$ORGANIZATIONWRITE; - } - public static function DOMAINSREAD(): OrganizationKeyScopes - { - self::$DOMAINSREAD ??= new OrganizationKeyScopes('domains.read'); - - return self::$DOMAINSREAD; - } - public static function DOMAINSWRITE(): OrganizationKeyScopes - { - self::$DOMAINSWRITE ??= new OrganizationKeyScopes('domains.write'); - - return self::$DOMAINSWRITE; - } - public static function KEYSREAD(): OrganizationKeyScopes - { - self::$KEYSREAD ??= new OrganizationKeyScopes('keys.read'); - - return self::$KEYSREAD; - } - public static function KEYSWRITE(): OrganizationKeyScopes - { - self::$KEYSWRITE ??= new OrganizationKeyScopes('keys.write'); - - return self::$KEYSWRITE; - } - - public static function from(string $value): self - { - return match ($value) { - 'projects.read' => self::PROJECTSREAD(), - 'projects.write' => self::PROJECTSWRITE(), - 'devKeys.read' => self::DEVKEYSREAD(), - 'devKeys.write' => self::DEVKEYSWRITE(), - 'organization.keys.read' => self::ORGANIZATIONKEYSREAD(), - 'organization.keys.write' => self::ORGANIZATIONKEYSWRITE(), - 'organization.installations.read' => self::ORGANIZATIONINSTALLATIONSREAD(), - 'organization.installations.write' => self::ORGANIZATIONINSTALLATIONSWRITE(), - '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(), - 'keys.write' => self::KEYSWRITE(), - default => throw new \InvalidArgumentException('Unknown OrganizationKeyScopes value: ' . $value), - }; - } -} diff --git a/src/Appwrite/Models/ActivityEventList.php b/src/Appwrite/Models/ActivityEventList.php index 8fd47418..357d7578 100644 --- a/src/Appwrite/Models/ActivityEventList.php +++ b/src/Appwrite/Models/ActivityEventList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'events' => [], ]; - if (!array_key_exists('events', $data)) { - throw new \InvalidArgumentException('Missing required field "events" for ' . static::class . '.'); - } - return new static( total: $data['total'], events: is_array($data['events']) diff --git a/src/Appwrite/Models/App.php b/src/Appwrite/Models/App.php index 24d11d56..7b0f9e16 100644 --- a/src/Appwrite/Models/App.php +++ b/src/Appwrite/Models/App.php @@ -104,12 +104,9 @@ public static function from(array $data): static 'userId' => "", 'installationScopes' => [], 'installationRedirectUrl' => "", + 'secrets' => [], ]; - if (!array_key_exists('secrets', $data)) { - throw new \InvalidArgumentException('Missing required field "secrets" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/AppInstallationList.php b/src/Appwrite/Models/AppInstallationList.php index cd5c3396..09803f30 100644 --- a/src/Appwrite/Models/AppInstallationList.php +++ b/src/Appwrite/Models/AppInstallationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'installations' => [], ]; - if (!array_key_exists('installations', $data)) { - throw new \InvalidArgumentException('Missing required field "installations" for ' . static::class . '.'); - } - return new static( total: $data['total'], installations: is_array($data['installations']) diff --git a/src/Appwrite/Models/AppKeyList.php b/src/Appwrite/Models/AppKeyList.php index 25f9edf9..577dfc64 100644 --- a/src/Appwrite/Models/AppKeyList.php +++ b/src/Appwrite/Models/AppKeyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'keys' => [], ]; - if (!array_key_exists('keys', $data)) { - throw new \InvalidArgumentException('Missing required field "keys" for ' . static::class . '.'); - } - return new static( total: $data['total'], keys: is_array($data['keys']) diff --git a/src/Appwrite/Models/AppScopeList.php b/src/Appwrite/Models/AppScopeList.php index 7ccaf66a..06bace42 100644 --- a/src/Appwrite/Models/AppScopeList.php +++ b/src/Appwrite/Models/AppScopeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'scopes' => [], ]; - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } - return new static( total: $data['total'], scopes: is_array($data['scopes']) diff --git a/src/Appwrite/Models/AppSecretList.php b/src/Appwrite/Models/AppSecretList.php index eae43eb6..9eb22f83 100644 --- a/src/Appwrite/Models/AppSecretList.php +++ b/src/Appwrite/Models/AppSecretList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'secrets' => [], ]; - if (!array_key_exists('secrets', $data)) { - throw new \InvalidArgumentException('Missing required field "secrets" for ' . static::class . '.'); - } - return new static( total: $data['total'], secrets: is_array($data['secrets']) diff --git a/src/Appwrite/Models/AppsList.php b/src/Appwrite/Models/AppsList.php index 4b028315..5685206d 100644 --- a/src/Appwrite/Models/AppsList.php +++ b/src/Appwrite/Models/AppsList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'apps' => [], ]; - if (!array_key_exists('apps', $data)) { - throw new \InvalidArgumentException('Missing required field "apps" for ' . static::class . '.'); - } - return new static( total: $data['total'], apps: is_array($data['apps']) diff --git a/src/Appwrite/Models/AttributeEnum.php b/src/Appwrite/Models/AttributeEnum.php index d2d84316..c99bdc57 100644 --- a/src/Appwrite/Models/AttributeEnum.php +++ b/src/Appwrite/Models/AttributeEnum.php @@ -57,15 +57,13 @@ public static function from(array $data): static 'required' => false, '$createdAt' => "", '$updatedAt' => "", + 'elements' => [], 'format' => "enum", ]; if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('elements', $data)) { - throw new \InvalidArgumentException('Missing required field "elements" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeList.php b/src/Appwrite/Models/AttributeList.php index 0dd3e89e..b583570c 100644 --- a/src/Appwrite/Models/AttributeList.php +++ b/src/Appwrite/Models/AttributeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'attributes' => [], ]; - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - return new static( total: $data['total'], attributes: $data['attributes'] diff --git a/src/Appwrite/Models/BackupArchive.php b/src/Appwrite/Models/BackupArchive.php index 44422c20..949c9466 100644 --- a/src/Appwrite/Models/BackupArchive.php +++ b/src/Appwrite/Models/BackupArchive.php @@ -20,12 +20,12 @@ * @param string $createdAt archive creation time in iso 8601 format. * @param string $updatedAt archive update date in iso 8601 format. * @param string $policyId archive policy id. - * @param int $size archive size in bytes. * @param string $status the status of the archive creation. possible values: pending, processing, uploading, completed, failed, skipped. - * @param string $startedAt the backup start time. * @param string $migrationId migration id. * @param array $services the services that are backed up by this archive. * @param array $resources the resources that are backed up by this archive. + * @param int|null $size archive size in bytes. null until the size is known. + * @param string|null $startedAt the backup start time. null until the backup starts. * @param string|null $resourceId the resource id to backup. set only if this archive should backup a single resource. * @param string|null $resourceType the resource type to backup. set only if this archive should backup a single resource. */ @@ -34,12 +34,12 @@ public function __construct( public string $createdAt, public string $updatedAt, public string $policyId, - public int $size, public string $status, - public string $startedAt, public string $migrationId, public array $services, public array $resources, + public ?int $size = null, + public ?string $startedAt = null, public ?string $resourceId = null, public ?string $resourceType = null ) { @@ -57,32 +57,21 @@ public static function from(array $data): static 'policyId' => "", 'status' => "", 'migrationId' => "", + 'services' => [], + 'resources' => [], ]; - if (!array_key_exists('size', $data)) { - throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); - } - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], updatedAt: $data['$updatedAt'], policyId: $data['policyId'], - size: $data['size'], status: $data['status'], - startedAt: $data['startedAt'], migrationId: $data['migrationId'], services: $data['services'], resources: $data['resources'], + size: $data['size'] ?? null, + startedAt: $data['startedAt'] ?? null, resourceId: $data['resourceId'] ?? null, resourceType: $data['resourceType'] ?? null ); diff --git a/src/Appwrite/Models/BackupArchiveList.php b/src/Appwrite/Models/BackupArchiveList.php index 49691da9..e166d7a7 100644 --- a/src/Appwrite/Models/BackupArchiveList.php +++ b/src/Appwrite/Models/BackupArchiveList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'archives' => [], ]; - if (!array_key_exists('archives', $data)) { - throw new \InvalidArgumentException('Missing required field "archives" for ' . static::class . '.'); - } - return new static( total: $data['total'], archives: is_array($data['archives']) diff --git a/src/Appwrite/Models/BackupPolicy.php b/src/Appwrite/Models/BackupPolicy.php index 790139c0..b527ffbc 100644 --- a/src/Appwrite/Models/BackupPolicy.php +++ b/src/Appwrite/Models/BackupPolicy.php @@ -55,19 +55,14 @@ public static function from(array $data): static 'name' => "", '$createdAt' => "", '$updatedAt' => "", + 'services' => [], + 'resources' => [], 'retention' => 1, 'schedule' => "0 * * * *", 'type' => "full", 'enabled' => false, ]; - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], name: $data['name'], diff --git a/src/Appwrite/Models/BackupPolicyList.php b/src/Appwrite/Models/BackupPolicyList.php index f27fe912..ab81c662 100644 --- a/src/Appwrite/Models/BackupPolicyList.php +++ b/src/Appwrite/Models/BackupPolicyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'policies' => [], ]; - if (!array_key_exists('policies', $data)) { - throw new \InvalidArgumentException('Missing required field "policies" for ' . static::class . '.'); - } - return new static( total: $data['total'], policies: is_array($data['policies']) diff --git a/src/Appwrite/Models/BackupRestoration.php b/src/Appwrite/Models/BackupRestoration.php index c6581f63..0a588ec3 100644 --- a/src/Appwrite/Models/BackupRestoration.php +++ b/src/Appwrite/Models/BackupRestoration.php @@ -22,11 +22,11 @@ * @param string $archiveId backup archive id. * @param string $policyId backup policy id. * @param string $status the status of the restoration. possible values: pending, downloading, processing, completed, failed. - * @param string $startedAt the backup start time. * @param string $migrationId migration id. * @param array $services the services that are backed up by this policy. * @param array $resources the resources that are backed up by this policy. - * @param string $options optional data in key-value object. + * @param array $options restoration options as a key-value object. + * @param string|null $startedAt the restoration start time. null until the restoration starts. */ public function __construct( public string $id, @@ -35,11 +35,11 @@ public function __construct( public string $archiveId, public string $policyId, public string $status, - public string $startedAt, public string $migrationId, public array $services, public array $resources, - public string $options + public array $options, + public ?string $startedAt = null ) { } @@ -56,19 +56,11 @@ public static function from(array $data): static 'policyId' => "", 'status' => "", 'migrationId' => "", + 'services' => [], + 'resources' => [], 'options' => [], ]; - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], @@ -76,11 +68,11 @@ public static function from(array $data): static archiveId: $data['archiveId'], policyId: $data['policyId'], status: $data['status'], - startedAt: $data['startedAt'], migrationId: $data['migrationId'], services: $data['services'], resources: $data['resources'], - options: $data['options'] + options: $data['options'], + startedAt: $data['startedAt'] ?? null ); } diff --git a/src/Appwrite/Models/BackupRestorationList.php b/src/Appwrite/Models/BackupRestorationList.php index 6d7f13dc..86759d45 100644 --- a/src/Appwrite/Models/BackupRestorationList.php +++ b/src/Appwrite/Models/BackupRestorationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'restorations' => [], ]; - if (!array_key_exists('restorations', $data)) { - throw new \InvalidArgumentException('Missing required field "restorations" for ' . static::class . '.'); - } - return new static( total: $data['total'], restorations: is_array($data['restorations']) diff --git a/src/Appwrite/Models/BillingPlan.php b/src/Appwrite/Models/BillingPlan.php index c8da4643..29ad81c0 100644 --- a/src/Appwrite/Models/BillingPlan.php +++ b/src/Appwrite/Models/BillingPlan.php @@ -30,6 +30,7 @@ * @param int $screenshotsGenerated screenshots generated * @param int $webhooks webhooks * @param int $wafRules maximum waf rules per project + * @param int $environments maximum environments per project. 0 when the plan does not offer environments. * @param int $projects projects * @param int $platforms platforms * @param int $users users @@ -54,7 +55,6 @@ * @param int $usageLogs usage history days * @param int $projectInactivityDays number of days of console inactivity before a project is paused. 0 means pausing is disabled. * @param int $alertLimit alert threshold percentage - * @param UsageBillingPlan $usage additional resources * @param BillingPlanAddon $addons addons * @param bool $budgetCapEnabled budget cap enabled or disabled. * @param bool $customSmtp custom smtp @@ -83,10 +83,10 @@ * @param BillingPlanGroup $group group of this billing plan for variants * @param float $databaseComputeCredit included monthly dedicated-database compute credit in usd. resets each billing cycle with no roll-over. * @param int|null $members members - * @param int|null $environments maximum environments per project. 0 when the plan does not offer environments. * @param int|null $activityLogs activity log days * @param array|null $usageLogsIntervals usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). * @param array|null $usageAggregateOnlyMetrics metrics this plan only records as a total. they cannot be broken down by dimension or filtered, because the stored events cover a fraction of the real traffic. + * @param UsageBillingPlan|null $usage additional resources. null when the plan does not support usage billing. * @param array|null $eligibleCountries iso country codes eligible for this regional plan. empty means no restriction. * @param bool|null $backupsEnabled does plan support backup policies. * @param int|null $backupPolicies how many policies does plan support @@ -107,6 +107,7 @@ public function __construct( public int $screenshotsGenerated, public int $webhooks, public int $wafRules, + public int $environments, public int $projects, public int $platforms, public int $users, @@ -131,7 +132,6 @@ public function __construct( public int $usageLogs, public int $projectInactivityDays, public int $alertLimit, - public UsageBillingPlan $usage, public BillingPlanAddon $addons, public bool $budgetCapEnabled, public bool $customSmtp, @@ -160,10 +160,10 @@ public function __construct( public BillingPlanGroup $group, public float $databaseComputeCredit, public ?int $members = null, - public ?int $environments = null, public ?int $activityLogs = null, public ?array $usageLogsIntervals = null, public ?array $usageAggregateOnlyMetrics = null, + public ?UsageBillingPlan $usage = null, public ?array $eligibleCountries = null, public ?bool $backupsEnabled = null, public ?int $backupPolicies = null, @@ -191,6 +191,7 @@ public static function from(array $data): static 'screenshotsGenerated' => 0, 'webhooks' => 0, 'wafRules' => 0, + 'environments' => 0, 'projects' => 0, 'platforms' => 0, 'users' => 0, @@ -241,9 +242,6 @@ public static function from(array $data): static 'databaseComputeCredit' => 0, ]; - 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 . '.'); } @@ -267,6 +265,7 @@ public static function from(array $data): static screenshotsGenerated: $data['screenshotsGenerated'], webhooks: $data['webhooks'], wafRules: $data['wafRules'], + environments: $data['environments'], projects: $data['projects'], platforms: $data['platforms'], users: $data['users'], @@ -291,7 +290,6 @@ functions: $data['functions'], 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'], @@ -320,10 +318,10 @@ functionsIntervalMinimum: $data['functionsIntervalMinimum'], group: static::hydrateTypedValue(BillingPlanGroup::class, $data['group']), databaseComputeCredit: $data['databaseComputeCredit'], members: $data['members'] ?? null, - environments: $data['environments'] ?? null, activityLogs: $data['activityLogs'] ?? null, usageLogsIntervals: $data['usageLogsIntervals'] ?? null, usageAggregateOnlyMetrics: $data['usageAggregateOnlyMetrics'] ?? null, + usage: array_key_exists('usage', $data) ? static::hydrateTypedValue(UsageBillingPlan::class, $data['usage'], true) : null, eligibleCountries: $data['eligibleCountries'] ?? null, backupsEnabled: $data['backupsEnabled'] ?? null, backupPolicies: $data['backupPolicies'] ?? null, diff --git a/src/Appwrite/Models/Block.php b/src/Appwrite/Models/Block.php index f40cb573..3b918222 100644 --- a/src/Appwrite/Models/Block.php +++ b/src/Appwrite/Models/Block.php @@ -20,12 +20,6 @@ * @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. - * @param string $organizationId id of the organization that owns the project. - * @param string $billingPlan billing plan of the organization that owns the project. - * @param string|null $reason reason for the block. can be null if no reason was provided. * @param string|null $expiredAt block expiration date in iso 8601 format. can be null if the block does not expire. */ public function __construct( @@ -33,12 +27,6 @@ public function __construct( public string $resourceType, public string $resourceId, public string $mode, - public string $projectName, - public string $region, - public string $organizationName, - public string $organizationId, - public string $billingPlan, - public ?string $reason = null, public ?string $expiredAt = null ) { } @@ -55,33 +43,11 @@ public static function from(array $data): static 'mode' => "full", ]; - if (!array_key_exists('projectName', $data)) { - throw new \InvalidArgumentException('Missing required field "projectName" for ' . static::class . '.'); - } - if (!array_key_exists('region', $data)) { - throw new \InvalidArgumentException('Missing required field "region" for ' . static::class . '.'); - } - if (!array_key_exists('organizationName', $data)) { - throw new \InvalidArgumentException('Missing required field "organizationName" for ' . static::class . '.'); - } - if (!array_key_exists('organizationId', $data)) { - throw new \InvalidArgumentException('Missing required field "organizationId" for ' . static::class . '.'); - } - if (!array_key_exists('billingPlan', $data)) { - throw new \InvalidArgumentException('Missing required field "billingPlan" for ' . static::class . '.'); - } - return new static( createdAt: $data['$createdAt'], resourceType: $data['resourceType'], resourceId: $data['resourceId'], mode: $data['mode'], - projectName: $data['projectName'], - region: $data['region'], - organizationName: $data['organizationName'], - organizationId: $data['organizationId'], - billingPlan: $data['billingPlan'], - reason: $data['reason'] ?? null, expiredAt: $data['expiredAt'] ?? null ); } @@ -96,13 +62,7 @@ public function toArray(): array '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), - 'region' => static::serializeValue($this->region), - 'organizationName' => static::serializeValue($this->organizationName), - 'organizationId' => static::serializeValue($this->organizationId), - 'billingPlan' => static::serializeValue($this->billingPlan) + 'expiredAt' => static::serializeValue($this->expiredAt) ]; } } diff --git a/src/Appwrite/Models/BucketList.php b/src/Appwrite/Models/BucketList.php index 4ee13e87..d5e2831f 100644 --- a/src/Appwrite/Models/BucketList.php +++ b/src/Appwrite/Models/BucketList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'buckets' => [], ]; - if (!array_key_exists('buckets', $data)) { - throw new \InvalidArgumentException('Missing required field "buckets" for ' . static::class . '.'); - } - return new static( total: $data['total'], buckets: is_array($data['buckets']) diff --git a/src/Appwrite/Models/Collection.php b/src/Appwrite/Models/Collection.php index 34e1ff95..cf23cf70 100644 --- a/src/Appwrite/Models/Collection.php +++ b/src/Appwrite/Models/Collection.php @@ -54,24 +54,17 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'documentSecurity' => false, + 'attributes' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/CollectionList.php b/src/Appwrite/Models/CollectionList.php index 435e41ad..19110117 100644 --- a/src/Appwrite/Models/CollectionList.php +++ b/src/Appwrite/Models/CollectionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'collections' => [], ]; - if (!array_key_exists('collections', $data)) { - throw new \InvalidArgumentException('Missing required field "collections" for ' . static::class . '.'); - } - return new static( total: $data['total'], collections: is_array($data['collections']) diff --git a/src/Appwrite/Models/ColumnEnum.php b/src/Appwrite/Models/ColumnEnum.php index f9c4c458..31b43871 100644 --- a/src/Appwrite/Models/ColumnEnum.php +++ b/src/Appwrite/Models/ColumnEnum.php @@ -57,15 +57,13 @@ public static function from(array $data): static 'required' => false, '$createdAt' => "", '$updatedAt' => "", + 'elements' => [], 'format' => "enum", ]; if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('elements', $data)) { - throw new \InvalidArgumentException('Missing required field "elements" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnIndexList.php b/src/Appwrite/Models/ColumnIndexList.php index b5eaf075..1ce04240 100644 --- a/src/Appwrite/Models/ColumnIndexList.php +++ b/src/Appwrite/Models/ColumnIndexList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'indexes' => [], ]; - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( total: $data['total'], indexes: is_array($data['indexes']) diff --git a/src/Appwrite/Models/ColumnList.php b/src/Appwrite/Models/ColumnList.php index 108ff6a4..bc3a30f3 100644 --- a/src/Appwrite/Models/ColumnList.php +++ b/src/Appwrite/Models/ColumnList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'columns' => [], ]; - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - return new static( total: $data['total'], columns: $data['columns'] diff --git a/src/Appwrite/Models/ContinentList.php b/src/Appwrite/Models/ContinentList.php index 3af16511..dbf1b56c 100644 --- a/src/Appwrite/Models/ContinentList.php +++ b/src/Appwrite/Models/ContinentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'continents' => [], ]; - if (!array_key_exists('continents', $data)) { - throw new \InvalidArgumentException('Missing required field "continents" for ' . static::class . '.'); - } - return new static( total: $data['total'], continents: is_array($data['continents']) diff --git a/src/Appwrite/Models/CountryList.php b/src/Appwrite/Models/CountryList.php index 0a9210a9..84ce278a 100644 --- a/src/Appwrite/Models/CountryList.php +++ b/src/Appwrite/Models/CountryList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'countries' => [], ]; - if (!array_key_exists('countries', $data)) { - throw new \InvalidArgumentException('Missing required field "countries" for ' . static::class . '.'); - } - return new static( total: $data['total'], countries: is_array($data['countries']) diff --git a/src/Appwrite/Models/CurrencyList.php b/src/Appwrite/Models/CurrencyList.php index d2b33e37..9243c75f 100644 --- a/src/Appwrite/Models/CurrencyList.php +++ b/src/Appwrite/Models/CurrencyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'currencies' => [], ]; - if (!array_key_exists('currencies', $data)) { - throw new \InvalidArgumentException('Missing required field "currencies" for ' . static::class . '.'); - } - return new static( total: $data['total'], currencies: is_array($data['currencies']) diff --git a/src/Appwrite/Models/Database.php b/src/Appwrite/Models/Database.php index bd3a45e1..6cbaff98 100644 --- a/src/Appwrite/Models/Database.php +++ b/src/Appwrite/Models/Database.php @@ -30,7 +30,7 @@ * @param string|null $specification compute specification identifier of the dedicated backing, e.g. s-2vcpu-2gb. null when the database has no dedicated backing. * @param int|null $replicas number of secondary high availability replicas, excluding the primary. null when backing configuration is unavailable. * @param string|null $error error message when the dedicated backing failed. null when the database has no dedicated backing or has not failed. - * @param string|null $containerStatus container status of the dedicated backing: active or inactive. null when the database has no dedicated backing or the runtime has not reported one. + * @param string|null $containerStatus container status of the dedicated backing: active, inactive, or failed (a wake was declined because the backing namespace is gone). null when the database has no dedicated backing or the runtime has not reported one. * @param string|null $lifecycleState idle-lifecycle state of the dedicated backing: active, warm, cold, or hibernated. null when the database has no dedicated backing or the runtime has not reported one. * @param list|null $policies database backup policies. * @param list|null $archives database backup archives. diff --git a/src/Appwrite/Models/DatabaseList.php b/src/Appwrite/Models/DatabaseList.php index 86fb3468..8a1dd971 100644 --- a/src/Appwrite/Models/DatabaseList.php +++ b/src/Appwrite/Models/DatabaseList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'databases' => [], ]; - if (!array_key_exists('databases', $data)) { - throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); - } - return new static( total: $data['total'], databases: is_array($data['databases']) diff --git a/src/Appwrite/Models/DatabaseMigrationList.php b/src/Appwrite/Models/DatabaseMigrationList.php index ae2528dd..480bf847 100644 --- a/src/Appwrite/Models/DatabaseMigrationList.php +++ b/src/Appwrite/Models/DatabaseMigrationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'migrations' => [], ]; - if (!array_key_exists('migrations', $data)) { - throw new \InvalidArgumentException('Missing required field "migrations" for ' . static::class . '.'); - } - return new static( total: $data['total'], migrations: is_array($data['migrations']) diff --git a/src/Appwrite/Models/DatabaseStatus.php b/src/Appwrite/Models/DatabaseStatus.php index 6fdaf141..b685e035 100644 --- a/src/Appwrite/Models/DatabaseStatus.php +++ b/src/Appwrite/Models/DatabaseStatus.php @@ -21,13 +21,13 @@ * @param string $engine database engine: postgresql, mysql, or mongodb. * @param string $version database engine version. * @param int $uptime database uptime in seconds. - * @param DatabaseStatusConnections $connections connection statistics. * @param string $syncMode requested replication sync mode. possible values: async, sync, quorum. compare with effectivesyncmode for what the primary is enforcing. * @param bool $syncDegraded whether the enforced replication is weaker than the requested syncmode. * @param int $syncAcknowledgements number of standby acknowledgements the primary waits for before a write is committed. * @param int $syncStandbyCount number of standbys registered with the primary for synchronous replication. * @param list $replicas list of database replicas and their status. every configured member appears, including one the backend has not brought up, which is reported as not healthy. * @param list $volumes storage volume information. + * @param DatabaseStatusConnections|null $connections connection statistics. null when the database has not been probed. * @param string|null $effectiveSyncMode replication sync mode the primary is actually enforcing. null when high availability is disabled or the state could not be read. * @param bool|null $syncStateConfirmed whether the other sync fields are an engine reading rather than a recorded estimate. true when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. false when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. false never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ @@ -37,13 +37,13 @@ public function __construct( public string $engine, public string $version, public int $uptime, - public DatabaseStatusConnections $connections, public string $syncMode, public bool $syncDegraded, public int $syncAcknowledgements, public int $syncStandbyCount, public array $replicas, public array $volumes, + public ?DatabaseStatusConnections $connections = null, public ?string $effectiveSyncMode = null, public ?bool $syncStateConfirmed = null ) { @@ -64,25 +64,16 @@ public static function from(array $data): static 'syncDegraded' => false, 'syncAcknowledgements' => 0, 'syncStandbyCount' => 0, + 'replicas' => [], + 'volumes' => [], ]; - if (!array_key_exists('connections', $data)) { - throw new \InvalidArgumentException('Missing required field "connections" for ' . static::class . '.'); - } - if (!array_key_exists('replicas', $data)) { - throw new \InvalidArgumentException('Missing required field "replicas" for ' . static::class . '.'); - } - if (!array_key_exists('volumes', $data)) { - throw new \InvalidArgumentException('Missing required field "volumes" for ' . static::class . '.'); - } - return new static( health: $data['health'], ready: $data['ready'], engine: $data['engine'], version: $data['version'], uptime: $data['uptime'], - connections: static::hydrateTypedValue(DatabaseStatusConnections::class, $data['connections']), syncMode: $data['syncMode'], syncDegraded: $data['syncDegraded'], syncAcknowledgements: $data['syncAcknowledgements'], @@ -99,6 +90,7 @@ public static function from(array $data): static $data['volumes'] ) : $data['volumes'], + connections: array_key_exists('connections', $data) ? static::hydrateTypedValue(DatabaseStatusConnections::class, $data['connections'], true) : null, effectiveSyncMode: $data['effectiveSyncMode'] ?? null, syncStateConfirmed: $data['syncStateConfirmed'] ?? null ); diff --git a/src/Appwrite/Models/DedicatedDatabase.php b/src/Appwrite/Models/DedicatedDatabase.php index acd6c5d1..fd356542 100644 --- a/src/Appwrite/Models/DedicatedDatabase.php +++ b/src/Appwrite/Models/DedicatedDatabase.php @@ -21,25 +21,23 @@ * @param string $updatedAt database update date in iso 8601 format. * @param string $projectId project id that owns this database. * @param string $name database display name. - * @param string $api product api that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. - * @param string $engine database engine: postgresql, mysql, or mongodb. null until the backing reports one. * @param string $version database engine version. * @param string $specification specification identifier. * @param string $backend database backend provider. possible values: edge. * @param string $hostname database hostname for connections. - * @param int $connectionPort database port for connections. derived from the engine when the backing has not reported one yet. * @param string $connectionUser database username for connections. * @param string $connectionPassword database password for connections. - * @param int $credentialGeneration committed generation of the primary connection credentials. null until the rotation contract has been initialized. * @param string $connectionString full database connection string (uri format). * @param bool $ssl whether ssl/tls is required for client connections. * @param string $status database status. possible values: provisioning, ready, inactive, paused, failed, deleted, restoring, scaling. - * @param string $containerStatus container status for lifecycle-managed database runtimes: active or inactive. + * @param string $containerStatus container status for lifecycle-managed database runtimes: active, inactive, or failed (a wake was declined because the backing namespace is gone). * @param string $lifecycleState idle-lifecycle state of the database. possible values: active, warm, cold, hibernated. * @param int $idleTimeoutMinutes minutes of inactivity before container scales to zero. * @param int $cpu cpu allocated in millicores. * @param int $memory memory allocated in mb. * @param int $storage storage allocated in gb. + * @param string $storageStatus storage resize status. possible values: idle (no resize in flight), resizing (the volume is growing towards storagetargetgb). + * @param int $storageTargetGb size in gb the volume is growing towards while storagestatus is resizing. 0 when no resize is in flight. * @param string $storageClass storage class. currently always 'ssd'; digitalocean exposes a single block-storage class. * @param int $storageMaxGb maximum storage allowed in gb. 0 means use system default. * @param string $nodePool kubernetes node pool where the database is scheduled. @@ -53,7 +51,7 @@ * @param int $pitrRetentionDays number of days to retain pitr data. * @param bool $storageAutoscaling whether automatic storage expansion is enabled. * @param int $storageAutoscalingThresholdPercent storage usage percentage that triggers automatic expansion. - * @param int $storageAutoscalingMaxGb maximum storage size in gb for autoscaling. 0 means no limit. + * @param int $storageAutoscalingMaxGb maximum storage size in gb for autoscaling. defaults to 3 times the specification's storage. 0 means no limit. * @param string $maintenanceWindowDay day of the week for the maintenance window. possible values: sun, mon, tue, wed, thu, fri, sat. * @param int $maintenanceWindowHourUtc hour in utc (0-23) when the maintenance window starts. * @param bool $metricsEnabled whether metrics collection is enabled. @@ -63,10 +61,12 @@ * @param int $sqlApiMaxBytes maximum serialised sql api result payload in bytes. results larger than this are truncated. * @param int $sqlApiTimeoutSeconds maximum server-side sql api execution time in seconds before the query is cancelled. * @param string $error error message if status is failed. + * @param string|null $api product api that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. + * @param string|null $engine database engine: postgresql, mysql, or mongodb. null until the backing reports one. + * @param int|null $connectionPort database port for connections. derived from the engine when the backing has not reported one yet. + * @param int|null $credentialGeneration committed generation of the primary connection credentials. null until the rotation contract has been initialized. * @param string|null $lastAccessedAt last activity timestamp in iso 8601 format. * @param string|null $idleUntil display-only timestamp when the database is expected to be considered idle (iso 8601 format). derived from last activity; lifecycle transitions are driven by lifecyclestate. - * @param string|null $storageStatus storage resize status. possible values: idle (no resize in flight), resizing (the volume is growing towards storagetargetgb). - * @param int|null $storageTargetGb size in gb the volume is growing towards while storagestatus is resizing. 0 when no resize is in flight. * @param string|null $storageResizeStartedAt time the in-flight storage resize started, in iso 8601 format. */ public function __construct( @@ -75,16 +75,12 @@ public function __construct( public string $updatedAt, public string $projectId, public string $name, - public string $api, - public string $engine, public string $version, public string $specification, public string $backend, public string $hostname, - public int $connectionPort, public string $connectionUser, public string $connectionPassword, - public int $credentialGeneration, public string $connectionString, public bool $ssl, public string $status, @@ -94,6 +90,8 @@ public function __construct( public int $cpu, public int $memory, public int $storage, + public string $storageStatus, + public int $storageTargetGb, public string $storageClass, public int $storageMaxGb, public string $nodePool, @@ -117,10 +115,12 @@ public function __construct( public int $sqlApiMaxBytes, public int $sqlApiTimeoutSeconds, public string $error, + public ?string $api = null, + public ?string $engine = null, + public ?int $connectionPort = null, + public ?int $credentialGeneration = null, public ?string $lastAccessedAt = null, public ?string $idleUntil = null, - public ?string $storageStatus = null, - public ?int $storageTargetGb = null, public ?string $storageResizeStartedAt = null ) { } @@ -151,6 +151,8 @@ public static function from(array $data): static 'cpu' => 500, 'memory' => 512, 'storage' => 10, + 'storageStatus' => "idle", + 'storageTargetGb' => 0, 'storageClass' => "ssd", 'storageMaxGb' => 0, 'nodePool' => "", @@ -176,35 +178,18 @@ public static function from(array $data): static 'error' => "", ]; - if (!array_key_exists('api', $data)) { - throw new \InvalidArgumentException('Missing required field "api" for ' . static::class . '.'); - } - if (!array_key_exists('engine', $data)) { - throw new \InvalidArgumentException('Missing required field "engine" for ' . static::class . '.'); - } - if (!array_key_exists('connectionPort', $data)) { - throw new \InvalidArgumentException('Missing required field "connectionPort" for ' . static::class . '.'); - } - if (!array_key_exists('credentialGeneration', $data)) { - throw new \InvalidArgumentException('Missing required field "credentialGeneration" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], updatedAt: $data['$updatedAt'], projectId: $data['projectId'], name: $data['name'], - api: $data['api'], - engine: $data['engine'], version: $data['version'], specification: $data['specification'], backend: $data['backend'], hostname: $data['hostname'], - connectionPort: $data['connectionPort'], connectionUser: $data['connectionUser'], connectionPassword: $data['connectionPassword'], - credentialGeneration: $data['credentialGeneration'], connectionString: $data['connectionString'], ssl: $data['ssl'], status: $data['status'], @@ -214,6 +199,8 @@ public static function from(array $data): static cpu: $data['cpu'], memory: $data['memory'], storage: $data['storage'], + storageStatus: $data['storageStatus'], + storageTargetGb: $data['storageTargetGb'], storageClass: $data['storageClass'], storageMaxGb: $data['storageMaxGb'], nodePool: $data['nodePool'], @@ -237,10 +224,12 @@ public static function from(array $data): static sqlApiMaxBytes: $data['sqlApiMaxBytes'], sqlApiTimeoutSeconds: $data['sqlApiTimeoutSeconds'], error: $data['error'], + api: $data['api'] ?? null, + engine: $data['engine'] ?? null, + connectionPort: $data['connectionPort'] ?? null, + credentialGeneration: $data['credentialGeneration'] ?? null, lastAccessedAt: $data['lastAccessedAt'] ?? null, idleUntil: $data['idleUntil'] ?? null, - storageStatus: $data['storageStatus'] ?? null, - storageTargetGb: $data['storageTargetGb'] ?? null, storageResizeStartedAt: $data['storageResizeStartedAt'] ?? null ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseBackupList.php b/src/Appwrite/Models/DedicatedDatabaseBackupList.php index fb6b0225..745fe62c 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBackupList.php +++ b/src/Appwrite/Models/DedicatedDatabaseBackupList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'backups' => [], ]; - if (!array_key_exists('backups', $data)) { - throw new \InvalidArgumentException('Missing required field "backups" for ' . static::class . '.'); - } - return new static( total: $data['total'], backups: is_array($data['backups']) diff --git a/src/Appwrite/Models/DedicatedDatabaseBranch.php b/src/Appwrite/Models/DedicatedDatabaseBranch.php index 47704627..7ddfe531 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBranch.php +++ b/src/Appwrite/Models/DedicatedDatabaseBranch.php @@ -21,13 +21,13 @@ * @param string $namespace kubernetes namespace where the branch is deployed. * @param int $expiresAt unix timestamp when the branch expires. * @param string $host branch hostname for direct connections. - * @param int $port branch port. null until the backing reports one. * @param string $database advertised catalog the client connects to. mysql/mariadb use default; postgres uses the routing label. * @param string $username database username. shared with the parent database. * @param string $password database password. shared with the parent database. * @param bool $ssl whether ssl is required. * @param string $engine database engine. possible values: postgresql, mysql, mongodb. * @param string $connectionString full connection string for the branch. + * @param int|null $port branch port. null until the backing reports one. */ public function __construct( public string $branchId, @@ -35,13 +35,13 @@ public function __construct( public string $namespace, public int $expiresAt, public string $host, - public int $port, public string $database, public string $username, public string $password, public bool $ssl, public string $engine, - public string $connectionString + public string $connectionString, + public ?int $port = null ) { } @@ -64,23 +64,19 @@ public static function from(array $data): static 'connectionString' => "", ]; - if (!array_key_exists('port', $data)) { - throw new \InvalidArgumentException('Missing required field "port" for ' . static::class . '.'); - } - return new static( branchId: $data['branchId'], branchName: $data['branchName'], namespace: $data['namespace'], expiresAt: $data['expiresAt'], host: $data['host'], - port: $data['port'], database: $data['database'], username: $data['username'], password: $data['password'], ssl: $data['ssl'], engine: $data['engine'], - connectionString: $data['connectionString'] + connectionString: $data['connectionString'], + port: $data['port'] ?? null ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseBranchList.php b/src/Appwrite/Models/DedicatedDatabaseBranchList.php index 4212a97d..c7bd5afc 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBranchList.php +++ b/src/Appwrite/Models/DedicatedDatabaseBranchList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'branches' => [], ]; - if (!array_key_exists('branches', $data)) { - throw new \InvalidArgumentException('Missing required field "branches" for ' . static::class . '.'); - } - return new static( total: $data['total'], branches: is_array($data['branches']) diff --git a/src/Appwrite/Models/DedicatedDatabaseExecution.php b/src/Appwrite/Models/DedicatedDatabaseExecution.php index 12e54077..283c9897 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExecution.php +++ b/src/Appwrite/Models/DedicatedDatabaseExecution.php @@ -41,15 +41,12 @@ public static function from(array $data): static $data += [ 'rows' => [], 'rowCount' => 0, + 'columns' => [], 'durationMs' => 0, 'truncated' => false, 'bytes' => 0, ]; - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - return new static( rows: $data['rows'], rowCount: $data['rowCount'], diff --git a/src/Appwrite/Models/DedicatedDatabaseExtensions.php b/src/Appwrite/Models/DedicatedDatabaseExtensions.php index b1532138..9f294000 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExtensions.php +++ b/src/Appwrite/Models/DedicatedDatabaseExtensions.php @@ -35,12 +35,9 @@ public static function from(array $data): static $data += [ 'installed' => [], 'available' => [], + 'metadata' => [], ]; - if (!array_key_exists('metadata', $data)) { - throw new \InvalidArgumentException('Missing required field "metadata" for ' . static::class . '.'); - } - return new static( installed: $data['installed'], available: $data['available'], diff --git a/src/Appwrite/Models/DedicatedDatabaseList.php b/src/Appwrite/Models/DedicatedDatabaseList.php index a9784de3..796742c0 100644 --- a/src/Appwrite/Models/DedicatedDatabaseList.php +++ b/src/Appwrite/Models/DedicatedDatabaseList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'databases' => [], ]; - if (!array_key_exists('databases', $data)) { - throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); - } - return new static( total: $data['total'], databases: is_array($data['databases']) diff --git a/src/Appwrite/Models/DedicatedDatabaseOperationList.php b/src/Appwrite/Models/DedicatedDatabaseOperationList.php index 7710285e..c8d97389 100644 --- a/src/Appwrite/Models/DedicatedDatabaseOperationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseOperationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'operations' => [], ]; - if (!array_key_exists('operations', $data)) { - throw new \InvalidArgumentException('Missing required field "operations" for ' . static::class . '.'); - } - return new static( total: $data['total'], operations: is_array($data['operations']) diff --git a/src/Appwrite/Models/DedicatedDatabaseReplicas.php b/src/Appwrite/Models/DedicatedDatabaseReplicas.php index 563630fe..451679fc 100644 --- a/src/Appwrite/Models/DedicatedDatabaseReplicas.php +++ b/src/Appwrite/Models/DedicatedDatabaseReplicas.php @@ -48,12 +48,9 @@ public static function from(array $data): static 'syncDegraded' => false, 'syncAcknowledgements' => 0, 'syncStandbyCount' => 0, + 'members' => [], ]; - if (!array_key_exists('members', $data)) { - throw new \InvalidArgumentException('Missing required field "members" for ' . static::class . '.'); - } - return new static( replicas: $data['replicas'], syncMode: $data['syncMode'], diff --git a/src/Appwrite/Models/DedicatedDatabaseRestoration.php b/src/Appwrite/Models/DedicatedDatabaseRestoration.php index 02927028..28b38db0 100644 --- a/src/Appwrite/Models/DedicatedDatabaseRestoration.php +++ b/src/Appwrite/Models/DedicatedDatabaseRestoration.php @@ -19,29 +19,29 @@ * @param string $id restoration id. * @param string $createdAt restoration creation time in iso 8601 format. * @param string $databaseId database id being restored into. - * @param string $sourceDatabaseId source database id when restoring a backup into another database. * @param string $projectId project id. - * @param string $backupId backup id used for restoration (null for pitr). * @param string $type restoration type. possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). * @param string $status restoration status. possible values: pending (queued for processing), running (currently in progress), completed (successfully finished), failed (encountered an error). - * @param string $targetTime target time for pitr restoration in iso 8601 format. - * @param string $startedAt restoration start time in iso 8601 format. - * @param string $completedAt restoration completion time in iso 8601 format. * @param string $error error message if restoration failed. + * @param string|null $sourceDatabaseId source database id when restoring a backup into another database. + * @param string|null $backupId backup id used for restoration (null for pitr). + * @param string|null $targetTime target time for pitr restoration in iso 8601 format. + * @param string|null $startedAt restoration start time in iso 8601 format. + * @param string|null $completedAt restoration completion time in iso 8601 format. */ public function __construct( public string $id, public string $createdAt, public string $databaseId, - public string $sourceDatabaseId, public string $projectId, - public string $backupId, public string $type, public string $status, - public string $targetTime, - public string $startedAt, - public string $completedAt, - public string $error + public string $error, + public ?string $sourceDatabaseId = null, + public ?string $backupId = null, + public ?string $targetTime = null, + public ?string $startedAt = null, + public ?string $completedAt = null ) { } @@ -60,35 +60,19 @@ public static function from(array $data): static 'error' => "", ]; - if (!array_key_exists('sourceDatabaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "sourceDatabaseId" for ' . static::class . '.'); - } - if (!array_key_exists('backupId', $data)) { - throw new \InvalidArgumentException('Missing required field "backupId" for ' . static::class . '.'); - } - if (!array_key_exists('targetTime', $data)) { - throw new \InvalidArgumentException('Missing required field "targetTime" for ' . static::class . '.'); - } - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('completedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "completedAt" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], databaseId: $data['databaseId'], - sourceDatabaseId: $data['sourceDatabaseId'], projectId: $data['projectId'], - backupId: $data['backupId'], type: $data['type'], status: $data['status'], - targetTime: $data['targetTime'], - startedAt: $data['startedAt'], - completedAt: $data['completedAt'], - error: $data['error'] + error: $data['error'], + sourceDatabaseId: $data['sourceDatabaseId'] ?? null, + backupId: $data['backupId'] ?? null, + targetTime: $data['targetTime'] ?? null, + startedAt: $data['startedAt'] ?? null, + completedAt: $data['completedAt'] ?? null ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseRestorationList.php b/src/Appwrite/Models/DedicatedDatabaseRestorationList.php index b4491a49..b599e127 100644 --- a/src/Appwrite/Models/DedicatedDatabaseRestorationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseRestorationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'restorations' => [], ]; - if (!array_key_exists('restorations', $data)) { - throw new \InvalidArgumentException('Missing required field "restorations" for ' . static::class . '.'); - } - return new static( total: $data['total'], restorations: is_array($data['restorations']) diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecification.php b/src/Appwrite/Models/DedicatedDatabaseSpecification.php index a4612cc0..aa10cd8e 100644 --- a/src/Appwrite/Models/DedicatedDatabaseSpecification.php +++ b/src/Appwrite/Models/DedicatedDatabaseSpecification.php @@ -19,31 +19,31 @@ * @param string $slug specification slug. use this value when creating a dedicated database. * @param string $name human readable specification name. * @param float $price monthly price of the specification in usd. + * @param float $storageOverageRate price per gb of storage above the included amount, per month, in usd. + * @param float $bandwidthOverageRate price per gb of bandwidth above the included amount, per month, in usd. + * @param float $replicaRate high availability replica price as a fraction of the specification price. + * @param float $pitrRate point-in-time recovery price as a fraction of the specification price. * @param int $cpu allocated cpu in millicores. * @param int $memory allocated memory in mb. * @param int $maxConnections maximum number of concurrent connections. * @param int $includedStorage included storage in gb before overage charges apply. * @param int $includedBandwidth included bandwidth in gb before overage charges apply. * @param bool $enabled whether the specification is available on the current plan. - * @param float|null $storageOverageRate price per gb of storage above the included amount, per month, in usd. - * @param float|null $bandwidthOverageRate price per gb of bandwidth above the included amount, per month, in usd. - * @param float|null $replicaRate high availability replica price as a fraction of the specification price. - * @param float|null $pitrRate point-in-time recovery price as a fraction of the specification price. */ public function __construct( public string $slug, public string $name, public float $price, + public float $storageOverageRate, + public float $bandwidthOverageRate, + public float $replicaRate, + public float $pitrRate, public int $cpu, public int $memory, public int $maxConnections, public int $includedStorage, public int $includedBandwidth, - public bool $enabled, - public ?float $storageOverageRate = null, - public ?float $bandwidthOverageRate = null, - public ?float $replicaRate = null, - public ?float $pitrRate = null + public bool $enabled ) { } @@ -56,6 +56,10 @@ public static function from(array $data): static 'slug' => "", 'name' => "", 'price' => 0, + 'storageOverageRate' => 0, + 'bandwidthOverageRate' => 0, + 'replicaRate' => 0, + 'pitrRate' => 0, 'cpu' => 0, 'memory' => 0, 'maxConnections' => 0, @@ -68,16 +72,16 @@ public static function from(array $data): static slug: $data['slug'], name: $data['name'], price: $data['price'], + storageOverageRate: $data['storageOverageRate'], + bandwidthOverageRate: $data['bandwidthOverageRate'], + replicaRate: $data['replicaRate'], + pitrRate: $data['pitrRate'], cpu: $data['cpu'], memory: $data['memory'], maxConnections: $data['maxConnections'], includedStorage: $data['includedStorage'], includedBandwidth: $data['includedBandwidth'], - enabled: $data['enabled'], - storageOverageRate: $data['storageOverageRate'] ?? null, - bandwidthOverageRate: $data['bandwidthOverageRate'] ?? null, - replicaRate: $data['replicaRate'] ?? null, - pitrRate: $data['pitrRate'] ?? null + enabled: $data['enabled'] ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php b/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php index 9ac12067..3f3aca02 100644 --- a/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php @@ -18,12 +18,10 @@ * * @param list $specifications list of dedicated database specifications. * @param int $total total number of specifications. - * @param DedicatedDatabaseSpecificationPricing $pricing overage and add-on pricing shared across all specifications. */ public function __construct( public array $specifications, - public int $total, - public DedicatedDatabaseSpecificationPricing $pricing + public int $total ) { } @@ -33,16 +31,10 @@ public function __construct( public static function from(array $data): static { $data += [ + 'specifications' => [], 'total' => 0, ]; - if (!array_key_exists('specifications', $data)) { - throw new \InvalidArgumentException('Missing required field "specifications" for ' . static::class . '.'); - } - if (!array_key_exists('pricing', $data)) { - throw new \InvalidArgumentException('Missing required field "pricing" for ' . static::class . '.'); - } - return new static( specifications: is_array($data['specifications']) ? array_map( @@ -50,8 +42,7 @@ public static function from(array $data): static $data['specifications'] ) : $data['specifications'], - total: $data['total'], - pricing: static::hydrateTypedValue(DedicatedDatabaseSpecificationPricing::class, $data['pricing']) + total: $data['total'] ); } @@ -62,8 +53,7 @@ public function toArray(): array { return [ 'specifications' => static::serializeValue($this->specifications), - 'total' => static::serializeValue($this->total), - 'pricing' => static::serializeValue($this->pricing) + 'total' => static::serializeValue($this->total) ]; } } diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php b/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php deleted file mode 100644 index c8a11f5f..00000000 --- a/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php +++ /dev/null @@ -1,70 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('storageOverageRate', $data)) { - throw new \InvalidArgumentException('Missing required field "storageOverageRate" for ' . static::class . '.'); - } - if (!array_key_exists('bandwidthOverageRate', $data)) { - throw new \InvalidArgumentException('Missing required field "bandwidthOverageRate" for ' . static::class . '.'); - } - if (!array_key_exists('replicaRate', $data)) { - throw new \InvalidArgumentException('Missing required field "replicaRate" for ' . static::class . '.'); - } - if (!array_key_exists('pitrRate', $data)) { - throw new \InvalidArgumentException('Missing required field "pitrRate" for ' . static::class . '.'); - } - - return new static( - storageOverageRate: $data['storageOverageRate'], - bandwidthOverageRate: $data['bandwidthOverageRate'], - replicaRate: $data['replicaRate'], - pitrRate: $data['pitrRate'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'storageOverageRate' => static::serializeValue($this->storageOverageRate), - 'bandwidthOverageRate' => static::serializeValue($this->bandwidthOverageRate), - 'replicaRate' => static::serializeValue($this->replicaRate), - 'pitrRate' => static::serializeValue($this->pitrRate) - ]; - } -} diff --git a/src/Appwrite/Models/DeploymentList.php b/src/Appwrite/Models/DeploymentList.php index 84e99d1e..cd39aa38 100644 --- a/src/Appwrite/Models/DeploymentList.php +++ b/src/Appwrite/Models/DeploymentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'deployments' => [], ]; - if (!array_key_exists('deployments', $data)) { - throw new \InvalidArgumentException('Missing required field "deployments" for ' . static::class . '.'); - } - return new static( total: $data['total'], deployments: is_array($data['deployments']) diff --git a/src/Appwrite/Models/DevKey.php b/src/Appwrite/Models/DevKey.php deleted file mode 100644 index 971c16fa..00000000 --- a/src/Appwrite/Models/DevKey.php +++ /dev/null @@ -1,98 +0,0 @@ - $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('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - - return new static( - id: $data['$id'], - createdAt: $data['$createdAt'], - updatedAt: $data['$updatedAt'], - name: $data['name'], - expire: $data['expire'], - secret: $data['secret'], - accessedAt: $data['accessedAt'], - sdks: $data['sdks'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - '$id' => static::serializeValue($this->id), - '$createdAt' => static::serializeValue($this->createdAt), - '$updatedAt' => static::serializeValue($this->updatedAt), - 'name' => static::serializeValue($this->name), - 'expire' => static::serializeValue($this->expire), - 'secret' => static::serializeValue($this->secret), - 'accessedAt' => static::serializeValue($this->accessedAt), - 'sdks' => static::serializeValue($this->sdks) - ]; - } -} diff --git a/src/Appwrite/Models/Document.php b/src/Appwrite/Models/Document.php index b0cf5b9c..fa1231f8 100644 --- a/src/Appwrite/Models/Document.php +++ b/src/Appwrite/Models/Document.php @@ -49,12 +49,9 @@ public static function from(array $data): static '$databaseId' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - $additionalProperties = static::extractAdditionalPropertiesFromFields( $data, [ diff --git a/src/Appwrite/Models/DocumentList.php b/src/Appwrite/Models/DocumentList.php index 8a34e498..68bfb14e 100644 --- a/src/Appwrite/Models/DocumentList.php +++ b/src/Appwrite/Models/DocumentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'documents' => [], ]; - if (!array_key_exists('documents', $data)) { - throw new \InvalidArgumentException('Missing required field "documents" for ' . static::class . '.'); - } - return new static( total: $data['total'], documents: is_array($data['documents']) diff --git a/src/Appwrite/Models/EmailTemplateList.php b/src/Appwrite/Models/EmailTemplateList.php index 934220ab..015cc0db 100644 --- a/src/Appwrite/Models/EmailTemplateList.php +++ b/src/Appwrite/Models/EmailTemplateList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'templates' => [], ]; - if (!array_key_exists('templates', $data)) { - throw new \InvalidArgumentException('Missing required field "templates" for ' . static::class . '.'); - } - return new static( total: $data['total'], templates: is_array($data['templates']) diff --git a/src/Appwrite/Models/EmbeddingList.php b/src/Appwrite/Models/EmbeddingList.php index dde35f28..7e362a18 100644 --- a/src/Appwrite/Models/EmbeddingList.php +++ b/src/Appwrite/Models/EmbeddingList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'embeddings' => [], ]; - if (!array_key_exists('embeddings', $data)) { - throw new \InvalidArgumentException('Missing required field "embeddings" for ' . static::class . '.'); - } - return new static( total: $data['total'], embeddings: is_array($data['embeddings']) diff --git a/src/Appwrite/Models/EphemeralKey.php b/src/Appwrite/Models/EphemeralKey.php index 0709c91c..c338f61e 100644 --- a/src/Appwrite/Models/EphemeralKey.php +++ b/src/Appwrite/Models/EphemeralKey.php @@ -53,12 +53,9 @@ public static function from(array $data): static 'scopes' => [], 'secret' => "", 'accessedAt' => "", + 'sdks' => [], ]; - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/Execution.php b/src/Appwrite/Models/Execution.php index 8ac7d6fa..29d3b3dd 100644 --- a/src/Appwrite/Models/Execution.php +++ b/src/Appwrite/Models/Execution.php @@ -37,7 +37,7 @@ * @param list $responseHeaders http response headers as a key-value object. this will return only whitelisted headers. all headers are returned if execution is created as synchronous. * @param string $logs resource logs. includes the last 4,000 characters. this will return an empty string unless the response is returned using an api key or as part of a webhook payload. * @param string $errors resource errors. includes the last 4,000 characters. this will return an empty string unless the response is returned using an api key or as part of a webhook payload. - * @param float $duration resource(function/site) execution duration in seconds. + * @param float $duration total time the resource(function/site) took to respond, in seconds. * @param string|null $scheduledAt the scheduled time for execution. if left empty, execution will be queued immediately. */ public function __construct( @@ -72,33 +72,27 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'resourceId' => "", 'resourceType' => "functions", 'deploymentId' => "", 'requestMethod' => "", 'requestPath' => "", + 'requestHeaders' => [], 'responseStatusCode' => 0, 'responseBody' => "", + 'responseHeaders' => [], 'logs' => "", 'errors' => "", 'duration' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } if (!array_key_exists('trigger', $data)) { throw new \InvalidArgumentException('Missing required field "trigger" for ' . static::class . '.'); } if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('requestHeaders', $data)) { - throw new \InvalidArgumentException('Missing required field "requestHeaders" for ' . static::class . '.'); - } - if (!array_key_exists('responseHeaders', $data)) { - throw new \InvalidArgumentException('Missing required field "responseHeaders" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/ExecutionList.php b/src/Appwrite/Models/ExecutionList.php index ee91c286..2b164511 100644 --- a/src/Appwrite/Models/ExecutionList.php +++ b/src/Appwrite/Models/ExecutionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'executions' => [], ]; - if (!array_key_exists('executions', $data)) { - throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.'); - } - return new static( total: $data['total'], executions: is_array($data['executions']) diff --git a/src/Appwrite/Models/FileList.php b/src/Appwrite/Models/FileList.php index f934a390..cab60fc5 100644 --- a/src/Appwrite/Models/FileList.php +++ b/src/Appwrite/Models/FileList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'files' => [], ]; - if (!array_key_exists('files', $data)) { - throw new \InvalidArgumentException('Missing required field "files" for ' . static::class . '.'); - } - return new static( total: $data['total'], files: is_array($data['files']) diff --git a/src/Appwrite/Models/Framework.php b/src/Appwrite/Models/Framework.php index 7c3efaff..20a43d42 100644 --- a/src/Appwrite/Models/Framework.php +++ b/src/Appwrite/Models/Framework.php @@ -40,15 +40,10 @@ public static function from(array $data): static 'key' => "", 'name' => "", 'buildRuntime' => "", + 'runtimes' => [], + 'adapters' => [], ]; - if (!array_key_exists('runtimes', $data)) { - throw new \InvalidArgumentException('Missing required field "runtimes" for ' . static::class . '.'); - } - if (!array_key_exists('adapters', $data)) { - throw new \InvalidArgumentException('Missing required field "adapters" for ' . static::class . '.'); - } - return new static( key: $data['key'], name: $data['name'], diff --git a/src/Appwrite/Models/FrameworkList.php b/src/Appwrite/Models/FrameworkList.php index 8188732e..9397daa1 100644 --- a/src/Appwrite/Models/FrameworkList.php +++ b/src/Appwrite/Models/FrameworkList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'frameworks' => [], ]; - if (!array_key_exists('frameworks', $data)) { - throw new \InvalidArgumentException('Missing required field "frameworks" for ' . static::class . '.'); - } - return new static( total: $data['total'], frameworks: is_array($data['frameworks']) diff --git a/src/Appwrite/Models/FunctionList.php b/src/Appwrite/Models/FunctionList.php index e5f38db1..39fca279 100644 --- a/src/Appwrite/Models/FunctionList.php +++ b/src/Appwrite/Models/FunctionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'functions' => [], ]; - if (!array_key_exists('functions', $data)) { - throw new \InvalidArgumentException('Missing required field "functions" for ' . static::class . '.'); - } - return new static( total: $data['total'], functions: is_array($data['functions']) diff --git a/src/Appwrite/Models/FunctionModel.php b/src/Appwrite/Models/FunctionModel.php index a6fbc219..559d2087 100644 --- a/src/Appwrite/Models/FunctionModel.php +++ b/src/Appwrite/Models/FunctionModel.php @@ -109,6 +109,7 @@ public static function from(array $data): static 'latestDeploymentCreatedAt' => "", 'latestDeploymentStatus' => "", 'scopes' => [], + 'vars' => [], 'events' => [], 'schedule' => "", 'timeout' => 15, @@ -126,10 +127,6 @@ public static function from(array $data): static 'runtimeSpecification' => "s-1vcpu-512mb", ]; - if (!array_key_exists('vars', $data)) { - throw new \InvalidArgumentException('Missing required field "vars" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/Identity.php b/src/Appwrite/Models/Identity.php index 7b208ff5..d7cc7c47 100644 --- a/src/Appwrite/Models/Identity.php +++ b/src/Appwrite/Models/Identity.php @@ -26,7 +26,7 @@ * @param string $providerAccessToken identity provider access token. * @param string $providerAccessTokenExpiry the date of when the access token expires in iso 8601 format. * @param string $providerRefreshToken identity provider refresh token. - * @param string|null $providerIdToken identity provider id token (jwt) from the most recent native sign-in. empty for identities created through the browser oauth2 flow. + * @param string $providerIdToken identity provider id token (jwt) from the most recent native sign-in. empty for identities created through the browser oauth2 flow. */ public function __construct( public string $id, @@ -39,7 +39,7 @@ public function __construct( public string $providerAccessToken, public string $providerAccessTokenExpiry, public string $providerRefreshToken, - public ?string $providerIdToken = null + public string $providerIdToken ) { } @@ -59,6 +59,7 @@ public static function from(array $data): static 'providerAccessToken' => "", 'providerAccessTokenExpiry' => "", 'providerRefreshToken' => "", + 'providerIdToken' => "", ]; return new static( @@ -72,7 +73,7 @@ public static function from(array $data): static providerAccessToken: $data['providerAccessToken'], providerAccessTokenExpiry: $data['providerAccessTokenExpiry'], providerRefreshToken: $data['providerRefreshToken'], - providerIdToken: $data['providerIdToken'] ?? null + providerIdToken: $data['providerIdToken'] ); } diff --git a/src/Appwrite/Models/IdentityList.php b/src/Appwrite/Models/IdentityList.php index f16cced6..d999ce18 100644 --- a/src/Appwrite/Models/IdentityList.php +++ b/src/Appwrite/Models/IdentityList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'identities' => [], ]; - if (!array_key_exists('identities', $data)) { - throw new \InvalidArgumentException('Missing required field "identities" for ' . static::class . '.'); - } - return new static( total: $data['total'], identities: is_array($data['identities']) diff --git a/src/Appwrite/Models/IndexList.php b/src/Appwrite/Models/IndexList.php index 4f2fbb8e..b9c1b65d 100644 --- a/src/Appwrite/Models/IndexList.php +++ b/src/Appwrite/Models/IndexList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'indexes' => [], ]; - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( total: $data['total'], indexes: is_array($data['indexes']) diff --git a/src/Appwrite/Models/Insight.php b/src/Appwrite/Models/Insight.php index b5b50f95..f05df485 100644 --- a/src/Appwrite/Models/Insight.php +++ b/src/Appwrite/Models/Insight.php @@ -74,12 +74,9 @@ public static function from(array $data): static 'parentResourceId' => "", 'title' => "", 'summary' => "", + 'ctas' => [], ]; - if (!array_key_exists('ctas', $data)) { - throw new \InvalidArgumentException('Missing required field "ctas" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/InsightList.php b/src/Appwrite/Models/InsightList.php index dfa3e4a9..3eee4fe6 100644 --- a/src/Appwrite/Models/InsightList.php +++ b/src/Appwrite/Models/InsightList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'insights' => [], ]; - if (!array_key_exists('insights', $data)) { - throw new \InvalidArgumentException('Missing required field "insights" for ' . static::class . '.'); - } - return new static( total: $data['total'], insights: is_array($data['insights']) diff --git a/src/Appwrite/Models/Key.php b/src/Appwrite/Models/Key.php index 216deb87..6b8e6841 100644 --- a/src/Appwrite/Models/Key.php +++ b/src/Appwrite/Models/Key.php @@ -53,12 +53,9 @@ public static function from(array $data): static 'scopes' => [], 'secret' => "", 'accessedAt' => "", + 'sdks' => [], ]; - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/KeyList.php b/src/Appwrite/Models/KeyList.php index 042450fb..92c164b9 100644 --- a/src/Appwrite/Models/KeyList.php +++ b/src/Appwrite/Models/KeyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'keys' => [], ]; - if (!array_key_exists('keys', $data)) { - throw new \InvalidArgumentException('Missing required field "keys" for ' . static::class . '.'); - } - return new static( total: $data['total'], keys: is_array($data['keys']) diff --git a/src/Appwrite/Models/LanguageList.php b/src/Appwrite/Models/LanguageList.php index 6a57c4b8..7cf1275f 100644 --- a/src/Appwrite/Models/LanguageList.php +++ b/src/Appwrite/Models/LanguageList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'languages' => [], ]; - if (!array_key_exists('languages', $data)) { - throw new \InvalidArgumentException('Missing required field "languages" for ' . static::class . '.'); - } - return new static( total: $data['total'], languages: is_array($data['languages']) diff --git a/src/Appwrite/Models/LocaleCodeList.php b/src/Appwrite/Models/LocaleCodeList.php index 59223a66..a9f1dfcd 100644 --- a/src/Appwrite/Models/LocaleCodeList.php +++ b/src/Appwrite/Models/LocaleCodeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'localeCodes' => [], ]; - if (!array_key_exists('localeCodes', $data)) { - throw new \InvalidArgumentException('Missing required field "localeCodes" for ' . static::class . '.'); - } - return new static( total: $data['total'], localeCodes: is_array($data['localeCodes']) diff --git a/src/Appwrite/Models/Log.php b/src/Appwrite/Models/Log.php deleted file mode 100644 index 01bfb02f..00000000 --- a/src/Appwrite/Models/Log.php +++ /dev/null @@ -1,196 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('event', $data)) { - throw new \InvalidArgumentException('Missing required field "event" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('userEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "userEmail" for ' . static::class . '.'); - } - if (!array_key_exists('userName', $data)) { - throw new \InvalidArgumentException('Missing required field "userName" for ' . static::class . '.'); - } - if (!array_key_exists('mode', $data)) { - throw new \InvalidArgumentException('Missing required field "mode" for ' . static::class . '.'); - } - if (!array_key_exists('userType', $data)) { - throw new \InvalidArgumentException('Missing required field "userType" for ' . static::class . '.'); - } - if (!array_key_exists('ip', $data)) { - throw new \InvalidArgumentException('Missing required field "ip" for ' . static::class . '.'); - } - if (!array_key_exists('time', $data)) { - throw new \InvalidArgumentException('Missing required field "time" for ' . static::class . '.'); - } - if (!array_key_exists('osCode', $data)) { - throw new \InvalidArgumentException('Missing required field "osCode" for ' . static::class . '.'); - } - if (!array_key_exists('osName', $data)) { - throw new \InvalidArgumentException('Missing required field "osName" for ' . static::class . '.'); - } - if (!array_key_exists('osVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "osVersion" for ' . static::class . '.'); - } - if (!array_key_exists('clientType', $data)) { - throw new \InvalidArgumentException('Missing required field "clientType" for ' . static::class . '.'); - } - if (!array_key_exists('clientCode', $data)) { - throw new \InvalidArgumentException('Missing required field "clientCode" for ' . static::class . '.'); - } - if (!array_key_exists('clientName', $data)) { - throw new \InvalidArgumentException('Missing required field "clientName" for ' . static::class . '.'); - } - if (!array_key_exists('clientVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "clientVersion" for ' . static::class . '.'); - } - if (!array_key_exists('clientEngine', $data)) { - throw new \InvalidArgumentException('Missing required field "clientEngine" for ' . static::class . '.'); - } - if (!array_key_exists('clientEngineVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "clientEngineVersion" for ' . static::class . '.'); - } - if (!array_key_exists('deviceName', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceName" for ' . static::class . '.'); - } - if (!array_key_exists('deviceBrand', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceBrand" for ' . static::class . '.'); - } - if (!array_key_exists('deviceModel', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceModel" 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( - event: $data['event'], - userId: $data['userId'], - userEmail: $data['userEmail'], - userName: $data['userName'], - mode: $data['mode'], - userType: $data['userType'], - ip: $data['ip'], - time: $data['time'], - osCode: $data['osCode'], - osName: $data['osName'], - osVersion: $data['osVersion'], - clientType: $data['clientType'], - clientCode: $data['clientCode'], - clientName: $data['clientName'], - clientVersion: $data['clientVersion'], - clientEngine: $data['clientEngine'], - clientEngineVersion: $data['clientEngineVersion'], - deviceName: $data['deviceName'], - deviceBrand: $data['deviceBrand'], - deviceModel: $data['deviceModel'], - countryCode: $data['countryCode'], - countryName: $data['countryName'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'event' => static::serializeValue($this->event), - 'userId' => static::serializeValue($this->userId), - 'userEmail' => static::serializeValue($this->userEmail), - 'userName' => static::serializeValue($this->userName), - 'mode' => static::serializeValue($this->mode), - 'userType' => static::serializeValue($this->userType), - 'ip' => static::serializeValue($this->ip), - 'time' => static::serializeValue($this->time), - 'osCode' => static::serializeValue($this->osCode), - 'osName' => static::serializeValue($this->osName), - 'osVersion' => static::serializeValue($this->osVersion), - 'clientType' => static::serializeValue($this->clientType), - 'clientCode' => static::serializeValue($this->clientCode), - 'clientName' => static::serializeValue($this->clientName), - 'clientVersion' => static::serializeValue($this->clientVersion), - 'clientEngine' => static::serializeValue($this->clientEngine), - 'clientEngineVersion' => static::serializeValue($this->clientEngineVersion), - 'deviceName' => static::serializeValue($this->deviceName), - 'deviceBrand' => static::serializeValue($this->deviceBrand), - 'deviceModel' => static::serializeValue($this->deviceModel), - 'countryCode' => static::serializeValue($this->countryCode), - 'countryName' => static::serializeValue($this->countryName) - ]; - } -} diff --git a/src/Appwrite/Models/LogList.php b/src/Appwrite/Models/LogList.php deleted file mode 100644 index 944b82ca..00000000 --- a/src/Appwrite/Models/LogList.php +++ /dev/null @@ -1,61 +0,0 @@ - $logs list of logs. - */ - public function __construct( - public int $total, - public array $logs - ) { - } - - /** - * @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('logs', $data)) { - throw new \InvalidArgumentException('Missing required field "logs" for ' . static::class . '.'); - } - - return new static( - total: $data['total'], - logs: is_array($data['logs']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(Log::class, $item), - $data['logs'] - ) - : $data['logs'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'total' => static::serializeValue($this->total), - 'logs' => static::serializeValue($this->logs) - ]; - } -} diff --git a/src/Appwrite/Models/MembershipList.php b/src/Appwrite/Models/MembershipList.php index 48529162..ece0e4b1 100644 --- a/src/Appwrite/Models/MembershipList.php +++ b/src/Appwrite/Models/MembershipList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'memberships' => [], ]; - if (!array_key_exists('memberships', $data)) { - throw new \InvalidArgumentException('Missing required field "memberships" for ' . static::class . '.'); - } - return new static( total: $data['total'], memberships: is_array($data['memberships']) diff --git a/src/Appwrite/Models/Message.php b/src/Appwrite/Models/Message.php index 267901bc..3d6ea590 100644 --- a/src/Appwrite/Models/Message.php +++ b/src/Appwrite/Models/Message.php @@ -59,21 +59,14 @@ public static function from(array $data): static '$createdAt' => "", '$updatedAt' => "", 'providerType' => "", + 'topics' => [], + 'users' => [], + 'targets' => [], 'deliveredTotal' => 0, 'data' => [], 'status' => "draft", ]; - if (!array_key_exists('topics', $data)) { - throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); - } - if (!array_key_exists('users', $data)) { - throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); - } - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/MessageList.php b/src/Appwrite/Models/MessageList.php index ea36b3e9..0f341543 100644 --- a/src/Appwrite/Models/MessageList.php +++ b/src/Appwrite/Models/MessageList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'messages' => [], ]; - if (!array_key_exists('messages', $data)) { - throw new \InvalidArgumentException('Missing required field "messages" for ' . static::class . '.'); - } - return new static( total: $data['total'], messages: is_array($data['messages']) diff --git a/src/Appwrite/Models/MockNumberList.php b/src/Appwrite/Models/MockNumberList.php index 60291620..b444d1b0 100644 --- a/src/Appwrite/Models/MockNumberList.php +++ b/src/Appwrite/Models/MockNumberList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'mockNumbers' => [], ]; - if (!array_key_exists('mockNumbers', $data)) { - throw new \InvalidArgumentException('Missing required field "mockNumbers" for ' . static::class . '.'); - } - return new static( total: $data['total'], mockNumbers: is_array($data['mockNumbers']) diff --git a/src/Appwrite/Models/OAuth2Apple.php b/src/Appwrite/Models/OAuth2Apple.php index 91b6b61c..0e9d8915 100644 --- a/src/Appwrite/Models/OAuth2Apple.php +++ b/src/Appwrite/Models/OAuth2Apple.php @@ -22,8 +22,8 @@ * @param string $keyId apple oauth2 key id. * @param string $teamId apple oauth2 team id. * @param string $p8File apple oauth2 .p8 private key file contents. the secret key wrapped by the pem markers is 200 characters long. - * @param bool|null $nativeEnabled native sign in with apple is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. - * @param array|null $nativeClientIds app bundle ids accepted as id token audiences for native sign in with apple, next to the services id. + * @param bool $nativeEnabled native sign in with apple is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. + * @param array $nativeClientIds app bundle ids accepted as id token audiences for native sign in with apple, next to the services id. */ public function __construct( public string $id, @@ -32,8 +32,8 @@ public function __construct( public string $keyId, public string $teamId, public string $p8File, - public ?bool $nativeEnabled = null, - public ?array $nativeClientIds = null + public bool $nativeEnabled, + public array $nativeClientIds ) { } @@ -49,6 +49,8 @@ public static function from(array $data): static 'keyId' => "", 'teamId' => "", 'p8File' => "", + 'nativeEnabled' => false, + 'nativeClientIds' => [], ]; return new static( @@ -58,8 +60,8 @@ public static function from(array $data): static keyId: $data['keyId'], teamId: $data['teamId'], p8File: $data['p8File'], - nativeEnabled: $data['nativeEnabled'] ?? null, - nativeClientIds: $data['nativeClientIds'] ?? null + nativeEnabled: $data['nativeEnabled'], + nativeClientIds: $data['nativeClientIds'] ); } diff --git a/src/Appwrite/Models/OAuth2Auth0.php b/src/Appwrite/Models/OAuth2Auth0.php index 2e119529..6f13390d 100644 --- a/src/Appwrite/Models/OAuth2Auth0.php +++ b/src/Appwrite/Models/OAuth2Auth0.php @@ -22,16 +22,16 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId auth0 oauth2 client id. * @param string $clientSecret auth0 oauth2 client secret. + * @param list $prompt auth0 oauth2 prompt values. * @param string $endpoint auth0 oauth2 endpoint domain. - * @param list|null $prompt auth0 oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public string $endpoint, - public ?array $prompt = null + public array $prompt, + public string $endpoint ) { } @@ -45,6 +45,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'endpoint' => "", ]; @@ -53,17 +54,13 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - endpoint: $data['endpoint'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2Auth0Prompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2Auth0Prompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'], + endpoint: $data['endpoint'] ); } diff --git a/src/Appwrite/Models/OAuth2Discord.php b/src/Appwrite/Models/OAuth2Discord.php index 34d4d3d0..6f1866f7 100644 --- a/src/Appwrite/Models/OAuth2Discord.php +++ b/src/Appwrite/Models/OAuth2Discord.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId discord oauth2 client id. * @param string $clientSecret discord oauth2 client secret. - * @param list|null $prompt discord oauth2 prompt values. + * @param list $prompt discord oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2DiscordPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2DiscordPrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'] ); } diff --git a/src/Appwrite/Models/OAuth2Github.php b/src/Appwrite/Models/OAuth2Github.php index 3e40437f..add2cfba 100644 --- a/src/Appwrite/Models/OAuth2Github.php +++ b/src/Appwrite/Models/OAuth2Github.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId github oauth2 client id. for github apps, use the "app id" when both an app id and client id are available. * @param string $clientSecret github oauth2 client secret. - * @param list|null $prompt github oauth2 prompt values. + * @param list $prompt github oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GithubPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GithubPrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'] ); } diff --git a/src/Appwrite/Models/OAuth2Google.php b/src/Appwrite/Models/OAuth2Google.php index ac2a6bef..4c9d2eb4 100644 --- a/src/Appwrite/Models/OAuth2Google.php +++ b/src/Appwrite/Models/OAuth2Google.php @@ -23,8 +23,8 @@ * @param string $clientId google oauth2 client id. * @param string $clientSecret google oauth2 client secret. * @param list $prompt google oauth2 prompt values. - * @param bool|null $nativeEnabled native google sign-in is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. - * @param array|null $nativeClientIds additional oauth2 client ids accepted as id token audiences for native sign-in, next to the client id. + * @param bool $nativeEnabled native google sign-in is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. + * @param array $nativeClientIds additional oauth2 client ids accepted as id token audiences for native sign-in, next to the client id. */ public function __construct( public string $id, @@ -32,8 +32,8 @@ public function __construct( public string $clientId, public string $clientSecret, public array $prompt, - public ?bool $nativeEnabled = null, - public ?array $nativeClientIds = null + public bool $nativeEnabled, + public array $nativeClientIds ) { } @@ -48,6 +48,8 @@ public static function from(array $data): static 'clientId' => "", 'clientSecret' => "", 'prompt' => ["consent"], + 'nativeEnabled' => false, + 'nativeClientIds' => [], ]; return new static( @@ -61,8 +63,8 @@ public static function from(array $data): static $data['prompt'] ) : $data['prompt'], - nativeEnabled: $data['nativeEnabled'] ?? null, - nativeClientIds: $data['nativeClientIds'] ?? null + nativeEnabled: $data['nativeEnabled'], + nativeClientIds: $data['nativeClientIds'] ); } diff --git a/src/Appwrite/Models/OAuth2Microsoft.php b/src/Appwrite/Models/OAuth2Microsoft.php index 12cddc22..e0e855b3 100644 --- a/src/Appwrite/Models/OAuth2Microsoft.php +++ b/src/Appwrite/Models/OAuth2Microsoft.php @@ -22,16 +22,16 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $applicationId microsoft oauth2 application id. * @param string $applicationSecret microsoft oauth2 application secret. + * @param list $prompt microsoft oauth2 prompt values. * @param string $tenant microsoft entra id tenant identifier. use 'common', 'organizations', 'consumers' or a specific tenant id. - * @param list|null $prompt microsoft oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $applicationId, public string $applicationSecret, - public string $tenant, - public ?array $prompt = null + public array $prompt, + public string $tenant ) { } @@ -45,6 +45,7 @@ public static function from(array $data): static 'enabled' => false, 'applicationId' => "", 'applicationSecret' => "", + 'prompt' => [], 'tenant' => "", ]; @@ -53,17 +54,13 @@ public static function from(array $data): static enabled: $data['enabled'], applicationId: $data['applicationId'], applicationSecret: $data['applicationSecret'], - tenant: $data['tenant'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2MicrosoftPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2MicrosoftPrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'], + tenant: $data['tenant'] ); } diff --git a/src/Appwrite/Models/OAuth2Oidc.php b/src/Appwrite/Models/OAuth2Oidc.php index 3f4a32f6..07547037 100644 --- a/src/Appwrite/Models/OAuth2Oidc.php +++ b/src/Appwrite/Models/OAuth2Oidc.php @@ -22,11 +22,11 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId openid connect oauth2 client id. * @param string $clientSecret openid connect oauth2 client secret. + * @param list $prompt openid connect prompt values controlling the authentication and consent screens. * @param string $wellKnownURL openid connect well-known configuration url. when set, authorization, token, and user info endpoints can be discovered automatically. * @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( @@ -34,11 +34,11 @@ public function __construct( public bool $enabled, public string $clientId, public string $clientSecret, + public array $prompt, public string $wellKnownURL, public string $authorizationURL, public string $tokenURL, public string $userInfoURL, - public array $prompt, public ?int $maxAge = null ) { } @@ -53,11 +53,11 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'wellKnownURL' => "", 'authorizationURL' => "", 'tokenURL' => "", 'userInfoURL' => "", - 'prompt' => [], ]; return new static( @@ -65,16 +65,16 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - wellKnownURL: $data['wellKnownURL'], - authorizationURL: $data['authorizationURL'], - tokenURL: $data['tokenURL'], - userInfoURL: $data['userInfoURL'], prompt: is_array($data['prompt']) ? array_map( static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OidcPrompt::class, $item), $data['prompt'] ) : $data['prompt'], + wellKnownURL: $data['wellKnownURL'], + authorizationURL: $data['authorizationURL'], + tokenURL: $data['tokenURL'], + userInfoURL: $data['userInfoURL'], maxAge: $data['maxAge'] ?? null ); } @@ -89,11 +89,11 @@ public function toArray(): array 'enabled' => static::serializeValue($this->enabled), 'clientId' => static::serializeValue($this->clientId), 'clientSecret' => static::serializeValue($this->clientSecret), + 'prompt' => static::serializeValue($this->prompt), 'wellKnownURL' => static::serializeValue($this->wellKnownURL), 'authorizationURL' => static::serializeValue($this->authorizationURL), 'tokenURL' => static::serializeValue($this->tokenURL), 'userInfoURL' => static::serializeValue($this->userInfoURL), - 'prompt' => static::serializeValue($this->prompt), 'maxAge' => static::serializeValue($this->maxAge) ]; } diff --git a/src/Appwrite/Models/OAuth2Okta.php b/src/Appwrite/Models/OAuth2Okta.php index 10f220af..121607ee 100644 --- a/src/Appwrite/Models/OAuth2Okta.php +++ b/src/Appwrite/Models/OAuth2Okta.php @@ -22,18 +22,18 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId okta oauth2 client id. * @param string $clientSecret okta oauth2 client secret. + * @param list $prompt okta oauth2 prompt values. * @param string $domain okta oauth2 domain. * @param string $authorizationServerId okta oauth2 authorization server id. - * @param list|null $prompt okta oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, + public array $prompt, public string $domain, - public string $authorizationServerId, - public ?array $prompt = null + public string $authorizationServerId ) { } @@ -47,6 +47,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'domain' => "", 'authorizationServerId' => "", ]; @@ -56,18 +57,14 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - domain: $data['domain'], - authorizationServerId: $data['authorizationServerId'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OktaPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OktaPrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'], + domain: $data['domain'], + authorizationServerId: $data['authorizationServerId'] ); } diff --git a/src/Appwrite/Models/OAuth2ProviderList.php b/src/Appwrite/Models/OAuth2ProviderList.php index bd2607be..4e278802 100644 --- a/src/Appwrite/Models/OAuth2ProviderList.php +++ b/src/Appwrite/Models/OAuth2ProviderList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'providers' => [], ]; - if (!array_key_exists('providers', $data)) { - throw new \InvalidArgumentException('Missing required field "providers" for ' . static::class . '.'); - } - return new static( total: $data['total'], providers: $data['providers'] diff --git a/src/Appwrite/Models/OAuth2Salesforce.php b/src/Appwrite/Models/OAuth2Salesforce.php index bea4ea61..f48965c8 100644 --- a/src/Appwrite/Models/OAuth2Salesforce.php +++ b/src/Appwrite/Models/OAuth2Salesforce.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $customerKey salesforce oauth2 consumer key. * @param string $customerSecret salesforce oauth2 consumer secret. - * @param list|null $prompt salesforce oauth2 prompt values. + * @param list $prompt salesforce oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $customerKey, public string $customerSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'customerKey' => "", 'customerSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], customerKey: $data['customerKey'], customerSecret: $data['customerSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2SalesforcePrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2SalesforcePrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'] ); } diff --git a/src/Appwrite/Models/OAuth2Zoho.php b/src/Appwrite/Models/OAuth2Zoho.php index 31966c63..ba102619 100644 --- a/src/Appwrite/Models/OAuth2Zoho.php +++ b/src/Appwrite/Models/OAuth2Zoho.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId zoho oauth2 client id. * @param string $clientSecret zoho oauth2 client secret. - * @param list|null $prompt zoho oauth2 prompt values. + * @param list $prompt zoho oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2ZohoPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2ZohoPrompt::class, $item), + $data['prompt'] ) - : null + : $data['prompt'] ); } diff --git a/src/Appwrite/Models/Oauth2ConsentList.php b/src/Appwrite/Models/Oauth2ConsentList.php index 5b83a171..1397c04b 100644 --- a/src/Appwrite/Models/Oauth2ConsentList.php +++ b/src/Appwrite/Models/Oauth2ConsentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'consents' => [], ]; - if (!array_key_exists('consents', $data)) { - throw new \InvalidArgumentException('Missing required field "consents" for ' . static::class . '.'); - } - return new static( total: $data['total'], consents: is_array($data['consents']) diff --git a/src/Appwrite/Models/Oauth2ConsentTokenList.php b/src/Appwrite/Models/Oauth2ConsentTokenList.php index 0a0a7bb4..1b23700d 100644 --- a/src/Appwrite/Models/Oauth2ConsentTokenList.php +++ b/src/Appwrite/Models/Oauth2ConsentTokenList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tokens' => [], ]; - if (!array_key_exists('tokens', $data)) { - throw new \InvalidArgumentException('Missing required field "tokens" for ' . static::class . '.'); - } - return new static( total: $data['total'], tokens: is_array($data['tokens']) diff --git a/src/Appwrite/Models/Oauth2OrganizationList.php b/src/Appwrite/Models/Oauth2OrganizationList.php index 6549f554..c5134675 100644 --- a/src/Appwrite/Models/Oauth2OrganizationList.php +++ b/src/Appwrite/Models/Oauth2OrganizationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'organizations' => [], ]; - if (!array_key_exists('organizations', $data)) { - throw new \InvalidArgumentException('Missing required field "organizations" for ' . static::class . '.'); - } - return new static( total: $data['total'], organizations: is_array($data['organizations']) diff --git a/src/Appwrite/Models/Oauth2ProjectList.php b/src/Appwrite/Models/Oauth2ProjectList.php index 111dda83..ad709350 100644 --- a/src/Appwrite/Models/Oauth2ProjectList.php +++ b/src/Appwrite/Models/Oauth2ProjectList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'projects' => [], ]; - if (!array_key_exists('projects', $data)) { - throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); - } - return new static( total: $data['total'], projects: is_array($data['projects']) diff --git a/src/Appwrite/Models/Organization.php b/src/Appwrite/Models/Organization.php index 569bc18f..dbed5cbc 100644 --- a/src/Appwrite/Models/Organization.php +++ b/src/Appwrite/Models/Organization.php @@ -27,19 +27,19 @@ * @param string $billingPlanId organization's billing plan id. * @param BillingPlan $billingPlanDetails organization's billing plan. * @param string $billingEmail billing email set for the organization. - * @param string $billingStartDate billing cycle start date. - * @param string $billingCurrentInvoiceDate current invoice cycle start date. - * @param string $billingNextInvoiceDate next invoice cycle start date. - * @param int $billingTrialDays number of trial days. - * @param string $billingAggregationId current active aggregation id. - * @param string $billingInvoiceId current active aggregation id. - * @param string $paymentMethodId default payment method. * @param string $status team status. * @param bool $markedForDeletion marked for deletion * @param string $platform product with which the organization is associated (appwrite or imagine) * @param array $projects selected projects * @param int|null $billingBudget project budget limit. null when no budget is set. + * @param string|null $billingStartDate billing cycle start date. + * @param string|null $billingCurrentInvoiceDate current invoice cycle start date. + * @param string|null $billingNextInvoiceDate next invoice cycle start date. * @param string|null $billingTrialStartDate start date of trial. + * @param int|null $billingTrialDays number of trial days. + * @param string|null $billingAggregationId current active aggregation id. + * @param string|null $billingInvoiceId current active aggregation id. + * @param string|null $paymentMethodId default payment method. * @param string|null $billingAddressId default payment method. * @param string|null $backupPaymentMethodId backup payment method. * @param string|null $remarks remarks on team status. @@ -64,19 +64,19 @@ public function __construct( public string $billingPlanId, public BillingPlan $billingPlanDetails, public string $billingEmail, - public string $billingStartDate, - public string $billingCurrentInvoiceDate, - public string $billingNextInvoiceDate, - public int $billingTrialDays, - public string $billingAggregationId, - public string $billingInvoiceId, - public string $paymentMethodId, public string $status, public bool $markedForDeletion, public string $platform, public array $projects, public ?int $billingBudget = null, + public ?string $billingStartDate = null, + public ?string $billingCurrentInvoiceDate = null, + public ?string $billingNextInvoiceDate = null, public ?string $billingTrialStartDate = null, + public ?int $billingTrialDays = null, + public ?string $billingAggregationId = null, + public ?string $billingInvoiceId = null, + public ?string $paymentMethodId = null, public ?string $billingAddressId = null, public ?string $backupPaymentMethodId = null, public ?string $remarks = null, @@ -118,27 +118,6 @@ public static function from(array $data): static if (!array_key_exists('billingPlanDetails', $data)) { throw new \InvalidArgumentException('Missing required field "billingPlanDetails" 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('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 . '.'); - } return new static( id: $data['$id'], @@ -152,19 +131,19 @@ public static function from(array $data): static billingPlanId: $data['billingPlanId'], billingPlanDetails: static::hydrateTypedValue(BillingPlan::class, $data['billingPlanDetails']), billingEmail: $data['billingEmail'], - billingStartDate: $data['billingStartDate'], - billingCurrentInvoiceDate: $data['billingCurrentInvoiceDate'], - billingNextInvoiceDate: $data['billingNextInvoiceDate'], - billingTrialDays: $data['billingTrialDays'], - billingAggregationId: $data['billingAggregationId'], - billingInvoiceId: $data['billingInvoiceId'], - paymentMethodId: $data['paymentMethodId'], status: $data['status'], markedForDeletion: $data['markedForDeletion'], platform: $data['platform'], projects: $data['projects'], billingBudget: $data['billingBudget'] ?? null, + billingStartDate: $data['billingStartDate'] ?? null, + billingCurrentInvoiceDate: $data['billingCurrentInvoiceDate'] ?? null, + billingNextInvoiceDate: $data['billingNextInvoiceDate'] ?? null, billingTrialStartDate: $data['billingTrialStartDate'] ?? null, + billingTrialDays: $data['billingTrialDays'] ?? null, + billingAggregationId: $data['billingAggregationId'] ?? null, + billingInvoiceId: $data['billingInvoiceId'] ?? null, + paymentMethodId: $data['paymentMethodId'] ?? null, billingAddressId: $data['billingAddressId'] ?? null, backupPaymentMethodId: $data['backupPaymentMethodId'] ?? null, remarks: $data['remarks'] ?? null, diff --git a/src/Appwrite/Models/Passkey.php b/src/Appwrite/Models/Passkey.php index 19e27794..61233db4 100644 --- a/src/Appwrite/Models/Passkey.php +++ b/src/Appwrite/Models/Passkey.php @@ -36,21 +36,13 @@ public function __construct( */ 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('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'accessedAt' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PasskeyChallenge.php b/src/Appwrite/Models/PasskeyChallenge.php index bb415366..c0ba66ca 100644 --- a/src/Appwrite/Models/PasskeyChallenge.php +++ b/src/Appwrite/Models/PasskeyChallenge.php @@ -36,21 +36,13 @@ public function __construct( */ 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('passkeyId', $data)) { - throw new \InvalidArgumentException('Missing required field "passkeyId" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('publicKey', $data)) { - throw new \InvalidArgumentException('Missing required field "publicKey" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'passkeyId' => "", + 'expire' => "", + 'publicKey' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PasskeyList.php b/src/Appwrite/Models/PasskeyList.php index f9506e55..7ef3d4b0 100644 --- a/src/Appwrite/Models/PasskeyList.php +++ b/src/Appwrite/Models/PasskeyList.php @@ -30,12 +30,10 @@ public function __construct( */ 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('passkeys', $data)) { - throw new \InvalidArgumentException('Missing required field "passkeys" for ' . static::class . '.'); - } + $data += [ + 'total' => 0, + 'passkeys' => [], + ]; return new static( total: $data['total'], diff --git a/src/Appwrite/Models/PhoneList.php b/src/Appwrite/Models/PhoneList.php index ac802484..318a2782 100644 --- a/src/Appwrite/Models/PhoneList.php +++ b/src/Appwrite/Models/PhoneList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'phones' => [], ]; - if (!array_key_exists('phones', $data)) { - throw new \InvalidArgumentException('Missing required field "phones" for ' . static::class . '.'); - } - return new static( total: $data['total'], phones: is_array($data['phones']) diff --git a/src/Appwrite/Models/PlatformAndroid.php b/src/Appwrite/Models/PlatformAndroid.php index 246df74b..bc9f9662 100644 --- a/src/Appwrite/Models/PlatformAndroid.php +++ b/src/Appwrite/Models/PlatformAndroid.php @@ -24,7 +24,7 @@ * @param string $name platform name. * @param PlatformType $type platform type. possible values are: windows, apple, android, linux, web. * @param string $applicationId android application id. - * @param array|null $fingerprints sha-256 fingerprints of the certificates the app is signed with. passkeys created in the app are accepted when its signature matches one. + * @param array $fingerprints sha-256 fingerprints of the certificates the app is signed with. passkeys created in the app are accepted when its signature matches one. */ public function __construct( public string $id, @@ -33,7 +33,7 @@ public function __construct( public string $name, public PlatformType $type, public string $applicationId, - public ?array $fingerprints = null + public array $fingerprints ) { } @@ -48,6 +48,7 @@ public static function from(array $data): static '$updatedAt' => "", 'name' => "", 'applicationId' => "", + 'fingerprints' => [], ]; if (!array_key_exists('type', $data)) { @@ -61,7 +62,7 @@ public static function from(array $data): static name: $data['name'], type: static::hydrateTypedValue(PlatformType::class, $data['type']), applicationId: $data['applicationId'], - fingerprints: $data['fingerprints'] ?? null + fingerprints: $data['fingerprints'] ); } diff --git a/src/Appwrite/Models/PlatformList.php b/src/Appwrite/Models/PlatformList.php index c8d64a41..6819d824 100644 --- a/src/Appwrite/Models/PlatformList.php +++ b/src/Appwrite/Models/PlatformList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'platforms' => [], ]; - if (!array_key_exists('platforms', $data)) { - throw new \InvalidArgumentException('Missing required field "platforms" for ' . static::class . '.'); - } - return new static( total: $data['total'], platforms: $data['platforms'] diff --git a/src/Appwrite/Models/PolicyList.php b/src/Appwrite/Models/PolicyList.php index a1599a40..16069c98 100644 --- a/src/Appwrite/Models/PolicyList.php +++ b/src/Appwrite/Models/PolicyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'policies' => [], ]; - if (!array_key_exists('policies', $data)) { - throw new \InvalidArgumentException('Missing required field "policies" for ' . static::class . '.'); - } - return new static( total: $data['total'], policies: $data['policies'] diff --git a/src/Appwrite/Models/PolicyPasskey.php b/src/Appwrite/Models/PolicyPasskey.php index 5dd5735a..f094bda4 100644 --- a/src/Appwrite/Models/PolicyPasskey.php +++ b/src/Appwrite/Models/PolicyPasskey.php @@ -32,15 +32,11 @@ public function __construct( */ 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('rpId', $data)) { - throw new \InvalidArgumentException('Missing required field "rpId" for ' . static::class . '.'); - } - if (!array_key_exists('origins', $data)) { - throw new \InvalidArgumentException('Missing required field "origins" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'rpId' => "", + 'origins' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Presence.php b/src/Appwrite/Models/Presence.php index 95ae696c..bd211ffe 100644 --- a/src/Appwrite/Models/Presence.php +++ b/src/Appwrite/Models/Presence.php @@ -48,14 +48,11 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'userId' => "", 'source' => "", ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/PresenceList.php b/src/Appwrite/Models/PresenceList.php index c363e108..c2e12147 100644 --- a/src/Appwrite/Models/PresenceList.php +++ b/src/Appwrite/Models/PresenceList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'presences' => [], ]; - if (!array_key_exists('presences', $data)) { - throw new \InvalidArgumentException('Missing required field "presences" for ' . static::class . '.'); - } - return new static( total: $data['total'], presences: is_array($data['presences']) diff --git a/src/Appwrite/Models/Project.php b/src/Appwrite/Models/Project.php index 256193bd..9735a0d8 100644 --- a/src/Appwrite/Models/Project.php +++ b/src/Appwrite/Models/Project.php @@ -22,7 +22,6 @@ * @param string $name project name. * @param string $teamId project team id. * @param string $region project region - * @param list $devKeys deprecated since 1.9.5: list of dev keys. * @param bool $smtpEnabled status for custom smtp * @param string $smtpSenderName smtp sender name * @param string $smtpSenderEmail smtp sender email @@ -73,7 +72,6 @@ public function __construct( public string $name, public string $teamId, public string $region, - public array $devKeys, public bool $smtpEnabled, public string $smtpSenderName, public string $smtpSenderEmail, @@ -146,25 +144,13 @@ public static function from(array $data): static 'labels' => [], 'status' => "active", 'onboarding' => [], + 'authMethods' => [], + 'services' => [], + 'protocols' => [], + 'blocks' => [], 'consoleAccessedAt' => "", ]; - if (!array_key_exists('devKeys', $data)) { - throw new \InvalidArgumentException('Missing required field "devKeys" for ' . static::class . '.'); - } - if (!array_key_exists('authMethods', $data)) { - throw new \InvalidArgumentException('Missing required field "authMethods" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('protocols', $data)) { - throw new \InvalidArgumentException('Missing required field "protocols" for ' . static::class . '.'); - } - if (!array_key_exists('blocks', $data)) { - throw new \InvalidArgumentException('Missing required field "blocks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], @@ -172,12 +158,6 @@ public static function from(array $data): static name: $data['name'], teamId: $data['teamId'], region: $data['region'], - devKeys: is_array($data['devKeys']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(DevKey::class, $item), - $data['devKeys'] - ) - : $data['devKeys'], smtpEnabled: $data['smtpEnabled'], smtpSenderName: $data['smtpSenderName'], smtpSenderEmail: $data['smtpSenderEmail'], @@ -255,7 +235,6 @@ public function toArray(): array 'name' => static::serializeValue($this->name), 'teamId' => static::serializeValue($this->teamId), 'region' => static::serializeValue($this->region), - 'devKeys' => static::serializeValue($this->devKeys), 'smtpEnabled' => static::serializeValue($this->smtpEnabled), 'smtpSenderName' => static::serializeValue($this->smtpSenderName), 'smtpSenderEmail' => static::serializeValue($this->smtpSenderEmail), diff --git a/src/Appwrite/Models/ProjectList.php b/src/Appwrite/Models/ProjectList.php index f7261447..17d71c0c 100644 --- a/src/Appwrite/Models/ProjectList.php +++ b/src/Appwrite/Models/ProjectList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'projects' => [], ]; - if (!array_key_exists('projects', $data)) { - throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); - } - return new static( total: $data['total'], projects: is_array($data['projects']) diff --git a/src/Appwrite/Models/ProviderList.php b/src/Appwrite/Models/ProviderList.php index 68bbeb5d..bd6ba8ea 100644 --- a/src/Appwrite/Models/ProviderList.php +++ b/src/Appwrite/Models/ProviderList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'providers' => [], ]; - if (!array_key_exists('providers', $data)) { - throw new \InvalidArgumentException('Missing required field "providers" for ' . static::class . '.'); - } - return new static( total: $data['total'], providers: is_array($data['providers']) diff --git a/src/Appwrite/Models/ProxyRule.php b/src/Appwrite/Models/ProxyRule.php index cc9f7583..5caeec45 100644 --- a/src/Appwrite/Models/ProxyRule.php +++ b/src/Appwrite/Models/ProxyRule.php @@ -33,7 +33,7 @@ * @param ProxyRuleStatus $status domain verification status. possible values are "unverified", "verifying", "verified" * @param string $logs logs from rule verification or certificate generation. certificate generation logs are prioritized if both are available. * @param string $renewAt certificate auto-renewal date in iso 8601 format. - * @param ProxyRuleDeploymentResourceType|null $deploymentResourceType type of deployment. possible values are "function", "site". used if rule's type is "deployment". + * @param ProxyRuleDeploymentResourceType|null $deploymentResourceType type of deployment resource: function, site, or dedicateddatabase. */ public function __construct( public string $id, diff --git a/src/Appwrite/Models/ProxyRuleList.php b/src/Appwrite/Models/ProxyRuleList.php index 413058a4..ac83cabf 100644 --- a/src/Appwrite/Models/ProxyRuleList.php +++ b/src/Appwrite/Models/ProxyRuleList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'rules' => [], ]; - if (!array_key_exists('rules', $data)) { - throw new \InvalidArgumentException('Missing required field "rules" for ' . static::class . '.'); - } - return new static( total: $data['total'], rules: is_array($data['rules']) diff --git a/src/Appwrite/Models/Report.php b/src/Appwrite/Models/Report.php index 8ecd43f9..e004db96 100644 --- a/src/Appwrite/Models/Report.php +++ b/src/Appwrite/Models/Report.php @@ -61,12 +61,9 @@ public static function from(array $data): static 'targetType' => "", 'target' => "", 'categories' => [], + 'insights' => [], ]; - if (!array_key_exists('insights', $data)) { - throw new \InvalidArgumentException('Missing required field "insights" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/ReportList.php b/src/Appwrite/Models/ReportList.php index ea32a528..5e129d3d 100644 --- a/src/Appwrite/Models/ReportList.php +++ b/src/Appwrite/Models/ReportList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'reports' => [], ]; - if (!array_key_exists('reports', $data)) { - throw new \InvalidArgumentException('Missing required field "reports" for ' . static::class . '.'); - } - return new static( total: $data['total'], reports: is_array($data['reports']) diff --git a/src/Appwrite/Models/ResourceTokenList.php b/src/Appwrite/Models/ResourceTokenList.php index 2b9b1885..c50b4801 100644 --- a/src/Appwrite/Models/ResourceTokenList.php +++ b/src/Appwrite/Models/ResourceTokenList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tokens' => [], ]; - if (!array_key_exists('tokens', $data)) { - throw new \InvalidArgumentException('Missing required field "tokens" for ' . static::class . '.'); - } - return new static( total: $data['total'], tokens: is_array($data['tokens']) diff --git a/src/Appwrite/Models/Row.php b/src/Appwrite/Models/Row.php index d37ab8ab..1e323515 100644 --- a/src/Appwrite/Models/Row.php +++ b/src/Appwrite/Models/Row.php @@ -49,12 +49,9 @@ public static function from(array $data): static '$databaseId' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - $additionalProperties = static::extractAdditionalPropertiesFromFields( $data, [ diff --git a/src/Appwrite/Models/RowList.php b/src/Appwrite/Models/RowList.php index f5194b86..9cf05c07 100644 --- a/src/Appwrite/Models/RowList.php +++ b/src/Appwrite/Models/RowList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'rows' => [], ]; - if (!array_key_exists('rows', $data)) { - throw new \InvalidArgumentException('Missing required field "rows" for ' . static::class . '.'); - } - return new static( total: $data['total'], rows: is_array($data['rows']) diff --git a/src/Appwrite/Models/Runtime.php b/src/Appwrite/Models/Runtime.php index 6b51ebed..84aa814d 100644 --- a/src/Appwrite/Models/Runtime.php +++ b/src/Appwrite/Models/Runtime.php @@ -50,12 +50,9 @@ public static function from(array $data): static 'base' => "", 'image' => "", 'logo' => "", + 'supports' => [], ]; - if (!array_key_exists('supports', $data)) { - throw new \InvalidArgumentException('Missing required field "supports" for ' . static::class . '.'); - } - return new static( id: $data['$id'], key: $data['key'], diff --git a/src/Appwrite/Models/RuntimeList.php b/src/Appwrite/Models/RuntimeList.php index 32baecf3..c13abbcf 100644 --- a/src/Appwrite/Models/RuntimeList.php +++ b/src/Appwrite/Models/RuntimeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'runtimes' => [], ]; - if (!array_key_exists('runtimes', $data)) { - throw new \InvalidArgumentException('Missing required field "runtimes" for ' . static::class . '.'); - } - return new static( total: $data['total'], runtimes: is_array($data['runtimes']) diff --git a/src/Appwrite/Models/SessionList.php b/src/Appwrite/Models/SessionList.php index 33e062cc..d834c970 100644 --- a/src/Appwrite/Models/SessionList.php +++ b/src/Appwrite/Models/SessionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'sessions' => [], ]; - if (!array_key_exists('sessions', $data)) { - throw new \InvalidArgumentException('Missing required field "sessions" for ' . static::class . '.'); - } - return new static( total: $data['total'], sessions: is_array($data['sessions']) diff --git a/src/Appwrite/Models/Site.php b/src/Appwrite/Models/Site.php index 671bb5d4..3b00ca02 100644 --- a/src/Appwrite/Models/Site.php +++ b/src/Appwrite/Models/Site.php @@ -114,6 +114,7 @@ public static function from(array $data): static 'latestDeploymentCreatedAt' => "", 'latestDeploymentStatus' => "", 'scopes' => [], + 'vars' => [], 'timeout' => 15, 'installCommand' => "", 'buildCommand' => "", @@ -131,9 +132,6 @@ public static function from(array $data): static 'buildRuntime' => "", ]; - if (!array_key_exists('vars', $data)) { - throw new \InvalidArgumentException('Missing required field "vars" for ' . static::class . '.'); - } if (!array_key_exists('adapter', $data)) { throw new \InvalidArgumentException('Missing required field "adapter" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/SiteList.php b/src/Appwrite/Models/SiteList.php index e3b32b48..2adcf105 100644 --- a/src/Appwrite/Models/SiteList.php +++ b/src/Appwrite/Models/SiteList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'sites' => [], ]; - if (!array_key_exists('sites', $data)) { - throw new \InvalidArgumentException('Missing required field "sites" for ' . static::class . '.'); - } - return new static( total: $data['total'], sites: is_array($data['sites']) diff --git a/src/Appwrite/Models/SpecificationList.php b/src/Appwrite/Models/SpecificationList.php index e48faded..117627c5 100644 --- a/src/Appwrite/Models/SpecificationList.php +++ b/src/Appwrite/Models/SpecificationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'specifications' => [], ]; - if (!array_key_exists('specifications', $data)) { - throw new \InvalidArgumentException('Missing required field "specifications" for ' . static::class . '.'); - } - return new static( total: $data['total'], specifications: is_array($data['specifications']) diff --git a/src/Appwrite/Models/SubscriberList.php b/src/Appwrite/Models/SubscriberList.php index 705cb0b5..cdd1819b 100644 --- a/src/Appwrite/Models/SubscriberList.php +++ b/src/Appwrite/Models/SubscriberList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'subscribers' => [], ]; - if (!array_key_exists('subscribers', $data)) { - throw new \InvalidArgumentException('Missing required field "subscribers" for ' . static::class . '.'); - } - return new static( total: $data['total'], subscribers: is_array($data['subscribers']) diff --git a/src/Appwrite/Models/Table.php b/src/Appwrite/Models/Table.php index 49869583..dc197d32 100644 --- a/src/Appwrite/Models/Table.php +++ b/src/Appwrite/Models/Table.php @@ -54,24 +54,17 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'rowSecurity' => false, + 'columns' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/TableList.php b/src/Appwrite/Models/TableList.php index c6352fb6..c3aa35fc 100644 --- a/src/Appwrite/Models/TableList.php +++ b/src/Appwrite/Models/TableList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tables' => [], ]; - if (!array_key_exists('tables', $data)) { - throw new \InvalidArgumentException('Missing required field "tables" for ' . static::class . '.'); - } - return new static( total: $data['total'], tables: is_array($data['tables']) diff --git a/src/Appwrite/Models/TargetList.php b/src/Appwrite/Models/TargetList.php index 8596f116..e68cdcf4 100644 --- a/src/Appwrite/Models/TargetList.php +++ b/src/Appwrite/Models/TargetList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'targets' => [], ]; - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } - return new static( total: $data['total'], targets: is_array($data['targets']) diff --git a/src/Appwrite/Models/TeamList.php b/src/Appwrite/Models/TeamList.php index 8c75339d..b9647882 100644 --- a/src/Appwrite/Models/TeamList.php +++ b/src/Appwrite/Models/TeamList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'teams' => [], ]; - if (!array_key_exists('teams', $data)) { - throw new \InvalidArgumentException('Missing required field "teams" for ' . static::class . '.'); - } - return new static( total: $data['total'], teams: is_array($data['teams']) diff --git a/src/Appwrite/Models/TokenSecret.php b/src/Appwrite/Models/TokenSecret.php index deedef6b..a9b879de 100644 --- a/src/Appwrite/Models/TokenSecret.php +++ b/src/Appwrite/Models/TokenSecret.php @@ -38,24 +38,14 @@ public function __construct( */ 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('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('phrase', $data)) { - throw new \InvalidArgumentException('Missing required field "phrase" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'userId' => "", + 'secret' => "", + 'expire' => "", + 'phrase' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Topic.php b/src/Appwrite/Models/Topic.php index 42f22386..4719c755 100644 --- a/src/Appwrite/Models/Topic.php +++ b/src/Appwrite/Models/Topic.php @@ -25,7 +25,7 @@ * @param int $pushTotal total count of push subscribers subscribed to the topic. * @param array $subscribe subscribe permissions. * @param int|null $qos mqtt qos for delivery on this topic. null lets the subscriber choose their level. - * @param int|null $expiry message retention in seconds for offline delivery. + * @param int|null $expiry message retention in seconds for offline delivery. null inherits the lowest expiry of the project's enabled appwrite providers, or the 7-day ledger window if none sets one. */ public function __construct( public string $id, diff --git a/src/Appwrite/Models/TopicList.php b/src/Appwrite/Models/TopicList.php index 4ba86969..48bbc421 100644 --- a/src/Appwrite/Models/TopicList.php +++ b/src/Appwrite/Models/TopicList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'topics' => [], ]; - if (!array_key_exists('topics', $data)) { - throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); - } - return new static( total: $data['total'], topics: is_array($data['topics']) diff --git a/src/Appwrite/Models/TransactionList.php b/src/Appwrite/Models/TransactionList.php index 7e17740d..92fd205d 100644 --- a/src/Appwrite/Models/TransactionList.php +++ b/src/Appwrite/Models/TransactionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'transactions' => [], ]; - if (!array_key_exists('transactions', $data)) { - throw new \InvalidArgumentException('Missing required field "transactions" for ' . static::class . '.'); - } - return new static( total: $data['total'], transactions: is_array($data['transactions']) diff --git a/src/Appwrite/Models/UsageBillingPlan.php b/src/Appwrite/Models/UsageBillingPlan.php index eb9cab99..1db3b763 100644 --- a/src/Appwrite/Models/UsageBillingPlan.php +++ b/src/Appwrite/Models/UsageBillingPlan.php @@ -16,29 +16,29 @@ /** * UsageBillingPlan constructor. * - * @param AdditionalResource $bandwidth bandwidth additional resources - * @param AdditionalResource $executions executions additional resources - * @param AdditionalResource $realtime realtime additional resources - * @param AdditionalResource $realtimeMessages realtime messages additional resources - * @param AdditionalResource $storage storage additional resources - * @param AdditionalResource $users user additional resources - * @param AdditionalResource $gBHours gbhour additional resources - * @param AdditionalResource $imageTransformations image transformation additional resources + * @param AdditionalResource|null $bandwidth bandwidth additional resources + * @param AdditionalResource|null $executions executions additional resources * @param AdditionalResource|null $member member additional resources + * @param AdditionalResource|null $realtime realtime additional resources + * @param AdditionalResource|null $realtimeMessages realtime messages additional resources * @param AdditionalResource|null $realtimeBandwidth realtime bandwidth additional resources + * @param AdditionalResource|null $storage storage additional resources + * @param AdditionalResource|null $users user additional resources + * @param AdditionalResource|null $gBHours gbhour additional resources + * @param AdditionalResource|null $imageTransformations image transformation additional resources * @param AdditionalResource|null $credits credits additional resources */ public function __construct( - public AdditionalResource $bandwidth, - public AdditionalResource $executions, - public AdditionalResource $realtime, - public AdditionalResource $realtimeMessages, - public AdditionalResource $storage, - public AdditionalResource $users, - public AdditionalResource $gBHours, - public AdditionalResource $imageTransformations, + public ?AdditionalResource $bandwidth = null, + public ?AdditionalResource $executions = null, public ?AdditionalResource $member = null, + public ?AdditionalResource $realtime = null, + public ?AdditionalResource $realtimeMessages = null, public ?AdditionalResource $realtimeBandwidth = null, + public ?AdditionalResource $storage = null, + public ?AdditionalResource $users = null, + public ?AdditionalResource $gBHours = null, + public ?AdditionalResource $imageTransformations = null, public ?AdditionalResource $credits = null ) { } @@ -48,42 +48,18 @@ public function __construct( */ 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('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('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 . '.'); - } return new static( - bandwidth: static::hydrateTypedValue(AdditionalResource::class, $data['bandwidth']), - executions: static::hydrateTypedValue(AdditionalResource::class, $data['executions']), - realtime: static::hydrateTypedValue(AdditionalResource::class, $data['realtime']), - realtimeMessages: static::hydrateTypedValue(AdditionalResource::class, $data['realtimeMessages']), - 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']), + bandwidth: array_key_exists('bandwidth', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['bandwidth'], true) : null, + executions: array_key_exists('executions', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['executions'], true) : null, member: array_key_exists('member', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['member'], true) : null, + realtime: array_key_exists('realtime', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtime'], true) : null, + realtimeMessages: array_key_exists('realtimeMessages', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtimeMessages'], true) : null, realtimeBandwidth: array_key_exists('realtimeBandwidth', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtimeBandwidth'], true) : null, + storage: array_key_exists('storage', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['storage'], true) : null, + users: array_key_exists('users', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['users'], true) : null, + gBHours: array_key_exists('GBHours', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['GBHours'], true) : null, + imageTransformations: array_key_exists('imageTransformations', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['imageTransformations'], true) : null, credits: array_key_exists('credits', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['credits'], true) : null ); } diff --git a/src/Appwrite/Models/User.php b/src/Appwrite/Models/User.php index 476c9802..57c6d397 100644 --- a/src/Appwrite/Models/User.php +++ b/src/Appwrite/Models/User.php @@ -94,15 +94,13 @@ public static function from(array $data): static 'emailVerification' => false, 'phoneVerification' => false, 'mfa' => false, + 'targets' => [], 'accessedAt' => "", ]; if (!array_key_exists('prefs', $data)) { throw new \InvalidArgumentException('Missing required field "prefs" for ' . static::class . '.'); } - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/UserList.php b/src/Appwrite/Models/UserList.php index 8c4d99d0..b3c9b38c 100644 --- a/src/Appwrite/Models/UserList.php +++ b/src/Appwrite/Models/UserList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'users' => [], ]; - if (!array_key_exists('users', $data)) { - throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); - } - return new static( total: $data['total'], users: is_array($data['users']) diff --git a/src/Appwrite/Models/VariableList.php b/src/Appwrite/Models/VariableList.php index 698af61c..9a8ae59b 100644 --- a/src/Appwrite/Models/VariableList.php +++ b/src/Appwrite/Models/VariableList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'variables' => [], ]; - if (!array_key_exists('variables', $data)) { - throw new \InvalidArgumentException('Missing required field "variables" for ' . static::class . '.'); - } - return new static( total: $data['total'], variables: is_array($data['variables']) diff --git a/src/Appwrite/Models/VectorsdbCollection.php b/src/Appwrite/Models/VectorsdbCollection.php index 38e5ec63..1ec525b7 100644 --- a/src/Appwrite/Models/VectorsdbCollection.php +++ b/src/Appwrite/Models/VectorsdbCollection.php @@ -56,25 +56,18 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'documentSecurity' => false, + 'attributes' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, 'dimension' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/VectorsdbCollectionList.php b/src/Appwrite/Models/VectorsdbCollectionList.php index e5c2c05c..8e414ae9 100644 --- a/src/Appwrite/Models/VectorsdbCollectionList.php +++ b/src/Appwrite/Models/VectorsdbCollectionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'collections' => [], ]; - if (!array_key_exists('collections', $data)) { - throw new \InvalidArgumentException('Missing required field "collections" for ' . static::class . '.'); - } - return new static( total: $data['total'], collections: is_array($data['collections']) diff --git a/src/Appwrite/Models/Webhook.php b/src/Appwrite/Models/Webhook.php index 9f1bef97..4df57b11 100644 --- a/src/Appwrite/Models/Webhook.php +++ b/src/Appwrite/Models/Webhook.php @@ -24,7 +24,7 @@ * @param array $events webhook trigger events. * @param bool $tls indicates if ssl / tls certificate verification is enabled. * @param string $authUsername http basic authentication username. - * @param string $authPassword http basic authentication password. + * @param string $authPassword http basic authentication password. write-only: always returned empty. * @param string $secret signature key which can be used to validate incoming webhook payloads. only returned on creation and secret rotation. * @param bool $enabled indicates if this webhook is enabled. * @param string $logs webhook error logs from the most recent failure. diff --git a/src/Appwrite/Models/WebhookList.php b/src/Appwrite/Models/WebhookList.php index dafb70d4..9ff66138 100644 --- a/src/Appwrite/Models/WebhookList.php +++ b/src/Appwrite/Models/WebhookList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'webhooks' => [], ]; - if (!array_key_exists('webhooks', $data)) { - throw new \InvalidArgumentException('Missing required field "webhooks" for ' . static::class . '.'); - } - return new static( total: $data['total'], webhooks: is_array($data['webhooks']) diff --git a/src/Appwrite/ResolvedTopic.php b/src/Appwrite/ResolvedTopic.php new file mode 100644 index 00000000..5da62ff9 --- /dev/null +++ b/src/Appwrite/ResolvedTopic.php @@ -0,0 +1,43 @@ + $levels + */ + public function __construct(private array $levels) + { + } + + /** + * @param array $levels + */ + public function path(array $levels): never + { + throw new \BadMethodCallException('nothing can come after all()'); + } + + public function any(): never + { + throw new \BadMethodCallException('nothing can come after all()'); + } + + public function all(): never + { + throw new \BadMethodCallException('nothing can come after all()'); + } + + public function __toString(): string + { + return \implode('/', $this->levels); + } +} diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 6caf55ff..74a1925d 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -144,6 +144,10 @@ public function listConsents(?array $queries = null, ?bool $total = null): \Appw */ public function getConsent(string $consentId): \Appwrite\Models\Oauth2Consent { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -180,6 +184,10 @@ public function getConsent(string $consentId): \Appwrite\Models\Oauth2Consent */ public function deleteConsent(string $consentId): string { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -211,6 +219,10 @@ public function deleteConsent(string $consentId): string */ public function listConsentTokens(string $consentId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\Oauth2ConsentTokenList { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -254,6 +266,14 @@ public function listConsentTokens(string $consentId, ?array $queries = null, ?bo */ public function getConsentToken(string $consentId, string $tokenId): \Appwrite\Models\Oauth2ConsentToken { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{consentId}', '{tokenId}'], [$consentId, $tokenId], @@ -291,6 +311,14 @@ public function getConsentToken(string $consentId, string $tokenId): \Appwrite\M */ public function deleteConsentToken(string $consentId, string $tokenId): string { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{consentId}', '{tokenId}'], [$consentId, $tokenId], @@ -404,6 +432,10 @@ public function listIdentities(?array $queries = null, ?bool $total = null): \Ap */ public function deleteIdentity(string $identityId): string { + if ($identityId === '') { + throw new AppwriteException('Missing required parameter: "identityId"'); + } + $apiPath = str_replace( ['{identityId}'], [$identityId], @@ -416,6 +448,7 @@ public function deleteIdentity(string $identityId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -425,48 +458,6 @@ public function deleteIdentity(string $identityId): string ); } - /** - * Get the list of latest security activity logs for the currently logged in - * user. Each log returns user IP address, location and date and time of log. - * - * @throws AppwriteException - */ - public function listLogs(?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - [], - [], - '/account/logs' - ); - - $apiParams = []; - - 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); - } - /** * Enable or disable MFA on an account. * @@ -597,6 +588,7 @@ public function deleteMFAAuthenticator(AuthenticatorType $type): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1484,7 +1476,8 @@ public function listSessions(?bool $total = null): \Appwrite\Models\SessionList /** * Delete all sessions from the user account and remove any sessions cookies - * from the end client. + * from the end client. Pass `current` as false to keep the session making the + * request and sign out of every other session. * * @throws AppwriteException */ @@ -1505,6 +1498,7 @@ public function deleteSessions(?bool $current = null): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1557,6 +1551,9 @@ public function createAnonymousSession(): \Appwrite\Models\Session /** * Allow the user to login into their account by providing a valid email and * password combination. This route will create a new session for the user. + * Use the optional `duration` parameter to create a shorter session, for + * example when the user doesn't choose "remember me". It must be at least 60 + * seconds and cannot exceed the project maximum session length. * * A user is limited to 10 active sessions at a time by default. [Learn more * about session @@ -1816,6 +1813,10 @@ public function createSession(string $userId, string $secret): \Appwrite\Models\ */ public function getSession(string $sessionId): \Appwrite\Models\Session { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1852,6 +1853,10 @@ public function getSession(string $sessionId): \Appwrite\Models\Session */ public function updateSession(string $sessionId): \Appwrite\Models\Session { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1891,6 +1896,10 @@ public function updateSession(string $sessionId): \Appwrite\Models\Session */ public function deleteSession(string $sessionId): string { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1903,6 +1912,7 @@ public function deleteSession(string $sessionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2068,6 +2078,10 @@ public function createMagicURLToken(string $userId, string $email, ?string $url * session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) * endpoint. * + * If there is already an active session, the OAuth2 identity is attached to + * the logged-in account and that session stays active until the token is + * exchanged for a new one. + * * A user is limited to 10 active sessions at a time by default. [Learn more * about session * limits](https://appwrite.io/docs/authentication-security#limits). diff --git a/src/Appwrite/Services/Activities.php b/src/Appwrite/Services/Activities.php index 4cb0ebb3..c5398cf0 100644 --- a/src/Appwrite/Services/Activities.php +++ b/src/Appwrite/Services/Activities.php @@ -54,6 +54,10 @@ public function listEvents(?array $queries = null): \Appwrite\Models\ActivityEve */ public function getEvent(string $eventId): \Appwrite\Models\ActivityEvent { + if ($eventId === '') { + throw new AppwriteException('Missing required parameter: "eventId"'); + } + $apiPath = str_replace( ['{eventId}'], [$eventId], diff --git a/src/Appwrite/Services/Advisor.php b/src/Appwrite/Services/Advisor.php index c09f9170..cc99a1ea 100644 --- a/src/Appwrite/Services/Advisor.php +++ b/src/Appwrite/Services/Advisor.php @@ -60,6 +60,10 @@ public function listReports(?array $queries = null, ?bool $total = null): \Appwr */ public function getReport(string $reportId): \Appwrite\Models\Report { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -95,6 +99,10 @@ public function getReport(string $reportId): \Appwrite\Models\Report */ public function deleteReport(string $reportId): string { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -107,6 +115,7 @@ public function deleteReport(string $reportId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -124,6 +133,10 @@ public function deleteReport(string $reportId): string */ public function listInsights(string $reportId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\InsightList { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -166,6 +179,14 @@ public function listInsights(string $reportId, ?array $queries = null, ?bool $to */ public function getInsight(string $reportId, string $insightId): \Appwrite\Models\Insight { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + + if ($insightId === '') { + throw new AppwriteException('Missing required parameter: "insightId"'); + } + $apiPath = str_replace( ['{reportId}', '{insightId}'], [$reportId, $insightId], diff --git a/src/Appwrite/Services/Apps.php b/src/Appwrite/Services/Apps.php index c66741f0..64162fa7 100644 --- a/src/Appwrite/Services/Apps.php +++ b/src/Appwrite/Services/Apps.php @@ -225,6 +225,10 @@ public function listOAuth2Scopes(): \Appwrite\Models\AppScopeList */ public function get(string $appId): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -259,6 +263,10 @@ public function get(string $appId): \Appwrite\Models\App */ public function update(string $appId, string $name, ?string $description = null, ?string $clientUri = null, ?string $logoUri = null, ?string $privacyPolicyUrl = null, ?string $termsUrl = null, ?array $contacts = null, ?string $tagline = null, ?array $tags = null, ?array $images = null, ?string $supportUrl = null, ?string $dataDeletionUrl = null, ?bool $enabled = null, ?array $redirectUris = null, ?array $postLogoutRedirectUris = null, ?string $type = null, ?bool $deviceFlow = null, ?array $installationScopes = null, ?string $installationRedirectUrl = null): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -367,6 +375,10 @@ public function update(string $appId, string $name, ?string $description = null, */ public function delete(string $appId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -398,6 +410,10 @@ public function delete(string $appId): string */ public function listInstallations(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppInstallationList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -442,6 +458,14 @@ public function listInstallations(string $appId, ?array $queries = null, ?bool $ */ public function getInstallation(string $appId, string $installationId): \Appwrite\Models\AppInstallation { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -479,6 +503,14 @@ public function getInstallation(string $appId, string $installationId): \Appwrit */ public function deleteInstallation(string $appId, string $installationId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -516,6 +548,14 @@ public function deleteInstallation(string $appId, string $installationId): strin */ public function createInstallationToken(string $appId, string $installationId): \Appwrite\Models\Oauth2Token { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -552,6 +592,10 @@ public function createInstallationToken(string $appId, string $installationId): */ public function listKeys(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppKeyList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -596,6 +640,10 @@ public function listKeys(string $appId, ?array $queries = null, ?bool $total = n */ public function createKey(string $appId): \Appwrite\Models\AppKey { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -631,6 +679,14 @@ public function createKey(string $appId): \Appwrite\Models\AppKey */ public function getKey(string $appId, string $keyId): \Appwrite\Models\AppKey { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{appId}', '{keyId}'], [$appId, $keyId], @@ -666,6 +722,14 @@ public function getKey(string $appId, string $keyId): \Appwrite\Models\AppKey */ public function deleteKey(string $appId, string $keyId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{appId}', '{keyId}'], [$appId, $keyId], @@ -698,6 +762,10 @@ public function deleteKey(string $appId, string $keyId): string */ public function updateLabels(string $appId, array $labels): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -734,6 +802,10 @@ public function updateLabels(string $appId, array $labels): \Appwrite\Models\App */ public function listSecrets(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppSecretList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -776,6 +848,10 @@ public function listSecrets(string $appId, ?array $queries = null, ?bool $total */ public function createSecret(string $appId): \Appwrite\Models\AppSecretPlaintext { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -811,6 +887,14 @@ public function createSecret(string $appId): \Appwrite\Models\AppSecretPlaintext */ public function getSecret(string $appId, string $secretId): \Appwrite\Models\AppSecret { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($secretId === '') { + throw new AppwriteException('Missing required parameter: "secretId"'); + } + $apiPath = str_replace( ['{appId}', '{secretId}'], [$appId, $secretId], @@ -846,6 +930,14 @@ public function getSecret(string $appId, string $secretId): \Appwrite\Models\App */ public function deleteSecret(string $appId, string $secretId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($secretId === '') { + throw new AppwriteException('Missing required parameter: "secretId"'); + } + $apiPath = str_replace( ['{appId}', '{secretId}'], [$appId, $secretId], @@ -876,6 +968,10 @@ public function deleteSecret(string $appId, string $secretId): string */ public function updateTeam(string $appId, string $teamId): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -912,6 +1008,10 @@ public function updateTeam(string $appId, string $teamId): \Appwrite\Models\App */ public function deleteTokens(string $appId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index ba8f5c11..eb5fa3a8 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -298,9 +298,9 @@ public function getInitials(?string $name = null, ?int $width = null, ?int $heig /** * Returns the best available profile photo for a user. The endpoint tries - * each source in priority order and returns the first successful result: - * OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in - * static fallback. + * each source in priority order and returns the first successful result: a + * custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, + * Gravatar, Libravatar, Appwrite Initials, built-in static fallback. * * Passing `userId` — `current()` for the authenticated user — resolves * the photo from everything known about that user: identity photos, email, diff --git a/src/Appwrite/Services/Backups.php b/src/Appwrite/Services/Backups.php index b67014b4..9b22277b 100644 --- a/src/Appwrite/Services/Backups.php +++ b/src/Appwrite/Services/Backups.php @@ -90,6 +90,10 @@ public function createArchive(array $services, ?string $resourceId = null): \App */ public function getArchive(string $archiveId): \Appwrite\Models\BackupArchive { + if ($archiveId === '') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + $apiPath = str_replace( ['{archiveId}'], [$archiveId], @@ -124,6 +128,10 @@ public function getArchive(string $archiveId): \Appwrite\Models\BackupArchive */ public function deleteArchive(string $archiveId): string { + if ($archiveId === '') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + $apiPath = str_replace( ['{archiveId}'], [$archiveId], @@ -237,6 +245,10 @@ public function createPolicy(string $policyId, array $services, int $retention, */ public function getPolicy(string $policyId): \Appwrite\Models\BackupPolicy { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -271,6 +283,10 @@ public function getPolicy(string $policyId): \Appwrite\Models\BackupPolicy */ public function updatePolicy(string $policyId, ?string $name = null, ?int $retention = null, ?string $schedule = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -313,6 +329,10 @@ public function updatePolicy(string $policyId, ?string $name = null, ?int $reten */ public function deletePolicy(string $policyId): string { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -453,6 +473,10 @@ public function listRestorations(?array $queries = null): \Appwrite\Models\Backu */ public function getRestoration(string $restorationId): \Appwrite\Models\BackupRestoration { + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{restorationId}'], [$restorationId], diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 6dd497fe..60caec64 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -200,6 +200,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -237,6 +241,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -283,6 +291,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -295,6 +307,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -314,6 +327,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -357,6 +374,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -394,6 +415,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, ?string $name = null, ?bool $enabled = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -441,6 +466,10 @@ public function update(string $databaseId, ?string $name = null, ?bool $enabled */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -453,6 +482,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -473,6 +503,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\CollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -525,6 +559,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?array $attributes = null, ?array $indexes = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -583,6 +621,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -621,6 +667,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, ?string $name = null, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -678,6 +732,14 @@ public function updateCollection(string $databaseId, string $collectionId, ?stri */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -691,6 +753,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -710,6 +773,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listAttributes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AttributeList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -757,6 +828,14 @@ public function listAttributes(string $databaseId, string $collectionId, ?array */ public function createBigIntAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -806,6 +885,18 @@ public function createBigIntAttribute(string $databaseId, string $collectionId, */ public function updateBigIntAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\AttributeBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -851,6 +942,14 @@ public function updateBigIntAttribute(string $databaseId, string $collectionId, */ public function createBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -898,6 +997,18 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, */ public function updateBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -941,6 +1052,14 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, */ public function createDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -988,6 +1107,18 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId */ public function updateDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1031,6 +1162,14 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId */ public function createEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1078,6 +1217,18 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s */ public function updateEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1122,6 +1273,14 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s */ public function createEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1170,6 +1329,18 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st */ public function updateEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1215,6 +1386,14 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st */ public function createFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1264,6 +1443,18 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s */ public function updateFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): \Appwrite\Models\AttributeFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1310,6 +1501,14 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s */ public function createIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1359,6 +1558,18 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, */ public function updateIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\AttributeInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1404,6 +1615,14 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, */ public function createIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1451,6 +1670,18 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri */ public function updateIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1494,6 +1725,14 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri */ public function createLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributeLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1537,6 +1776,18 @@ public function createLineAttribute(string $databaseId, string $collectionId, st */ public function updateLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributeLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1580,6 +1831,14 @@ public function updateLineAttribute(string $databaseId, string $collectionId, st */ public function createLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1631,6 +1890,18 @@ public function createLongtextAttribute(string $databaseId, string $collectionId */ public function updateLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1674,6 +1945,14 @@ public function updateLongtextAttribute(string $databaseId, string $collectionId */ public function createMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1725,6 +2004,18 @@ public function createMediumtextAttribute(string $databaseId, string $collection */ public function updateMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1768,6 +2059,14 @@ public function updateMediumtextAttribute(string $databaseId, string $collection */ public function createPointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributePoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1811,6 +2110,18 @@ public function createPointAttribute(string $databaseId, string $collectionId, s */ public function updatePointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributePoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1854,6 +2165,14 @@ public function updatePointAttribute(string $databaseId, string $collectionId, s */ public function createPolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributePolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1897,6 +2216,18 @@ public function createPolygonAttribute(string $databaseId, string $collectionId, */ public function updatePolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributePolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1941,6 +2272,14 @@ public function updatePolygonAttribute(string $databaseId, string $collectionId, */ public function createRelationshipAttribute(string $databaseId, string $collectionId, string $relatedCollectionId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): \Appwrite\Models\AttributeRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1993,6 +2332,18 @@ public function createRelationshipAttribute(string $databaseId, string $collecti */ public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\AttributeRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2038,6 +2389,14 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti */ public function createStringAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2090,6 +2449,18 @@ public function createStringAttribute(string $databaseId, string $collectionId, */ public function updateStringAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2134,6 +2505,14 @@ public function updateStringAttribute(string $databaseId, string $collectionId, */ public function createTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2185,6 +2564,18 @@ public function createTextAttribute(string $databaseId, string $collectionId, st */ public function updateTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2228,6 +2619,14 @@ public function updateTextAttribute(string $databaseId, string $collectionId, st */ public function createUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2275,6 +2674,18 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str */ public function updateUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2318,6 +2729,14 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str */ 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 { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2370,6 +2789,18 @@ public function createVarcharAttribute(string $databaseId, string $collectionId, */ public function updateVarcharAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\AttributeVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2412,8 +2843,20 @@ public function updateVarcharAttribute(string $databaseId, string $collectionId, * @deprecated This API has been deprecated since 1.8.0. Please use `getColumn` instead. * @see TablesDB::getColumn */ - public function getAttribute(string $databaseId, string $collectionId, string $key): \Appwrite\Models\AttributeBoolean|\Appwrite\Models\AttributeInteger|\Appwrite\Models\AttributeFloat|\Appwrite\Models\AttributeEmail|\Appwrite\Models\AttributeEnum|\Appwrite\Models\AttributeUrl|\Appwrite\Models\AttributeIp|\Appwrite\Models\AttributeDatetime|\Appwrite\Models\AttributeRelationship|\Appwrite\Models\AttributeString + public function getAttribute(string $databaseId, string $collectionId, string $key): \Appwrite\Models\AttributeBoolean|\Appwrite\Models\AttributeBigint|\Appwrite\Models\AttributeInteger|\Appwrite\Models\AttributeFloat|\Appwrite\Models\AttributeEmail|\Appwrite\Models\AttributeEnum|\Appwrite\Models\AttributeUrl|\Appwrite\Models\AttributeIp|\Appwrite\Models\AttributeDatetime|\Appwrite\Models\AttributeRelationship|\Appwrite\Models\AttributePoint|\Appwrite\Models\AttributeLine|\Appwrite\Models\AttributePolygon|\Appwrite\Models\AttributeVarchar|\Appwrite\Models\AttributeText|\Appwrite\Models\AttributeMediumtext|\Appwrite\Models\AttributeLongtext|\Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2460,6 +2903,10 @@ public function getAttribute(string $databaseId, string $collectionId, string $k return \Appwrite\Models\AttributeBoolean::from($response); } + if (($response['type'] ?? null) === 'bigint') { + return \Appwrite\Models\AttributeBigint::from($response); + } + if (($response['type'] ?? null) === 'integer') { return \Appwrite\Models\AttributeInteger::from($response); } @@ -2476,6 +2923,34 @@ public function getAttribute(string $databaseId, string $collectionId, string $k return \Appwrite\Models\AttributeRelationship::from($response); } + if (($response['type'] ?? null) === 'point') { + return \Appwrite\Models\AttributePoint::from($response); + } + + if (($response['type'] ?? null) === 'linestring') { + return \Appwrite\Models\AttributeLine::from($response); + } + + if (($response['type'] ?? null) === 'polygon') { + return \Appwrite\Models\AttributePolygon::from($response); + } + + if (($response['type'] ?? null) === 'varchar') { + return \Appwrite\Models\AttributeVarchar::from($response); + } + + if (($response['type'] ?? null) === 'text') { + return \Appwrite\Models\AttributeText::from($response); + } + + if (($response['type'] ?? null) === 'mediumtext') { + return \Appwrite\Models\AttributeMediumtext::from($response); + } + + if (($response['type'] ?? null) === 'longtext') { + return \Appwrite\Models\AttributeLongtext::from($response); + } + if (($response['type'] ?? null) === 'string') { return \Appwrite\Models\AttributeString::from($response); } @@ -2493,6 +2968,18 @@ public function getAttribute(string $databaseId, string $collectionId, string $k */ public function deleteAttribute(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2507,6 +2994,7 @@ public function deleteAttribute(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2527,6 +3015,14 @@ public function deleteAttribute(string $databaseId, string $collectionId, string */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2584,6 +3080,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2630,6 +3134,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2674,6 +3186,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2717,6 +3237,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2766,6 +3294,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2814,6 +3350,18 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2864,6 +3412,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2911,6 +3471,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2957,6 +3529,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2975,6 +3559,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2994,6 +3579,22 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -3041,6 +3642,22 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -3088,6 +3705,14 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -3127,7 +3752,9 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu /** * Creates an index on the attributes listed. Your index should include all * the attributes you will query in a single request. - * Attributes can be `key`, `fulltext`, and `unique`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + * `trigram` is only available on PostgreSQL and lets `contains`, + * `startsWith`, and `endsWith` queries on string attributes use an index. * * @throws AppwriteException * @@ -3136,6 +3763,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, DatabasesIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -3186,6 +3821,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -3225,6 +3872,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -3239,6 +3898,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/DocumentsDB.php b/src/Appwrite/Services/DocumentsDB.php index 4e0e734f..efaef6eb 100644 --- a/src/Appwrite/Services/DocumentsDB.php +++ b/src/Appwrite/Services/DocumentsDB.php @@ -104,8 +104,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -223,6 +223,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -257,6 +261,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -300,6 +308,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -312,6 +324,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -328,6 +341,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -368,6 +385,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -402,6 +423,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, string $name, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -446,6 +471,10 @@ public function update(string $databaseId, string $name, ?bool $enabled = null, */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -458,6 +487,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -475,6 +505,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\CollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -524,6 +558,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?array $attributes = null, ?array $indexes = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -579,6 +617,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -614,6 +660,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -668,6 +722,14 @@ public function updateCollection(string $databaseId, string $collectionId, strin */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -681,6 +743,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -698,6 +761,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -752,6 +823,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -801,6 +880,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -845,6 +932,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -888,6 +983,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -937,6 +1040,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -982,6 +1093,18 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1029,6 +1152,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1079,6 +1214,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1128,6 +1275,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1146,6 +1305,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1162,6 +1322,22 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -1212,6 +1388,22 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -1262,6 +1454,14 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1307,6 +1507,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, DocumentsDBIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1354,6 +1562,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1390,6 +1610,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1404,6 +1636,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1428,6 +1661,10 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1467,6 +1704,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1514,6 +1755,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1550,6 +1795,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index d1bb5dda..cf414016 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -268,6 +268,10 @@ public function listSpecifications(?string $type = null, ?bool $total = null): \ */ public function get(string $functionId): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -302,6 +306,10 @@ public function get(string $functionId): \Appwrite\Models\FunctionModel */ public function update(string $functionId, string $name, ?Runtime $runtime = null, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?int $interval = null): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -404,6 +412,10 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul */ public function delete(string $functionId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -416,6 +428,7 @@ public function delete(string $functionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -433,6 +446,10 @@ public function delete(string $functionId): string */ public function updateFunctionDeployment(string $functionId, string $deploymentId): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -470,6 +487,10 @@ public function updateFunctionDeployment(string $functionId, string $deploymentI */ public function listDeployments(string $functionId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\DeploymentList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -525,6 +546,10 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str */ public function createDeployment(string $functionId, InputFile $code, bool $activate, ?string $entrypoint = null, ?string $commands = null, ?callable $onProgress = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -548,9 +573,6 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($code->getPath() ?? null)) { $size = strlen($code->getData()); $mimeType = $code->getMimeType(); @@ -704,6 +726,10 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti */ public function createDuplicateDeployment(string $functionId, string $deploymentId, ?string $buildId = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -748,6 +774,10 @@ public function createDuplicateDeployment(string $functionId, string $deployment */ public function createTemplateDeployment(string $functionId, string $repository, string $owner, string $rootDirectory, TemplateReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -794,6 +824,10 @@ public function createTemplateDeployment(string $functionId, string $repository, */ public function createVcsDeployment(string $functionId, VCSReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -835,6 +869,14 @@ public function createVcsDeployment(string $functionId, VCSReferenceType $type, */ public function getDeployment(string $functionId, string $deploymentId): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -870,6 +912,14 @@ public function getDeployment(string $functionId, string $deploymentId): \Appwri */ public function deleteDeployment(string $functionId, string $deploymentId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -883,6 +933,7 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -901,6 +952,14 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri */ public function getDeploymentDownload(string $functionId, string $deploymentId, ?DeploymentDownloadType $type = null, ?string $token = null): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -942,6 +1001,14 @@ public function getDeploymentDownload(string $functionId, string $deploymentId, */ public function updateDeploymentStatus(string $functionId, string $deploymentId): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -979,6 +1046,10 @@ public function updateDeploymentStatus(string $functionId, string $deploymentId) */ public function listExecutions(string $functionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ExecutionList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1024,6 +1095,10 @@ public function listExecutions(string $functionId, ?array $queries = null, ?bool */ public function createExecution(string $functionId, ?string $body = null, ?bool $async = null, ?string $xpath = null, ?ExecutionMethod $method = null, ?array $headers = null, ?string $scheduledAt = null): \Appwrite\Models\Execution { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1080,6 +1155,14 @@ public function createExecution(string $functionId, ?string $body = null, ?bool */ public function getExecution(string $functionId, string $executionId): \Appwrite\Models\Execution { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($executionId === '') { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + $apiPath = str_replace( ['{functionId}', '{executionId}'], [$functionId, $executionId], @@ -1115,6 +1198,14 @@ public function getExecution(string $functionId, string $executionId): \Appwrite */ public function deleteExecution(string $functionId, string $executionId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($executionId === '') { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + $apiPath = str_replace( ['{functionId}', '{executionId}'], [$functionId, $executionId], @@ -1128,6 +1219,7 @@ public function deleteExecution(string $functionId, string $executionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1144,6 +1236,10 @@ public function deleteExecution(string $functionId, string $executionId): string */ public function listVariables(string $functionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\VariableList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1187,6 +1283,10 @@ public function listVariables(string $functionId, ?array $queries = null, ?bool */ public function createVariable(string $functionId, string $variableId, string $key, string $value, ?bool $secret = null): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1229,6 +1329,14 @@ public function createVariable(string $functionId, string $variableId, string $k */ public function getVariable(string $functionId, string $variableId): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1264,6 +1372,14 @@ public function getVariable(string $functionId, string $variableId): \Appwrite\M */ public function updateVariable(string $functionId, string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1303,6 +1419,14 @@ public function updateVariable(string $functionId, string $variableId, ?string $ */ public function deleteVariable(string $functionId, string $variableId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1316,6 +1440,7 @@ public function deleteVariable(string $functionId, string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Messaging.php b/src/Appwrite/Services/Messaging.php index 053d0e67..af0072de 100644 --- a/src/Appwrite/Services/Messaging.php +++ b/src/Appwrite/Services/Messaging.php @@ -94,10 +94,7 @@ public function createEmail(string $messageId, string $subject, string $content, if (!is_null($bcc)) { $apiParams['bcc'] = $bcc; } - - if (!is_null($attachments)) { - $apiParams['attachments'] = $attachments; - } + $apiParams['attachments'] = $attachments; if (!is_null($draft)) { $apiParams['draft'] = $draft; @@ -144,6 +141,10 @@ public function createEmail(string $messageId, string $subject, string $content, */ public function updateEmail(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $subject = null, ?string $content = null, ?bool $draft = null, ?bool $html = null, ?array $cc = null, ?array $bcc = null, ?string $scheduledAt = null, ?array $attachments = null, ?string $replyToEmail = null, ?string $replyToName = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -299,6 +300,10 @@ public function createPush(string $messageId, ?string $title = null, ?string $bo */ public function updatePush(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $title = null, ?string $body = null, ?array $data = null, ?string $action = null, ?string $image = null, ?string $icon = null, ?string $sound = null, ?string $color = null, ?string $tag = null, ?int $badge = null, ?bool $draft = null, ?string $scheduledAt = null, ?bool $contentAvailable = null, ?bool $critical = null, ?MessagePriority $priority = null, ?string $channelId = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -408,6 +413,10 @@ public function createSMS(string $messageId, string $content, ?array $topics = n */ public function updateSMS(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $content = null, ?bool $draft = null, ?string $scheduledAt = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -449,6 +458,10 @@ public function updateSMS(string $messageId, ?array $topics = null, ?array $user */ public function getMessage(string $messageId): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -484,6 +497,10 @@ public function getMessage(string $messageId): \Appwrite\Models\Message */ public function delete(string $messageId): string { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -496,6 +513,7 @@ public function delete(string $messageId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -512,6 +530,10 @@ public function delete(string $messageId): string */ public function listTargets(string $messageId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\TargetList { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -656,6 +678,10 @@ public function createAPNSProvider(string $providerId, string $name, ?string $au */ public function updateAPNSProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $authKey = null, ?string $authKeyId = null, ?string $teamId = null, ?string $bundleId = null, ?bool $sandbox = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -836,6 +862,10 @@ public function createFCMProvider(string $providerId, string $name, ?array $serv */ public function updateFCMProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?array $serviceAccountJSON = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -939,6 +969,10 @@ public function createMailgunProvider(string $providerId, string $name, ?string */ public function updateMailgunProvider(string $providerId, ?string $name = null, ?string $apiKey = null, ?string $domain = null, ?bool $isEuRegion = null, ?bool $enabled = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1053,6 +1087,10 @@ public function createMsg91Provider(string $providerId, string $name, ?string $t */ public function updateMsg91Provider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $templateId = null, ?string $senderId = null, ?string $authKey = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1162,6 +1200,10 @@ public function createResendProvider(string $providerId, string $name, ?string $ */ public function updateResendProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1279,6 +1321,10 @@ public function createSendgridProvider(string $providerId, string $name, ?string */ public function updateSendgridProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1404,6 +1450,10 @@ public function createSesProvider(string $providerId, string $name, ?string $acc */ public function updateSesProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $accessKey = null, ?string $secretKey = null, ?string $region = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1550,6 +1600,10 @@ public function createSMTPProvider(string $providerId, string $name, string $hos */ public function updateSMTPProvider(string $providerId, ?string $name = null, ?string $host = null, ?int $port = null, ?string $username = null, ?string $password = null, ?SmtpEncryption $encryption = null, ?bool $autoTLS = null, ?string $mailer = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null, ?bool $enabled = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1677,6 +1731,10 @@ public function createTelesignProvider(string $providerId, string $name, ?string */ public function updateTelesignProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $customerId = null, ?string $apiKey = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1778,6 +1836,10 @@ public function createTextmagicProvider(string $providerId, string $name, ?strin */ public function updateTextmagicProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $username = null, ?string $apiKey = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1879,6 +1941,10 @@ public function createTwilioProvider(string $providerId, string $name, ?string $ */ public function updateTwilioProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $accountSid = null, ?string $authToken = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1980,6 +2046,10 @@ public function createVonageProvider(string $providerId, string $name, ?string $ */ public function updateVonageProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $apiSecret = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2032,6 +2102,10 @@ public function updateVonageProvider(string $providerId, ?string $name = null, ? */ public function getProvider(string $providerId): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2066,6 +2140,10 @@ public function getProvider(string $providerId): \Appwrite\Models\Provider */ public function deleteProvider(string $providerId): string { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2078,6 +2156,7 @@ public function deleteProvider(string $providerId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2181,6 +2260,10 @@ public function createTopic(string $topicId, string $name, ?array $subscribe = n */ public function getTopic(string $topicId): \Appwrite\Models\Topic { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2215,6 +2298,10 @@ public function getTopic(string $topicId): \Appwrite\Models\Topic */ public function updateTopic(string $topicId, ?string $name = null, ?array $subscribe = null, ?int $qos = null, ?int $expiry = null): \Appwrite\Models\Topic { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2254,6 +2341,10 @@ public function updateTopic(string $topicId, ?string $name = null, ?array $subsc */ public function deleteTopic(string $topicId): string { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2266,6 +2357,7 @@ public function deleteTopic(string $topicId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2282,6 +2374,10 @@ public function deleteTopic(string $topicId): string */ public function listSubscribers(string $topicId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\SubscriberList { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2328,6 +2424,10 @@ public function listSubscribers(string $topicId, ?array $queries = null, ?string */ public function createSubscriber(string $topicId, string $subscriberId, string $targetId): \Appwrite\Models\Subscriber { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2365,6 +2465,14 @@ public function createSubscriber(string $topicId, string $subscriberId, string $ */ public function getSubscriber(string $topicId, string $subscriberId): \Appwrite\Models\Subscriber { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + if ($subscriberId === '') { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + $apiPath = str_replace( ['{topicId}', '{subscriberId}'], [$topicId, $subscriberId], @@ -2400,6 +2508,14 @@ public function getSubscriber(string $topicId, string $subscriberId): \Appwrite\ */ public function deleteSubscriber(string $topicId, string $subscriberId): string { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + if ($subscriberId === '') { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + $apiPath = str_replace( ['{topicId}', '{subscriberId}'], [$topicId, $subscriberId], @@ -2413,6 +2529,7 @@ public function deleteSubscriber(string $topicId, string $subscriberId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Mongo.php b/src/Appwrite/Services/Mongo.php index 21771ece..4c74acc4 100644 --- a/src/Appwrite/Services/Mongo.php +++ b/src/Appwrite/Services/Mongo.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -849,6 +938,10 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -887,6 +980,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -927,6 +1024,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -967,6 +1068,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1014,6 +1119,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1049,6 +1158,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1084,6 +1197,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1137,6 +1254,10 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st */ public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1180,6 +1301,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1217,6 +1346,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1252,6 +1385,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Mysql.php b/src/Appwrite/Services/Mysql.php index 95f4cd35..d0787222 100644 --- a/src/Appwrite/Services/Mysql.php +++ b/src/Appwrite/Services/Mysql.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -849,6 +938,10 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate */ public function createExecution(string $databaseId, string $sql, ?array $bindings = null, ?int $timeoutSeconds = null): \Appwrite\Models\DedicatedDatabaseExecution { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -895,6 +988,10 @@ public function createExecution(string $databaseId, string $sql, ?array $binding */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -933,6 +1030,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -973,6 +1074,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1013,6 +1118,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1060,6 +1169,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1095,6 +1208,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1130,6 +1247,10 @@ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabas */ public function updatePooler(string $databaseId, ?string $mode = null, ?int $maxConnections = null, ?int $defaultPoolSize = null, ?bool $readWriteSplitting = null, ?string $poolerCpuRequest = null, ?string $poolerCpuLimit = null, ?string $poolerMemoryRequest = null, ?string $poolerMemoryLimit = null): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1174,6 +1295,10 @@ public function updatePooler(string $databaseId, ?string $mode = null, ?int $max */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1209,6 +1334,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1262,6 +1391,10 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st */ public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1305,6 +1438,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1342,6 +1483,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1377,6 +1522,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Oauth2.php b/src/Appwrite/Services/Oauth2.php index 45d4927a..e246e345 100644 --- a/src/Appwrite/Services/Oauth2.php +++ b/src/Appwrite/Services/Oauth2.php @@ -65,7 +65,7 @@ public function approve(string $grantId, ?string $authorizationDetails = null, ? * * @throws AppwriteException */ - public function authorize(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize + public function authorize(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize { $apiPath = str_replace( ['{project_id}'], @@ -157,7 +157,7 @@ public function authorize(?string $clientId = null, ?string $redirectUri = null, * * @throws AppwriteException */ - public function authorizePost(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize + public function authorizePost(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize { $apiPath = str_replace( ['{project_id}'], @@ -244,7 +244,7 @@ public function authorizePost(?string $clientId = null, ?string $redirectUri = n * * @throws AppwriteException */ - public function createDeviceAuthorization(?string $clientId = null, ?string $scope = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2DeviceAuthorization + public function createDeviceAuthorization(?string $clientId = null, ?string $scope = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2DeviceAuthorization { $apiPath = str_replace( ['{project_id}'], @@ -338,6 +338,10 @@ public function createGrant(string $userCode): \Appwrite\Models\Oauth2Grant */ public function getGrant(string $grantId): \Appwrite\Models\Oauth2Grant { + if ($grantId === '') { + throw new AppwriteException('Missing required parameter: "grantId"'); + } + $apiPath = str_replace( ['{project_id}', '{grant_id}'], [$this->client->getConfig('project'), $grantId], @@ -465,7 +469,7 @@ public function listOrganizations(?int $limit = null, ?int $offset = null, ?stri * * @throws AppwriteException */ - public function createPAR(string $clientId, string $redirectUri, string $responseType, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2PAR + public function createPAR(string $clientId, string $redirectUri, string $responseType, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2PAR { $apiPath = str_replace( ['{project_id}'], @@ -662,7 +666,7 @@ public function revoke(string $token, ?string $tokenTypeHint = null, ?string $cl * * @throws AppwriteException */ - public function createToken(string $grantType, ?string $code = null, ?string $refreshToken = null, ?string $deviceCode = null, ?string $clientId = null, ?string $clientSecret = null, ?string $codeVerifier = null, ?string $redirectUri = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2Token + public function createToken(string $grantType, ?string $code = null, ?string $refreshToken = null, ?string $deviceCode = null, ?string $clientId = null, ?string $clientSecret = null, ?string $codeVerifier = null, ?string $redirectUri = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2Token { $apiPath = str_replace( ['{project_id}'], diff --git a/src/Appwrite/Services/Organization.php b/src/Appwrite/Services/Organization.php index 3b572126..d8be8f07 100644 --- a/src/Appwrite/Services/Organization.php +++ b/src/Appwrite/Services/Organization.php @@ -98,6 +98,7 @@ public function delete(): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -198,6 +199,10 @@ public function createInstallation(string $appId, ?string $authorizationDetails */ public function getInstallation(string $installationId): \Appwrite\Models\AppInstallation { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -235,6 +240,10 @@ public function getInstallation(string $installationId): \Appwrite\Models\AppIns */ public function updateInstallation(string $installationId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -273,6 +282,10 @@ public function updateInstallation(string $installationId, ?string $authorizatio */ public function deleteInstallation(string $installationId): string { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -295,188 +308,6 @@ public function deleteInstallation(string $installationId): string ); } - /** - * Get a list of all API keys from the current organization. - * - * @throws AppwriteException - */ - public function listKeys(?array $queries = null, ?bool $total = null): \Appwrite\Models\KeyList - { - $apiPath = str_replace( - [], - [], - '/organization/keys' - ); - - $apiParams = []; - - 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\KeyList::from($response); - } - - /** - * Create a new organization API key. - * - * @throws AppwriteException - */ - public function createKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key - { - $apiPath = str_replace( - [], - [], - '/organization/keys' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - $apiParams['name'] = $name; - $apiParams['scopes'] = $scopes; - $apiParams['expire'] = $expire; - - $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\Key::from($response); - } - - /** - * Get a key by its unique ID. This endpoint returns details about a specific - * API key in your organization including its scopes. - * - * @throws AppwriteException - */ - public function getKey(string $keyId): \Appwrite\Models\Key - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - - $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\Key::from($response); - } - - /** - * Update a key by its unique ID. Use this endpoint to update the name, - * scopes, or expiration time of an API key. - * - * @throws AppwriteException - */ - public function updateKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - $apiParams['name'] = $name; - $apiParams['scopes'] = $scopes; - $apiParams['expire'] = $expire; - - $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\Key::from($response); - } - - /** - * Delete a key by its unique ID. Once deleted, the key can no longer be used - * to authenticate API calls. - * - * @throws AppwriteException - */ - public function deleteKey(string $keyId): string - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - /** * Get a list of all memberships from the current organization. * @@ -586,6 +417,10 @@ public function createMembership(array $roles, ?string $email = null, ?string $u */ public function getMembership(string $membershipId): \Appwrite\Models\Membership { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -620,6 +455,10 @@ public function getMembership(string $membershipId): \Appwrite\Models\Membership */ public function updateMembership(string $membershipId, array $roles): \Appwrite\Models\Membership { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -658,6 +497,10 @@ public function updateMembership(string $membershipId, array $roles): \Appwrite\ */ public function deleteMembership(string $membershipId): string { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -670,6 +513,7 @@ public function deleteMembership(string $membershipId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -772,6 +616,10 @@ public function createProject(string $projectId, string $name, ?Region $region = */ public function getProject(string $projectId): \Appwrite\Models\Project { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -783,6 +631,7 @@ public function getProject(string $projectId): \Appwrite\Models\Project $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; $response = $this->client->call( Client::METHOD_GET, @@ -805,6 +654,10 @@ public function getProject(string $projectId): \Appwrite\Models\Project */ public function updateProject(string $projectId, string $name): \Appwrite\Models\Project { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -841,6 +694,10 @@ public function updateProject(string $projectId, string $name): \Appwrite\Models */ public function deleteProject(string $projectId): string { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -853,6 +710,7 @@ public function deleteProject(string $projectId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Postgresql.php b/src/Appwrite/Services/Postgresql.php index 536e5730..701d5238 100644 --- a/src/Appwrite/Services/Postgresql.php +++ b/src/Appwrite/Services/Postgresql.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -849,6 +938,10 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate */ public function createExecution(string $databaseId, string $sql, ?array $bindings = null, ?int $timeoutSeconds = null): \Appwrite\Models\DedicatedDatabaseExecution { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -887,6 +980,10 @@ public function createExecution(string $databaseId, string $sql, ?array $binding */ public function listExtensions(string $databaseId): \Appwrite\Models\DedicatedDatabaseExtensions { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -922,6 +1019,10 @@ public function listExtensions(string $databaseId): \Appwrite\Models\DedicatedDa */ public function createExtension(string $databaseId, string $name): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -959,6 +1060,14 @@ public function createExtension(string $databaseId, string $name): \Appwrite\Mod */ public function deleteExtension(string $databaseId, string $extensionName): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($extensionName === '') { + throw new AppwriteException('Missing required parameter: "extensionName"'); + } + $apiPath = str_replace( ['{databaseId}', '{extensionName}'], [$databaseId, $extensionName], @@ -1003,6 +1112,10 @@ public function deleteExtension(string $databaseId, string $extensionName): \App */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1041,6 +1154,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1081,6 +1198,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1121,6 +1242,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1168,6 +1293,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1203,6 +1332,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1238,6 +1371,10 @@ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabas */ public function updatePooler(string $databaseId, ?string $mode = null, ?int $maxConnections = null, ?int $defaultPoolSize = null, ?bool $readWriteSplitting = null, ?string $poolerCpuRequest = null, ?string $poolerCpuLimit = null, ?string $poolerMemoryRequest = null, ?string $poolerMemoryLimit = null): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1282,6 +1419,10 @@ public function updatePooler(string $databaseId, ?string $mode = null, ?int $max */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1317,6 +1458,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1370,6 +1515,10 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st */ public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1413,6 +1562,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1450,6 +1607,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1485,6 +1646,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Presences.php b/src/Appwrite/Services/Presences.php index 80f429c9..5a04fc40 100644 --- a/src/Appwrite/Services/Presences.php +++ b/src/Appwrite/Services/Presences.php @@ -63,6 +63,10 @@ public function list(?array $queries = null, ?bool $total = null, ?int $ttl = nu */ public function get(string $presenceId): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -97,6 +101,10 @@ public function get(string $presenceId): \Appwrite\Models\Presence */ public function upsert(string $presenceId, string $userId, string $status, ?array $permissions = null, ?string $expiresAt = null, ?array $metadata = null): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -147,6 +155,10 @@ public function upsert(string $presenceId, string $userId, string $status, ?arra */ public function update(string $presenceId, string $userId, ?string $status = null, ?string $expiresAt = null, ?array $metadata = null, ?array $permissions = null, ?bool $purge = null): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -203,6 +215,10 @@ public function update(string $presenceId, string $userId, ?string $status = nul */ public function delete(string $presenceId): string { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -215,6 +231,7 @@ public function delete(string $presenceId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Project.php b/src/Appwrite/Services/Project.php index 05577731..223a6273 100644 --- a/src/Appwrite/Services/Project.php +++ b/src/Appwrite/Services/Project.php @@ -35,6 +35,7 @@ public function get(): \Appwrite\Models\Project $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; $response = $this->client->call( Client::METHOD_GET, @@ -68,6 +69,7 @@ public function delete(): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -393,6 +395,10 @@ public function createEphemeralKey(array $scopes, int $duration): \Appwrite\Mode */ public function getKey(string $keyId): \Appwrite\Models\Key { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -428,6 +434,10 @@ public function getKey(string $keyId): \Appwrite\Models\Key */ public function updateKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -467,6 +477,10 @@ public function updateKey(string $keyId, string $name, array $scopes, ?string $e */ public function deleteKey(string $keyId): string { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -479,6 +493,7 @@ public function deleteKey(string $keyId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -611,6 +626,10 @@ public function createMockPhone(string $number, string $otp): \Appwrite\Models\M */ public function getMockPhone(string $number): \Appwrite\Models\MockNumber { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -646,6 +665,10 @@ public function getMockPhone(string $number): \Appwrite\Models\MockNumber */ public function updateMockPhone(string $number, string $otp): \Appwrite\Models\MockNumber { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -683,6 +706,10 @@ public function updateMockPhone(string $number, string $otp): \Appwrite\Models\M */ public function deleteMockPhone(string $number): string { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -695,6 +722,7 @@ public function deleteMockPhone(string $number): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1648,7 +1676,7 @@ public function updateOAuth2HuggingFace(?string $clientId = null, ?string $clien * * @throws AppwriteException */ - public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecret = null, ?array $prompt = null, ?bool $enabled = null): \Appwrite\Models\OAuth2Kakao + public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecret = null, ?bool $enabled = null, ?array $prompt = null): \Appwrite\Models\OAuth2Kakao { $apiPath = str_replace( [], @@ -1659,8 +1687,8 @@ public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecre $apiParams = []; $apiParams['clientId'] = $clientId; $apiParams['clientSecret'] = $clientSecret; - $apiParams['prompt'] = $prompt; $apiParams['enabled'] = $enabled; + $apiParams['prompt'] = $prompt; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -2964,12 +2992,16 @@ public function createAndroidPlatform(string $platformId, string $name, string $ /** * Update an Android platform by its unique ID. Use this endpoint to update - * the platform's name or application ID. + * the platform's name, application ID or signing certificate fingerprints. * * @throws AppwriteException */ public function updateAndroidPlatform(string $platformId, string $name, string $applicationId, ?array $fingerprints = null): \Appwrite\Models\PlatformAndroid { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3048,6 +3080,10 @@ public function createApplePlatform(string $platformId, string $name, string $bu */ public function updateApplePlatform(string $platformId, string $name, string $bundleIdentifier): \Appwrite\Models\PlatformApple { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3125,6 +3161,10 @@ public function createLinuxPlatform(string $platformId, string $name, string $pa */ public function updateLinuxPlatform(string $platformId, string $name, string $packageName): \Appwrite\Models\PlatformLinux { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3202,6 +3242,10 @@ public function createWebPlatform(string $platformId, string $name, string $host */ public function updateWebPlatform(string $platformId, string $name, string $hostname): \Appwrite\Models\PlatformWeb { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3279,6 +3323,10 @@ public function createWindowsPlatform(string $platformId, string $name, string $ */ public function updateWindowsPlatform(string $platformId, string $name, string $packageIdentifierName): \Appwrite\Models\PlatformWindows { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3317,6 +3365,10 @@ public function updateWindowsPlatform(string $platformId, string $name, string $ */ public function getPlatform(string $platformId): \Appwrite\Models\PlatformWeb|\Appwrite\Models\PlatformApple|\Appwrite\Models\PlatformAndroid|\Appwrite\Models\PlatformWindows|\Appwrite\Models\PlatformLinux { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3372,6 +3424,10 @@ public function getPlatform(string $platformId): \Appwrite\Models\PlatformWeb|\A */ public function deletePlatform(string $platformId): string { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3384,6 +3440,7 @@ public function deletePlatform(string $platformId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -4432,6 +4489,7 @@ public function createSMTPTest(array $emails): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_POST, @@ -4660,6 +4718,10 @@ public function createVariable(string $variableId, string $key, string $value, ? */ public function getVariable(string $variableId): \Appwrite\Models\Variable { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4694,6 +4756,10 @@ public function getVariable(string $variableId): \Appwrite\Models\Variable */ public function updateVariable(string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4732,6 +4798,10 @@ public function updateVariable(string $variableId, ?string $key = null, ?string */ public function deleteVariable(string $variableId): string { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4744,6 +4814,7 @@ public function deleteVariable(string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Proxy.php b/src/Appwrite/Services/Proxy.php index 4b04c9e1..6fbe84b2 100644 --- a/src/Appwrite/Services/Proxy.php +++ b/src/Appwrite/Services/Proxy.php @@ -20,6 +20,8 @@ class Proxy extends Service * Depending on type, the invalidation purges a single cache tag, a single URL * path, or all cached content for the domain. * + * Domains that route to a function do not support cache invalidation. + * * @throws AppwriteException */ public function createInvalidation(string $domain, InvalidationType $type, ?string $reference = null): \Appwrite\Models\ProxyInvalidation @@ -273,6 +275,10 @@ public function createSiteRule(string $domain, string $siteId, ?string $branch = */ public function getRule(string $ruleId): \Appwrite\Models\ProxyRule { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], @@ -307,6 +313,10 @@ public function getRule(string $ruleId): \Appwrite\Models\ProxyRule */ public function deleteRule(string $ruleId): string { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], @@ -319,6 +329,7 @@ public function deleteRule(string $ruleId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -338,6 +349,10 @@ public function deleteRule(string $ruleId): string */ public function updateRuleStatus(string $ruleId): \Appwrite\Models\ProxyRule { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], diff --git a/src/Appwrite/Services/Sites.php b/src/Appwrite/Services/Sites.php index 3aeb94d8..c585adaa 100644 --- a/src/Appwrite/Services/Sites.php +++ b/src/Appwrite/Services/Sites.php @@ -268,6 +268,10 @@ public function listSpecifications(?string $type = null, ?bool $total = null): \ */ public function get(string $siteId): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -302,6 +306,10 @@ public function get(string $siteId): \Appwrite\Models\Site */ public function update(string $siteId, string $name, Framework $framework, ?bool $enabled = null, ?bool $logging = null, ?int $timeout = null, ?string $installCommand = null, ?string $buildCommand = null, ?string $startCommand = null, ?string $outputDirectory = null, ?BuildRuntime $buildRuntime = null, ?Adapter $adapter = null, ?string $fallbackFile = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?array $scopes = null): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -356,10 +364,7 @@ public function update(string $siteId, string $name, Framework $framework, ?bool if (!is_null($installationId)) { $apiParams['installationId'] = $installationId; } - - if (!is_null($providerRepositoryId)) { - $apiParams['providerRepositoryId'] = $providerRepositoryId; - } + $apiParams['providerRepositoryId'] = $providerRepositoryId; if (!is_null($providerBranch)) { $apiParams['providerBranch'] = $providerBranch; @@ -411,6 +416,10 @@ public function update(string $siteId, string $name, Framework $framework, ?bool */ public function delete(string $siteId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -423,6 +432,7 @@ public function delete(string $siteId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -440,6 +450,10 @@ public function delete(string $siteId): string */ public function updateSiteDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -477,6 +491,10 @@ public function updateSiteDeployment(string $siteId, string $deploymentId): \App */ public function listDeployments(string $siteId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\DeploymentList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -525,6 +543,10 @@ public function listDeployments(string $siteId, ?array $queries = null, ?string */ public function createDeployment(string $siteId, InputFile $code, ?string $installCommand = null, ?string $buildCommand = null, ?string $outputDirectory = null, ?bool $activate = null, ?callable $onProgress = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -555,9 +577,6 @@ public function createDeployment(string $siteId, InputFile $code, ?string $insta $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($code->getPath() ?? null)) { $size = strlen($code->getData()); $mimeType = $code->getMimeType(); @@ -711,6 +730,10 @@ public function createDeployment(string $siteId, InputFile $code, ?string $insta */ public function createDuplicateDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -751,6 +774,10 @@ public function createDuplicateDeployment(string $siteId, string $deploymentId): */ public function createTemplateDeployment(string $siteId, string $repository, string $owner, string $rootDirectory, TemplateReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -797,6 +824,10 @@ public function createTemplateDeployment(string $siteId, string $repository, str */ public function createVcsDeployment(string $siteId, VCSReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -838,6 +869,14 @@ public function createVcsDeployment(string $siteId, VCSReferenceType $type, stri */ public function getDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -873,6 +912,14 @@ public function getDeployment(string $siteId, string $deploymentId): \Appwrite\M */ public function deleteDeployment(string $siteId, string $deploymentId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -886,6 +933,7 @@ public function deleteDeployment(string $siteId, string $deploymentId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -904,6 +952,14 @@ public function deleteDeployment(string $siteId, string $deploymentId): string */ public function getDeploymentDownload(string $siteId, string $deploymentId, ?DeploymentDownloadType $type = null, ?string $token = null): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -945,6 +1001,14 @@ public function getDeploymentDownload(string $siteId, string $deploymentId, ?Dep */ public function updateDeploymentStatus(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -982,6 +1046,10 @@ public function updateDeploymentStatus(string $siteId, string $deploymentId): \A */ public function listLogs(string $siteId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ExecutionList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1024,6 +1092,14 @@ public function listLogs(string $siteId, ?array $queries = null, ?bool $total = */ public function getLog(string $siteId, string $logId): \Appwrite\Models\Execution { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($logId === '') { + throw new AppwriteException('Missing required parameter: "logId"'); + } + $apiPath = str_replace( ['{siteId}', '{logId}'], [$siteId, $logId], @@ -1059,6 +1135,14 @@ public function getLog(string $siteId, string $logId): \Appwrite\Models\Executio */ public function deleteLog(string $siteId, string $logId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($logId === '') { + throw new AppwriteException('Missing required parameter: "logId"'); + } + $apiPath = str_replace( ['{siteId}', '{logId}'], [$siteId, $logId], @@ -1089,6 +1173,10 @@ public function deleteLog(string $siteId, string $logId): string */ public function listVariables(string $siteId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\VariableList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1132,6 +1220,10 @@ public function listVariables(string $siteId, ?array $queries = null, ?bool $tot */ public function createVariable(string $siteId, string $variableId, string $key, string $value, ?bool $secret = null): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1174,6 +1266,14 @@ public function createVariable(string $siteId, string $variableId, string $key, */ public function getVariable(string $siteId, string $variableId): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1209,6 +1309,14 @@ public function getVariable(string $siteId, string $variableId): \Appwrite\Model */ public function updateVariable(string $siteId, string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1248,6 +1356,14 @@ public function updateVariable(string $siteId, string $variableId, ?string $key */ public function deleteVariable(string $siteId, string $variableId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1261,6 +1377,7 @@ public function deleteVariable(string $siteId, string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index ed3a2e93..2382a1f4 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -138,6 +138,10 @@ public function createBucket(string $bucketId, string $name, ?array $permissions */ public function getBucket(string $bucketId): \Appwrite\Models\Bucket { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -172,6 +176,10 @@ public function getBucket(string $bucketId): \Appwrite\Models\Bucket */ public function updateBucket(string $bucketId, string $name, ?array $permissions = null, ?bool $fileSecurity = null, ?bool $enabled = null, ?int $maximumFileSize = null, ?array $allowedFileExtensions = null, ?Compression $compression = null, ?bool $encryption = null, ?bool $antivirus = null, ?bool $transformations = null): \Appwrite\Models\Bucket { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -190,22 +198,13 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - - if (!is_null($maximumFileSize)) { - $apiParams['maximumFileSize'] = $maximumFileSize; - } + $apiParams['maximumFileSize'] = $maximumFileSize; if (!is_null($allowedFileExtensions)) { $apiParams['allowedFileExtensions'] = $allowedFileExtensions; } - - if (!is_null($compression)) { - $apiParams['compression'] = $compression; - } - - if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; - } + $apiParams['compression'] = $compression; + $apiParams['encryption'] = $encryption; if (!is_null($antivirus)) { $apiParams['antivirus'] = $antivirus; @@ -241,6 +240,10 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions */ public function deleteBucket(string $bucketId): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -253,6 +256,7 @@ public function deleteBucket(string $bucketId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -270,6 +274,10 @@ public function deleteBucket(string $bucketId): string */ public function listFiles(string $bucketId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\FileList { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -332,6 +340,10 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea */ public function createFile(string $bucketId, string $fileId, InputFile $file, ?array $permissions = null, ?string $folder = null, ?callable $onProgress = null): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -355,9 +367,6 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($file->getPath() ?? null)) { $size = strlen($file->getData()); $mimeType = $file->getMimeType(); @@ -521,6 +530,14 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a */ public function getFile(string $bucketId, string $fileId): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -557,6 +574,14 @@ public function getFile(string $bucketId, string $fileId): \Appwrite\Models\File */ public function updateFile(string $bucketId, string $fileId, ?string $name = null, ?array $permissions = null): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -599,6 +624,14 @@ public function updateFile(string $bucketId, string $fileId, ?string $name = nul */ public function deleteFile(string $bucketId, string $fileId): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -612,6 +645,7 @@ public function deleteFile(string $bucketId, string $fileId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -630,6 +664,14 @@ public function deleteFile(string $bucketId, string $fileId): string */ public function getFileDownload(string $bucketId, string $fileId, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -667,6 +709,14 @@ public function getFileDownload(string $bucketId, string $fileId, ?string $token */ public function getFilePreview(string $bucketId, string $fileId, ?int $width = null, ?int $height = null, ?ImageGravity $gravity = null, ?int $quality = null, ?int $borderWidth = null, ?string $borderColor = null, ?int $borderRadius = null, ?float $opacity = null, ?int $rotation = null, ?string $background = null, ?ImageFormat $output = null, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -746,6 +796,14 @@ public function getFilePreview(string $bucketId, string $fileId, ?int $width = n */ public function getFileView(string $bucketId, string $fileId, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], diff --git a/src/Appwrite/Services/TablesDB.php b/src/Appwrite/Services/TablesDB.php index 4ec544bd..14a42049 100644 --- a/src/Appwrite/Services/TablesDB.php +++ b/src/Appwrite/Services/TablesDB.php @@ -110,8 +110,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -229,6 +229,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -263,6 +267,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -306,6 +314,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -318,6 +330,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -334,6 +347,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -374,6 +391,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -408,6 +429,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, ?string $name = null, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -455,6 +480,10 @@ public function update(string $databaseId, ?string $name = null, ?bool $enabled */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -467,6 +496,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -491,6 +521,10 @@ public function delete(string $databaseId): string */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -528,6 +562,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listMigrations(string $databaseId): \Appwrite\Models\DatabaseMigrationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -564,6 +602,10 @@ public function listMigrations(string $databaseId): \Appwrite\Models\DatabaseMig */ public function createMigration(string $databaseId, string $specification, ?bool $autoCutover = null): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -604,6 +646,14 @@ public function createMigration(string $databaseId, string $specification, ?bool */ public function getMigration(string $databaseId, string $migrationId): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -640,6 +690,14 @@ public function getMigration(string $databaseId, string $migrationId): \Appwrite */ public function deleteMigration(string $databaseId, string $migrationId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -675,6 +733,14 @@ public function deleteMigration(string $databaseId, string $migrationId): string */ public function createCutover(string $databaseId, string $migrationId): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -714,6 +780,10 @@ public function createCutover(string $databaseId, string $migrationId): \Appwrit */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -761,6 +831,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -797,6 +871,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -832,6 +910,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function listTables(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\TableList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -881,6 +963,10 @@ public function listTables(string $databaseId, ?array $queries = null, ?string $ */ public function createTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null, ?array $columns = null, ?array $indexes = null): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -936,6 +1022,14 @@ public function createTable(string $databaseId, string $tableId, string $name, ? */ public function getTable(string $databaseId, string $tableId): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -971,6 +1065,14 @@ public function getTable(string $databaseId, string $tableId): \Appwrite\Models\ */ public function updateTable(string $databaseId, string $tableId, ?string $name = null, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1025,6 +1127,14 @@ public function updateTable(string $databaseId, string $tableId, ?string $name = */ public function deleteTable(string $databaseId, string $tableId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1038,6 +1148,7 @@ public function deleteTable(string $databaseId, string $tableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1054,6 +1165,14 @@ public function deleteTable(string $databaseId, string $tableId): string */ public function listColumns(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ColumnList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1098,6 +1217,14 @@ public function listColumns(string $databaseId, string $tableId, ?array $queries */ public function createBigIntColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1144,6 +1271,18 @@ public function createBigIntColumn(string $databaseId, string $tableId, string $ */ public function updateBigIntColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\ColumnBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1186,6 +1325,14 @@ public function updateBigIntColumn(string $databaseId, string $tableId, string $ */ public function createBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1230,6 +1377,18 @@ public function createBooleanColumn(string $databaseId, string $tableId, string */ public function updateBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1270,6 +1429,14 @@ public function updateBooleanColumn(string $databaseId, string $tableId, string */ public function createDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1314,6 +1481,18 @@ public function createDatetimeColumn(string $databaseId, string $tableId, string */ public function updateDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1354,6 +1533,14 @@ public function updateDatetimeColumn(string $databaseId, string $tableId, string */ public function createEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1398,6 +1585,18 @@ public function createEmailColumn(string $databaseId, string $tableId, string $k */ public function updateEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1439,6 +1638,14 @@ public function updateEmailColumn(string $databaseId, string $tableId, string $k */ public function createEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1484,6 +1691,18 @@ public function createEnumColumn(string $databaseId, string $tableId, string $ke */ public function updateEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1526,6 +1745,14 @@ public function updateEnumColumn(string $databaseId, string $tableId, string $ke */ public function createFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1572,6 +1799,18 @@ public function createFloatColumn(string $databaseId, string $tableId, string $k */ public function updateFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): \Appwrite\Models\ColumnFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1615,6 +1854,14 @@ public function updateFloatColumn(string $databaseId, string $tableId, string $k */ public function createIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1661,6 +1908,18 @@ public function createIntegerColumn(string $databaseId, string $tableId, string */ public function updateIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\ColumnInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1703,6 +1962,14 @@ public function updateIntegerColumn(string $databaseId, string $tableId, string */ public function createIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1747,6 +2014,18 @@ public function createIpColumn(string $databaseId, string $tableId, string $key, */ public function updateIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1787,6 +2066,14 @@ public function updateIpColumn(string $databaseId, string $tableId, string $key, */ public function createLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1827,6 +2114,18 @@ public function createLineColumn(string $databaseId, string $tableId, string $ke */ public function updateLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1867,6 +2166,14 @@ public function updateLineColumn(string $databaseId, string $tableId, string $ke */ public function createLongtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1915,6 +2222,18 @@ public function createLongtextColumn(string $databaseId, string $tableId, string */ public function updateLongtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1955,6 +2274,14 @@ public function updateLongtextColumn(string $databaseId, string $tableId, string */ public function createMediumtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2003,6 +2330,18 @@ public function createMediumtextColumn(string $databaseId, string $tableId, stri */ public function updateMediumtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2043,6 +2382,14 @@ public function updateMediumtextColumn(string $databaseId, string $tableId, stri */ public function createPointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnPoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2083,6 +2430,18 @@ public function createPointColumn(string $databaseId, string $tableId, string $k */ public function updatePointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnPoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2123,6 +2482,14 @@ public function updatePointColumn(string $databaseId, string $tableId, string $k */ public function createPolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnPolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2163,6 +2530,18 @@ public function createPolygonColumn(string $databaseId, string $tableId, string */ public function updatePolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnPolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2204,6 +2583,14 @@ public function updatePolygonColumn(string $databaseId, string $tableId, string */ public function createRelationshipColumn(string $databaseId, string $tableId, string $relatedTableId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): \Appwrite\Models\ColumnRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2245,6 +2632,58 @@ public function createRelationshipColumn(string $databaseId, string $tableId, st return \Appwrite\Models\ColumnRelationship::from($response); } + /** + * Update relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * @throws AppwriteException + */ + public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\ColumnRelationship + { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['onDelete'] = $onDelete; + $apiParams['newKey'] = $newKey; + + $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\ColumnRelationship::from($response); + } + /** * Create a string column. * @@ -2255,6 +2694,14 @@ public function createRelationshipColumn(string $databaseId, string $tableId, st */ public function createStringColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2307,6 +2754,18 @@ public function createStringColumn(string $databaseId, string $tableId, string $ */ public function updateStringColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2348,6 +2807,14 @@ public function updateStringColumn(string $databaseId, string $tableId, string $ */ public function createTextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2396,6 +2863,18 @@ public function createTextColumn(string $databaseId, string $tableId, string $ke */ public function updateTextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2436,6 +2915,14 @@ public function updateTextColumn(string $databaseId, string $tableId, string $ke */ public function createUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2480,6 +2967,18 @@ public function createUrlColumn(string $databaseId, string $tableId, string $key */ public function updateUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2520,6 +3019,14 @@ public function updateUrlColumn(string $databaseId, string $tableId, string $key */ public function createVarcharColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2569,6 +3076,18 @@ public function createVarcharColumn(string $databaseId, string $tableId, string */ public function updateVarcharColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\ColumnVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2608,8 +3127,20 @@ public function updateVarcharColumn(string $databaseId, string $tableId, string * * @throws AppwriteException */ - public function getColumn(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnBoolean|\Appwrite\Models\ColumnInteger|\Appwrite\Models\ColumnFloat|\Appwrite\Models\ColumnEmail|\Appwrite\Models\ColumnEnum|\Appwrite\Models\ColumnUrl|\Appwrite\Models\ColumnIp|\Appwrite\Models\ColumnDatetime|\Appwrite\Models\ColumnRelationship|\Appwrite\Models\ColumnString + public function getColumn(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnBoolean|\Appwrite\Models\ColumnBigint|\Appwrite\Models\ColumnInteger|\Appwrite\Models\ColumnFloat|\Appwrite\Models\ColumnEmail|\Appwrite\Models\ColumnEnum|\Appwrite\Models\ColumnUrl|\Appwrite\Models\ColumnIp|\Appwrite\Models\ColumnDatetime|\Appwrite\Models\ColumnRelationship|\Appwrite\Models\ColumnPoint|\Appwrite\Models\ColumnLine|\Appwrite\Models\ColumnPolygon|\Appwrite\Models\ColumnVarchar|\Appwrite\Models\ColumnText|\Appwrite\Models\ColumnMediumtext|\Appwrite\Models\ColumnLongtext|\Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2656,6 +3187,10 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap return \Appwrite\Models\ColumnBoolean::from($response); } + if (($response['type'] ?? null) === 'bigint') { + return \Appwrite\Models\ColumnBigint::from($response); + } + if (($response['type'] ?? null) === 'integer') { return \Appwrite\Models\ColumnInteger::from($response); } @@ -2672,6 +3207,34 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap return \Appwrite\Models\ColumnRelationship::from($response); } + if (($response['type'] ?? null) === 'point') { + return \Appwrite\Models\ColumnPoint::from($response); + } + + if (($response['type'] ?? null) === 'linestring') { + return \Appwrite\Models\ColumnLine::from($response); + } + + if (($response['type'] ?? null) === 'polygon') { + return \Appwrite\Models\ColumnPolygon::from($response); + } + + if (($response['type'] ?? null) === 'varchar') { + return \Appwrite\Models\ColumnVarchar::from($response); + } + + if (($response['type'] ?? null) === 'text') { + return \Appwrite\Models\ColumnText::from($response); + } + + if (($response['type'] ?? null) === 'mediumtext') { + return \Appwrite\Models\ColumnMediumtext::from($response); + } + + if (($response['type'] ?? null) === 'longtext') { + return \Appwrite\Models\ColumnLongtext::from($response); + } + if (($response['type'] ?? null) === 'string') { return \Appwrite\Models\ColumnString::from($response); } @@ -2686,67 +3249,40 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap */ public function deleteColumn(string $databaseId, string $tableId, string $key): string { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['content-type'] = 'application/json'; + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } - /** - * Update relationship column. [Learn more about relationship - * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * @throws AppwriteException - */ - public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\ColumnRelationship - { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' ); $apiParams = []; $apiParams['databaseId'] = $databaseId; $apiParams['tableId'] = $tableId; $apiParams['key'] = $key; - $apiParams['onDelete'] = $onDelete; - $apiParams['newKey'] = $newKey; $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, + return $this->client->call( + Client::METHOD_DELETE, $apiPath, $apiHeaders, $apiParams ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\ColumnRelationship::from($response); } /** @@ -2756,6 +3292,14 @@ public function updateRelationshipColumn(string $databaseId, string $tableId, st */ public function listIndexes(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ColumnIndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2795,12 +3339,22 @@ public function listIndexes(string $databaseId, string $tableId, ?array $queries /** * Creates an index on the columns listed. Your index should include all the * columns you will query in a single request. - * Type can be `key`, `fulltext`, or `unique`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + * is only available on PostgreSQL and lets `contains`, `startsWith`, and + * `endsWith` queries on string columns use an index. * * @throws AppwriteException */ public function createIndex(string $databaseId, string $tableId, string $key, TablesDBIndexType $type, array $columns, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\ColumnIndex { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2848,6 +3402,18 @@ public function createIndex(string $databaseId, string $tableId, string $key, Ta */ public function getIndex(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnIndex { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2884,6 +3450,18 @@ public function getIndex(string $databaseId, string $tableId, string $key): \App */ public function deleteIndex(string $databaseId, string $tableId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2898,6 +3476,7 @@ public function deleteIndex(string $databaseId, string $tableId, string $key): s $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2915,6 +3494,14 @@ public function deleteIndex(string $databaseId, string $tableId, string $key): s */ public function listRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2969,6 +3556,14 @@ public function listRows(string $databaseId, string $tableId, ?array $queries = */ public function createRow(string $databaseId, string $tableId, string $rowId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3012,6 +3607,14 @@ public function createRow(string $databaseId, string $tableId, string $rowId, ar */ public function createRows(string $databaseId, string $tableId, array $rows, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3053,6 +3656,14 @@ public function createRows(string $databaseId, string $tableId, array $rows, ?st */ public function upsertRows(string $databaseId, string $tableId, array $rows, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3092,6 +3703,14 @@ public function upsertRows(string $databaseId, string $tableId, array $rows, ?st */ public function updateRows(string $databaseId, string $tableId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3138,6 +3757,14 @@ public function updateRows(string $databaseId, string $tableId, ?array $data = n */ public function deleteRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3183,6 +3810,18 @@ public function deleteRows(string $databaseId, string $tableId, ?array $queries */ public function getRow(string $databaseId, string $tableId, string $rowId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3230,6 +3869,18 @@ public function getRow(string $databaseId, string $tableId, string $rowId, ?arra */ public function upsertRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3274,6 +3925,18 @@ public function upsertRow(string $databaseId, string $tableId, string $rowId, ?a */ public function updateRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3317,6 +3980,18 @@ public function updateRow(string $databaseId, string $tableId, string $rowId, ?a */ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3335,6 +4010,7 @@ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?s $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -3351,6 +4027,22 @@ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?s */ public function decrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if ($column === '') { + throw new AppwriteException('Missing required parameter: "column"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}', '{column}'], [$databaseId, $tableId, $rowId, $column], @@ -3395,6 +4087,22 @@ public function decrementRowColumn(string $databaseId, string $tableId, string $ */ public function incrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if ($column === '') { + throw new AppwriteException('Missing required parameter: "column"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}', '{column}'], [$databaseId, $tableId, $rowId, $column], diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index 3aad4091..e963c412 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -105,6 +105,10 @@ public function create(string $teamId, string $name, ?array $roles = null): \App */ public function get(string $teamId): \Appwrite\Models\Team { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -139,6 +143,10 @@ public function get(string $teamId): \Appwrite\Models\Team */ public function updateName(string $teamId, string $name): \Appwrite\Models\Team { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -176,6 +184,10 @@ public function updateName(string $teamId, string $name): \Appwrite\Models\Team */ public function delete(string $teamId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -188,6 +200,7 @@ public function delete(string $teamId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -204,6 +217,10 @@ public function delete(string $teamId): string */ public function listInstallations(string $teamId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppInstallationList { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -249,6 +266,10 @@ public function listInstallations(string $teamId, ?array $queries = null, ?bool */ public function createInstallation(string $teamId, string $appId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -290,6 +311,14 @@ public function createInstallation(string $teamId, string $appId, ?string $autho */ public function getInstallation(string $teamId, string $installationId): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -328,6 +357,14 @@ public function getInstallation(string $teamId, string $installationId): \Appwri */ public function updateInstallation(string $teamId, string $installationId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -367,6 +404,14 @@ public function updateInstallation(string $teamId, string $installationId, ?stri */ public function deleteInstallation(string $teamId, string $installationId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -399,6 +444,10 @@ public function deleteInstallation(string $teamId, string $installationId): stri */ public function listMemberships(string $teamId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\MembershipList { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -464,6 +513,10 @@ public function listMemberships(string $teamId, ?array $queries = null, ?string */ public function createMembership(string $teamId, array $roles, ?string $email = null, ?string $userId = null, ?string $phone = null, ?string $url = null, ?string $name = null, ?string $membershipId = null): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -526,6 +579,14 @@ public function createMembership(string $teamId, array $roles, ?string $email = */ public function getMembership(string $teamId, string $membershipId): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -563,6 +624,14 @@ public function getMembership(string $teamId, string $membershipId): \Appwrite\M */ public function updateMembership(string $teamId, string $membershipId, array $roles): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -602,6 +671,14 @@ public function updateMembership(string $teamId, string $membershipId, array $ro */ public function deleteMembership(string $teamId, string $membershipId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -615,6 +692,7 @@ public function deleteMembership(string $teamId, string $membershipId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -636,6 +714,14 @@ public function deleteMembership(string $teamId, string $membershipId): string */ public function updateMembershipStatus(string $teamId, string $membershipId, string $userId, string $secret): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -676,6 +762,10 @@ public function updateMembershipStatus(string $teamId, string $membershipId, str */ public function getPrefs(string $teamId): \Appwrite\Models\Preferences { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -712,6 +802,10 @@ public function getPrefs(string $teamId): \Appwrite\Models\Preferences */ public function updatePrefs(string $teamId, array $prefs): \Appwrite\Models\Preferences { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], diff --git a/src/Appwrite/Services/Tokens.php b/src/Appwrite/Services/Tokens.php index 1d2b5137..a5d3bc40 100644 --- a/src/Appwrite/Services/Tokens.php +++ b/src/Appwrite/Services/Tokens.php @@ -18,6 +18,14 @@ class Tokens extends Service */ public function list(string $bucketId, string $fileId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ResourceTokenList { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -62,6 +70,14 @@ public function list(string $bucketId, string $fileId, ?array $queries = null, ? */ public function createFileToken(string $bucketId, string $fileId, ?string $expire = null): \Appwrite\Models\ResourceToken { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -99,6 +115,10 @@ public function createFileToken(string $bucketId, string $fileId, ?string $expir */ public function get(string $tokenId): \Appwrite\Models\ResourceToken { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -134,6 +154,10 @@ public function get(string $tokenId): \Appwrite\Models\ResourceToken */ public function update(string $tokenId, ?string $expire = null): \Appwrite\Models\ResourceToken { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -170,6 +194,10 @@ public function update(string $tokenId, ?string $expire = null): \Appwrite\Model */ public function delete(string $tokenId): string { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -182,6 +210,7 @@ public function delete(string $tokenId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index b0333df3..cbd44020 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -76,10 +76,7 @@ public function create(string $userId, ?string $email = null, ?string $phone = n $apiParams['userId'] = $userId; $apiParams['email'] = $email; $apiParams['phone'] = $phone; - - if (!is_null($password)) { - $apiParams['password'] = $password; - } + $apiParams['password'] = $password; if (!is_null($name)) { $apiParams['name'] = $name; @@ -244,6 +241,10 @@ public function listIdentities(?array $queries = null, ?string $search = null, ? */ public function deleteIdentity(string $identityId): string { + if ($identityId === '') { + throw new AppwriteException('Missing required parameter: "identityId"'); + } + $apiPath = str_replace( ['{identityId}'], [$identityId], @@ -256,6 +257,7 @@ public function deleteIdentity(string $identityId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -505,6 +507,10 @@ public function createSHAUser(string $userId, string $email, string $password, ? */ public function get(string $userId): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -544,6 +550,10 @@ public function get(string $userId): \Appwrite\Models\User */ public function delete(string $userId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -556,6 +566,7 @@ public function delete(string $userId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -572,6 +583,10 @@ public function delete(string $userId): string */ public function updateEmail(string $userId, string $email): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -606,12 +621,19 @@ public function updateEmail(string $userId, string $email): \Appwrite\Models\Use * impersonation headers are used, the request runs as the target user for API * behavior, while internal audit logs still attribute the action to the * original impersonator and store the impersonated target details only in - * internal audit payload data. + * internal audit payload data. Account endpoints are read-only while + * impersonating: they report the target's account, and anything that would + * change it is refused, so an impersonator cannot alter the target's + * credentials or delete their account. * * @throws AppwriteException */ public function updateImpersonator(string $userId, bool $impersonator): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -650,6 +672,10 @@ public function updateImpersonator(string $userId, bool $impersonator): \Appwrit */ public function createJWT(string $userId, ?string $sessionId = null, ?int $duration = null): \Appwrite\Models\Jwt { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -698,6 +724,10 @@ public function createJWT(string $userId, ?string $sessionId = null, ?int $durat */ public function updateLabels(string $userId, array $labels): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -727,48 +757,6 @@ public function updateLabels(string $userId, array $labels): \Appwrite\Models\Us return \Appwrite\Models\User::from($response); } - /** - * Get the user activity logs list by its unique ID. - * - * @throws AppwriteException - */ - public function listLogs(string $userId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - ['{userId}'], - [$userId], - '/users/{userId}/logs' - ); - - $apiParams = []; - $apiParams['userId'] = $userId; - - 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 user membership list by its unique ID. * @@ -776,6 +764,10 @@ public function listLogs(string $userId, ?array $queries = null, ?bool $total = */ public function listMemberships(string $userId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\MembershipList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -822,6 +814,10 @@ public function listMemberships(string $userId, ?array $queries = null, ?string */ public function updateMFA(string $userId, bool $mfa): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -858,6 +854,10 @@ public function updateMFA(string $userId, bool $mfa): \Appwrite\Models\User */ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}', '{type}'], [$userId, (string) $type], @@ -871,6 +871,7 @@ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -888,6 +889,14 @@ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): */ public function getMFAChallenge(string $userId, string $challengeId): \Appwrite\Models\MfaChallengeSecret { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($challengeId === '') { + throw new AppwriteException('Missing required parameter: "challengeId"'); + } + $apiPath = str_replace( ['{userId}', '{challengeId}'], [$userId, $challengeId], @@ -923,6 +932,10 @@ public function getMFAChallenge(string $userId, string $challengeId): \Appwrite\ */ public function listMFAFactors(string $userId): \Appwrite\Models\MfaFactors { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -960,6 +973,10 @@ public function listMFAFactors(string $userId): \Appwrite\Models\MfaFactors */ public function getMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -997,6 +1014,10 @@ public function getMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecover */ public function updateMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1035,6 +1056,10 @@ public function updateMFARecoveryCodes(string $userId): \Appwrite\Models\MfaReco */ public function createMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1070,6 +1095,10 @@ public function createMFARecoveryCodes(string $userId): \Appwrite\Models\MfaReco */ public function updateName(string $userId, string $name): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1279,6 +1308,10 @@ public function deletePasskey(string $userId, string $passkeyId): string */ public function updatePassword(string $userId, string $password): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1315,6 +1348,10 @@ public function updatePassword(string $userId, string $password): \Appwrite\Mode */ public function updatePhone(string $userId, string $number): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1351,6 +1388,10 @@ public function updatePhone(string $userId, string $number): \Appwrite\Models\Us */ public function getPrefs(string $userId): \Appwrite\Models\Preferences { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1387,6 +1428,10 @@ public function getPrefs(string $userId): \Appwrite\Models\Preferences */ public function updatePrefs(string $userId, array $prefs): \Appwrite\Models\Preferences { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1423,6 +1468,10 @@ public function updatePrefs(string $userId, array $prefs): \Appwrite\Models\Pref */ public function listSessions(string $userId, ?bool $total = null): \Appwrite\Models\SessionList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1466,6 +1515,10 @@ public function listSessions(string $userId, ?bool $total = null): \Appwrite\Mod */ public function createSession(string $userId): \Appwrite\Models\Session { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1501,6 +1554,10 @@ public function createSession(string $userId): \Appwrite\Models\Session */ public function deleteSessions(string $userId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1513,6 +1570,7 @@ public function deleteSessions(string $userId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1529,6 +1587,14 @@ public function deleteSessions(string $userId): string */ public function deleteSession(string $userId, string $sessionId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{userId}', '{sessionId}'], [$userId, $sessionId], @@ -1542,6 +1608,7 @@ public function deleteSession(string $userId, string $sessionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1559,6 +1626,10 @@ public function deleteSession(string $userId, string $sessionId): string */ public function updateStatus(string $userId, bool $status): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1595,6 +1666,10 @@ public function updateStatus(string $userId, bool $status): \Appwrite\Models\Use */ public function listTargets(string $userId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\TargetList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1637,6 +1712,10 @@ public function listTargets(string $userId, ?array $queries = null, ?bool $total */ public function createTarget(string $userId, string $targetId, MessagingProviderType $providerType, string $identifier, ?string $providerId = null, ?string $name = null): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1683,6 +1762,14 @@ public function createTarget(string $userId, string $targetId, MessagingProvider */ public function getTarget(string $userId, string $targetId): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1718,6 +1805,14 @@ public function getTarget(string $userId, string $targetId): \Appwrite\Models\Ta */ public function updateTarget(string $userId, string $targetId, ?string $identifier = null, ?string $providerId = null, ?string $name = null): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1766,6 +1861,14 @@ public function updateTarget(string $userId, string $targetId, ?string $identifi */ public function deleteTarget(string $userId, string $targetId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1779,6 +1882,7 @@ public function deleteTarget(string $userId, string $targetId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1798,6 +1902,10 @@ public function deleteTarget(string $userId, string $targetId): string */ public function createToken(string $userId, ?int $length = null, ?int $expire = null): \Appwrite\Models\Token { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1841,6 +1949,10 @@ public function createToken(string $userId, ?int $length = null, ?int $expire = */ public function updateEmailVerification(string $userId, bool $emailVerification): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1877,6 +1989,10 @@ public function updateEmailVerification(string $userId, bool $emailVerification) */ public function updatePhoneVerification(string $userId, bool $phoneVerification): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], diff --git a/src/Appwrite/Services/VectorsDB.php b/src/Appwrite/Services/VectorsDB.php index c2a5c12a..053efccb 100644 --- a/src/Appwrite/Services/VectorsDB.php +++ b/src/Appwrite/Services/VectorsDB.php @@ -104,8 +104,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -223,6 +223,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -257,6 +261,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -300,6 +308,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -312,6 +324,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -328,6 +341,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -368,6 +385,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -402,6 +423,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, string $name, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -446,6 +471,10 @@ public function update(string $databaseId, string $name, ?bool $enabled = null, */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -458,6 +487,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -475,6 +505,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\VectorsdbCollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -524,6 +558,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, int $dimension, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -575,6 +613,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -610,6 +656,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?int $dimension = null, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -632,10 +686,7 @@ public function updateCollection(string $databaseId, string $collectionId, strin if (!is_null($documentSecurity)) { $apiParams['documentSecurity'] = $documentSecurity; } - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } + $apiParams['enabled'] = $enabled; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -664,6 +715,14 @@ public function updateCollection(string $databaseId, string $collectionId, strin */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -677,6 +736,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -694,6 +754,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -748,6 +816,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -797,6 +873,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -841,6 +925,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -884,6 +976,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -933,6 +1033,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -980,6 +1088,14 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function createQuery(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1033,6 +1149,18 @@ public function createQuery(string $databaseId, string $collectionId, ?array $qu */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1080,6 +1208,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1130,6 +1270,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1179,6 +1331,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1197,6 +1361,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1213,6 +1378,14 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1258,6 +1431,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, VectorsDBIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1305,6 +1486,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1341,6 +1534,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1355,6 +1560,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1379,6 +1585,10 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1418,6 +1628,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1465,6 +1679,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1501,6 +1719,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Webhooks.php b/src/Appwrite/Services/Webhooks.php index 2694980a..7563d2ff 100644 --- a/src/Appwrite/Services/Webhooks.php +++ b/src/Appwrite/Services/Webhooks.php @@ -116,6 +116,10 @@ public function create(string $webhookId, string $url, string $name, array $even */ public function get(string $webhookId): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -151,6 +155,10 @@ public function get(string $webhookId): \Appwrite\Models\Webhook */ public function update(string $webhookId, string $name, string $url, array $events, ?bool $enabled = null, ?bool $tls = null, ?string $authUsername = null, ?string $authPassword = null): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -174,10 +182,7 @@ public function update(string $webhookId, string $name, string $url, array $even if (!is_null($authUsername)) { $apiParams['authUsername'] = $authUsername; } - - if (!is_null($authPassword)) { - $apiParams['authPassword'] = $authPassword; - } + $apiParams['authPassword'] = $authPassword; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -206,6 +211,10 @@ public function update(string $webhookId, string $name, string $url, array $even */ public function delete(string $webhookId): string { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -218,6 +227,7 @@ public function delete(string $webhookId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -236,6 +246,10 @@ public function delete(string $webhookId): string */ public function updateSecret(string $webhookId, ?string $secret = null): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], diff --git a/src/Appwrite/Topic.php b/src/Appwrite/Topic.php new file mode 100644 index 00000000..9377b2fc --- /dev/null +++ b/src/Appwrite/Topic.php @@ -0,0 +1,144 @@ +any()->path(['notification']); // "user/+/notification" + * Topic::path(['org'])->any()->path(['logs'])->all(); // "org/+/logs/#" + * + * `any()` matches exactly one level and `all()` everything below, at any depth (including the + * parent itself). `all()` ends the topic, so it returns a ResolvedTopic. + * + * The same names start a topic (`Topic::path()`) and extend one (`$topic->path()`); both are + * routed through `__callStatic()` and `__call()` to the protected implementations below. + * + * @method static Topic path(array $levels) Start a topic with the given levels, or append them. + * @method static Topic any() Start a topic with a single-level wildcard (`+`), or append one. + * @method static ResolvedTopic all() The multi-level wildcard (`#`) alone, or appended to end the topic. + */ +final readonly class Topic implements \Stringable +{ + /** + * @param list $levels + */ + private function __construct(private array $levels) + { + } + + /** + * @param array $arguments + */ + public static function __callStatic(string $name, array $arguments): self|ResolvedTopic + { + return new self([])->dispatch($name, $arguments); + } + + /** + * @param array $arguments + */ + public function __call(string $name, array $arguments): self|ResolvedTopic + { + return $this->dispatch($name, $arguments); + } + + /** + * Append the given levels. + */ + protected function appendPath(mixed $levels): self + { + return new self([...$this->levels, ...$this->levelsOf($levels)]); + } + + /** + * Append a single-level wildcard (`+`): matches exactly one level. + */ + protected function appendAny(): self + { + return new self([...$this->levels, '+']); + } + + /** + * Append the multi-level wildcard (`#`) and end the topic. + */ + protected function appendAll(): ResolvedTopic + { + return new ResolvedTopic([...$this->levels, '#']); + } + + public function __toString(): string + { + return \implode('/', $this->levels); + } + + /** + * @param array $arguments + */ + private function dispatch(string $name, array $arguments): self|ResolvedTopic + { + return match ($name) { + 'path' => $this->appendPath($arguments[0] ?? null), + 'any' => $this->appendAny(), + 'all' => $this->appendAll(), + default => throw new \BadMethodCallException('Call to undefined method ' . self::class . '::' . $name . '()'), + }; + } + + /** + * Validate the levels passed to `path()`: a non-empty array of non-empty strings, none holding + * the level separator `/` or the wildcards `+` and `#` (use `any()` and `all()` for those). + * + * @return list + */ + private function levelsOf(mixed $levels): array + { + if (!\is_array($levels)) { + throw new \InvalidArgumentException("path() expects an array, e.g. path(['user'])"); + } + + if ($levels === []) { + throw new \InvalidArgumentException('path() needs at least one level'); + } + + $result = []; + foreach (\array_values($levels) as $index => $level) { + if (!\is_string($level)) { + $type = $level === null ? 'null' : \get_debug_type($level); + throw new \InvalidArgumentException(\sprintf('level at index %d must be a string, got %s', $index, $type)); + } + + if ($level === '') { + throw new \InvalidArgumentException(\sprintf('empty level at index %d', $index)); + } + + if (\str_contains($level, '/')) { + $parts = \implode(', ', \array_map(static fn (string $part): string => "'" . $part . "'", \explode('/', $level))); + throw new \InvalidArgumentException(\sprintf('"%s" contains "/", split it: path([%s])', $level, $parts)); + } + + if ($level === '+') { + throw new \InvalidArgumentException('"+" is reserved, use any()'); + } + + if (\str_contains($level, '+')) { + throw new \InvalidArgumentException(\sprintf('"%s" contains "+", use any() for wildcards', $level)); + } + + if ($level === '#') { + throw new \InvalidArgumentException('"#" is reserved, use all()'); + } + + if (\str_contains($level, '#')) { + throw new \InvalidArgumentException(\sprintf('"%s" contains "#", use all() for wildcards', $level)); + } + + $result[] = $level; + } + + return $result; + } +} diff --git a/tests/Appwrite/ClientTest.php b/tests/Appwrite/ClientTest.php index 46678475..99d5b6ff 100644 --- a/tests/Appwrite/ClientTest.php +++ b/tests/Appwrite/ClientTest.php @@ -5,9 +5,14 @@ namespace Appwrite; use PHPUnit\Framework\TestCase; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; use ReflectionMethod; use ReflectionProperty; use Utopia\Client\Client as HttpClient; +use Utopia\Psr7\Response; +use Utopia\Psr7\Stream; final class ClientTest extends TestCase { @@ -117,13 +122,6 @@ public function testSetForwardedUserAgentReturnsClient(): void $this->assertSame($client, $result); } - public function testSetDevKeyReturnsClient(): void - { - $client = new Client(); - $result = $client->setDevKey('test-value'); - $this->assertSame($client, $result); - } - public function testSetCookieReturnsClient(): void { $client = new Client(); @@ -185,7 +183,76 @@ public function testSelfSignedAndConnectTimeoutResetHttpClient(): void $this->assertNotSame($afterSelfSigned, $this->httpClient($client, true)); } - private function httpClient(Client $client, bool $followRedirects): HttpClient + public function testInjectedTransportReceivesEncodedRequests(): void + { + $received = []; + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->once())->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request) use (&$received): ResponseInterface { + $received[] = $request; + + return new Response(body: new Stream('{"received":true}')) + ->withHeader('content-type', 'application/json'); + }); + + $client = new Client($transport) + ->setEndpoint('https://example.com/v1') + ->addHeader('x-test', 'injected'); + + $this->assertSame(['received' => true], $client->call(Client::METHOD_POST, '/items', ['content-type' => 'application/json'], ['name' => 'item'])); + $this->assertCount(1, $received); + $this->assertSame('POST', $received[0]->getMethod()); + $this->assertSame('https://example.com/v1/items', (string) $received[0]->getUri()); + $this->assertSame(['name' => 'item'], json_decode((string) $received[0]->getBody(), true)); + $this->assertSame('injected', $received[0]->getHeaderLine('x-test')); + } + + public function testInjectedTransportSurvivesFailureAndConfigurationChanges(): void + { + $received = []; + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->exactly(2))->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request) use (&$received): ResponseInterface { + $received[] = (string) $request->getUri(); + + return count($received) === 1 + ? new Response(503, body: new Stream('{"message":"Unavailable","type":"unavailable"}'))->withHeader('content-type', 'application/json') + : new Response(body: new Stream('null'))->withHeader('content-type', 'application/json'); + }); + $client = new Client($transport)->setEndpoint('https://first.example'); + + $failure = null; + try { + $client->call(Client::METHOD_GET, '/fail'); + } catch (AppwriteException $error) { + $failure = $error; + } + + $client->setEndpoint('https://second.example')->setTimeout(5)->setConnectTimeout(2)->setSelfSigned(true); + $this->assertNull($client->call(Client::METHOD_GET, '/next', params: ['project' => 'project-1'])); + $this->assertInstanceOf(AppwriteException::class, $failure); + $this->assertSame(503, $failure->getCode()); + $this->assertSame(['https://first.example/fail', 'https://second.example/next?project=project-1'], $received); + $this->assertSame($transport, $this->httpClient($client, true)); + $this->assertSame($transport, $this->httpClient($client, false)); + } + + public function testLocationResponseUsesInjectedTransport(): void + { + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->once())->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request): ResponseInterface { + $this->assertSame('GET', $request->getMethod()); + $this->assertSame('https://example.com/redirect', (string) $request->getUri()); + + return new Response(302)->withHeader('location', 'https://storage.example/file'); + }); + + $client = new Client($transport)->setEndpoint('https://example.com'); + $this->assertSame('https://storage.example/file', $client->call(Client::METHOD_GET, '/redirect', responseType: 'location')); + } + + private function httpClient(Client $client, bool $followRedirects): ClientInterface { $method = new ReflectionMethod(Client::class, 'getHttpClient'); diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php index c4a20ad2..eed55b62 100644 --- a/tests/Appwrite/Services/AccountTest.php +++ b/tests/Appwrite/Services/AccountTest.php @@ -333,7 +333,8 @@ public function testMethodListIdentities(): void "providerEmail" => "user@example.com", "providerAccessToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", "providerAccessTokenExpiry" => "2020-10-15T06:38:00.000+00:00", - "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3" + "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerIdToken" => "eyJhbGciOiJSUzI1NiIsImtpZCI6IjBhYzNmMWQwNWExYjhlN2YifQ.eyJzdWIiOiIxMTAxNjk0ODQ0NzQzODYyNzYzMzQifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ] ] ]; @@ -366,49 +367,6 @@ public function testMethodDeleteIdentity(): void $this->assertSame($data, $response); } - public function testMethodListLogs(): void - { - $data = [ - "total" => 5, - "logs" => [ - [ - "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->account->listLogs(); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } public function testMethodUpdateMFA(): void { $data = [ diff --git a/tests/Appwrite/Services/BackupsTest.php b/tests/Appwrite/Services/BackupsTest.php index 353bd0d7..11782077 100644 --- a/tests/Appwrite/Services/BackupsTest.php +++ b/tests/Appwrite/Services/BackupsTest.php @@ -31,9 +31,7 @@ public function testMethodListArchives(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -59,9 +57,7 @@ public function testMethodCreateArchive(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -87,9 +83,7 @@ public function testMethodGetArchive(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -182,7 +176,7 @@ public function testMethodCreatePolicy(): void "", [BackupServices::DATABASES()], 1, - "" + "schedule" ); $this->assertInstanceOf(\Appwrite\Models\BackupPolicy::class, $response); @@ -269,11 +263,10 @@ public function testMethodCreateRestoration(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ]; $this->client @@ -302,11 +295,10 @@ public function testMethodListRestorations(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ] ] ]; @@ -331,11 +323,10 @@ public function testMethodGetRestoration(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ]; $this->client diff --git a/tests/Appwrite/Services/DocumentsDBTest.php b/tests/Appwrite/Services/DocumentsDBTest.php index 183fdefc..9f51a063 100644 --- a/tests/Appwrite/Services/DocumentsDBTest.php +++ b/tests/Appwrite/Services/DocumentsDBTest.php @@ -81,6 +81,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -89,13 +93,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -970,16 +968,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -989,6 +983,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1002,7 +998,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1096,10 +1092,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, diff --git a/tests/Appwrite/Services/FunctionsTest.php b/tests/Appwrite/Services/FunctionsTest.php index 0e950d3a..dc681800 100644 --- a/tests/Appwrite/Services/FunctionsTest.php +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -808,7 +808,7 @@ public function testMethodListExecutions(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ] ] ]; @@ -856,7 +856,7 @@ public function testMethodCreateExecution(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client @@ -902,7 +902,7 @@ public function testMethodGetExecution(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client diff --git a/tests/Appwrite/Services/MongoTest.php b/tests/Appwrite/Services/MongoTest.php index aaa2b0ea..db3fd910 100644 --- a/tests/Appwrite/Services/MongoTest.php +++ b/tests/Appwrite/Services/MongoTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -819,16 +804,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -838,6 +819,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -851,7 +834,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -884,16 +867,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -903,6 +882,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -916,7 +897,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -951,16 +932,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -970,6 +947,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -983,7 +962,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1099,14 +1078,9 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1131,14 +1105,9 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1161,14 +1130,9 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1194,10 +1158,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1240,16 +1200,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1259,6 +1215,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1272,7 +1230,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/MysqlTest.php b/tests/Appwrite/Services/MysqlTest.php index 85f067a6..c413429a 100644 --- a/tests/Appwrite/Services/MysqlTest.php +++ b/tests/Appwrite/Services/MysqlTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -849,16 +834,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -868,6 +849,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -881,7 +864,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -914,16 +897,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -933,6 +912,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -946,7 +927,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -981,16 +962,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1000,6 +977,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1013,7 +992,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1185,14 +1164,9 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1217,14 +1191,9 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1247,14 +1216,9 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1280,10 +1244,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1326,16 +1286,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1345,6 +1301,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1358,7 +1316,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/Oauth2Test.php b/tests/Appwrite/Services/Oauth2Test.php index 3196d5e8..ed0c9360 100644 --- a/tests/Appwrite/Services/Oauth2Test.php +++ b/tests/Appwrite/Services/Oauth2Test.php @@ -80,8 +80,8 @@ public function testMethodCreateDeviceAuthorization(): void $data = [ "device_code" => "5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a", "user_code" => "ABCD-EFGH", - "verification_uri" => "https://cloud.appwrite.io/console/oauth2/device", - "verification_uri_complete" => "https://cloud.appwrite.io/console/oauth2/device?user_code=ABCD-EFGH", + "verification_uri" => "https://appwrite.io/oauth2/device", + "verification_uri_complete" => "https://appwrite.io/oauth2/device?user_code=ABCD-EFGH", "expires_in" => 900, "interval" => 5 ]; diff --git a/tests/Appwrite/Services/OrganizationTest.php b/tests/Appwrite/Services/OrganizationTest.php index 1132dac0..7fa0c08a 100644 --- a/tests/Appwrite/Services/OrganizationTest.php +++ b/tests/Appwrite/Services/OrganizationTest.php @@ -8,7 +8,6 @@ use Mockery; use Mockery\MockInterface; use PHPUnit\Framework\TestCase; -use Appwrite\Enums\OrganizationKeyScopes; use Appwrite\Enums\ProjectKeyScopes; final class OrganizationTest extends TestCase @@ -47,6 +46,7 @@ public function testMethodGet(): void "screenshotsGenerated" => 50, "webhooks" => 25, "wafRules" => 2, + "environments" => 5, "projects" => 2, "platforms" => 3, "users" => 25, @@ -71,72 +71,6 @@ public function testMethodGet(): void "usageLogs" => 30, "projectInactivityDays" => 7, "alertLimit" => 80, - "usage" => [ - "bandwidth" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "executions" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtime" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtimeMessages" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "storage" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "users" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "GBHours" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "imageTransformations" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ] - ], "addons" => [], "budgetCapEnabled" => true, "customSmtp" => true, @@ -166,17 +100,10 @@ public function testMethodGet(): void "buildSize" => 2000, "functionsIntervalMinimum" => 60, "databasesAllowEncrypt" => true, - "group" => "starter", + "group" => "free", "databaseComputeCredit" => 10 ], "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", - "billingTrialDays" => 14, - "billingAggregationId" => "adbc3de4rddfsd", - "billingInvoiceId" => "adbc3de4rddfsd", - "paymentMethodId" => "adbc3de4rddfsd", "status" => "active", "markedForDeletion" => true, "platform" => "imagine", @@ -219,6 +146,7 @@ public function testMethodUpdate(): void "screenshotsGenerated" => 50, "webhooks" => 25, "wafRules" => 2, + "environments" => 5, "projects" => 2, "platforms" => 3, "users" => 25, @@ -243,72 +171,6 @@ public function testMethodUpdate(): void "usageLogs" => 30, "projectInactivityDays" => 7, "alertLimit" => 80, - "usage" => [ - "bandwidth" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "executions" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtime" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtimeMessages" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "storage" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "users" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "GBHours" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "imageTransformations" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ] - ], "addons" => [], "budgetCapEnabled" => true, "customSmtp" => true, @@ -338,17 +200,10 @@ public function testMethodUpdate(): void "buildSize" => 2000, "functionsIntervalMinimum" => 60, "databasesAllowEncrypt" => true, - "group" => "starter", + "group" => "free", "databaseComputeCredit" => 10 ], "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", - "billingTrialDays" => 14, - "billingAggregationId" => "adbc3de4rddfsd", - "billingInvoiceId" => "adbc3de4rddfsd", - "paymentMethodId" => "adbc3de4rddfsd", "status" => "active", "markedForDeletion" => true, "platform" => "imagine", @@ -511,138 +366,6 @@ public function testMethodDeleteInstallation(): void $this->assertSame($data, $response); } - public function testMethodListKeys(): void - { - $data = [ - "total" => 5, - "keys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->listKeys(); - - $this->assertInstanceOf(\Appwrite\Models\KeyList::class, $response); - } - public function testMethodCreateKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->createKey( - "", - "", - [OrganizationKeyScopes::PROJECTSREAD()] - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodGetKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->getKey( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodUpdateKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->updateKey( - "", - "", - [OrganizationKeyScopes::PROJECTSREAD()] - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodDeleteKey(): 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->deleteKey( - "" - ); - - $this->assertSame($data, $response); - } public function testMethodListMemberships(): void { $data = [ @@ -808,18 +531,6 @@ public function testMethodListProjects(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -858,12 +569,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -891,18 +597,6 @@ public function testMethodCreateProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -941,12 +635,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -975,18 +664,6 @@ public function testMethodGetProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -1025,12 +702,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -1058,18 +730,6 @@ public function testMethodUpdateProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -1108,12 +768,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" diff --git a/tests/Appwrite/Services/PostgresqlTest.php b/tests/Appwrite/Services/PostgresqlTest.php index f4204910..f5ef1b99 100644 --- a/tests/Appwrite/Services/PostgresqlTest.php +++ b/tests/Appwrite/Services/PostgresqlTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -877,16 +862,12 @@ public function testMethodCreateExtension(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -896,6 +877,8 @@ public function testMethodCreateExtension(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -909,7 +892,7 @@ public function testMethodCreateExtension(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -943,16 +926,12 @@ public function testMethodDeleteExtension(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -962,6 +941,8 @@ public function testMethodDeleteExtension(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -975,7 +956,7 @@ public function testMethodDeleteExtension(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1009,16 +990,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1028,6 +1005,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1041,7 +1020,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1074,16 +1053,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1093,6 +1068,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1106,7 +1083,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1141,16 +1118,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1160,6 +1133,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1173,7 +1148,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1345,14 +1320,9 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1377,14 +1347,9 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1407,14 +1372,9 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1440,10 +1400,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1486,16 +1442,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1505,6 +1457,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1518,7 +1472,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/ProjectTest.php b/tests/Appwrite/Services/ProjectTest.php index ca05b4f6..5d9b3983 100644 --- a/tests/Appwrite/Services/ProjectTest.php +++ b/tests/Appwrite/Services/ProjectTest.php @@ -36,18 +36,6 @@ public function testMethodGet(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -86,12 +74,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -132,18 +115,6 @@ public function testMethodUpdateAuthMethod(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -182,12 +153,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -219,7 +185,6 @@ public function testMethodListEnvironments(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -258,12 +223,7 @@ public function testMethodListEnvironments(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -291,7 +251,6 @@ public function testMethodCreateEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -330,12 +289,7 @@ public function testMethodCreateEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -364,7 +318,6 @@ public function testMethodGetEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -403,12 +356,7 @@ public function testMethodGetEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -436,7 +384,6 @@ public function testMethodUpdateEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -475,12 +422,7 @@ public function testMethodUpdateEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -657,18 +599,6 @@ public function testMethodUpdateLabels(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -707,12 +637,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -868,18 +793,6 @@ public function testMethodUpdateOAuth2Server(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -918,12 +831,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -971,7 +879,9 @@ public function testMethodUpdateOAuth2Apple(): void "serviceId" => "ip.appwrite.app.web", "keyId" => "P4000000N8", "teamId" => "D4000000R6", - "p8File" => "-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----" + "p8File" => "-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----", + "nativeEnabled" => true, + "nativeClientIds" => [] ]; $this->client @@ -1012,6 +922,7 @@ public function testMethodUpdateOAuth2Auth0(): void "enabled" => true, "clientId" => "OaOkIA000000000000000000005KLSYq", "clientSecret" => "zXz0000-00000000000000000000000000000-00000000000000000000PJafnF", + "prompt" => ["none"], "endpoint" => "example.us.auth0.com" ]; @@ -1173,7 +1084,8 @@ public function testMethodUpdateOAuth2Discord(): void "\$id" => "github", "enabled" => true, "clientId" => "950722000000343754", - "clientSecret" => "YmPXnM000000000000000000002zFg5D" + "clientSecret" => "YmPXnM000000000000000000002zFg5D", + "prompt" => ["none"] ]; $this->client @@ -1314,7 +1226,8 @@ public function testMethodUpdateOAuth2GitHub(): void "\$id" => "github", "enabled" => true, "clientId" => "e4d87900000000540733", - "clientSecret" => "5e07c00000000000000000000000000000198bcc" + "clientSecret" => "5e07c00000000000000000000000000000198bcc", + "prompt" => ["select_account"] ]; $this->client @@ -1356,7 +1269,9 @@ public function testMethodUpdateOAuth2Google(): void "enabled" => true, "clientId" => "120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com", "clientSecret" => "GOCSPX-2k8gsR0000000000000000VNahJj", - "prompt" => ["none"] + "prompt" => ["none"], + "nativeEnabled" => true, + "nativeClientIds" => [] ]; $this->client @@ -1480,6 +1395,7 @@ public function testMethodUpdateOAuth2Microsoft(): void "enabled" => true, "applicationId" => "00001111-aaaa-2222-bbbb-3333cccc4444", "applicationSecret" => "A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u", + "prompt" => ["none"], "tenant" => "common" ]; @@ -1521,11 +1437,11 @@ public function testMethodUpdateOAuth2Oidc(): void "enabled" => true, "clientId" => "qibI2x0000000000000000000000000006L2YFoG", "clientSecret" => "Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV", + "prompt" => ["none"], "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", - "prompt" => ["none"] + "userInfoURL" => "https://myoauth.com/oauth2/userinfo" ]; $this->client @@ -1546,6 +1462,7 @@ public function testMethodUpdateOAuth2Okta(): void "enabled" => true, "clientId" => "0oa00000000000000698", "clientSecret" => "Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV", + "prompt" => ["none"], "domain" => "trial-6400025.okta.com", "authorizationServerId" => "aus000000000000000h7z" ]; @@ -1647,7 +1564,8 @@ public function testMethodUpdateOAuth2Salesforce(): void "\$id" => "github", "enabled" => true, "customerKey" => "3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq", - "customerSecret" => "3w000000000000e2" + "customerSecret" => "3w000000000000e2", + "prompt" => ["login"] ]; $this->client @@ -1907,7 +1825,8 @@ public function testMethodUpdateOAuth2Zoho(): void "\$id" => "github", "enabled" => true, "clientId" => "1000.83C178000000000000000000RPNX0B", - "clientSecret" => "fb5cac000000000000000000000000000000a68f6e" + "clientSecret" => "fb5cac000000000000000000000000000000a68f6e", + "prompt" => ["consent"] ]; $this->client @@ -1995,7 +1914,8 @@ public function testMethodCreateAndroidPlatform(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "My Web App", "type" => "windows", - "applicationId" => "com.company.appname" + "applicationId" => "com.company.appname", + "fingerprints" => [] ]; $this->client @@ -2021,7 +1941,8 @@ public function testMethodUpdateAndroidPlatform(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "My Web App", "type" => "windows", - "applicationId" => "com.company.appname" + "applicationId" => "com.company.appname", + "fingerprints" => [] ]; $this->client @@ -2320,18 +2241,6 @@ public function testMethodUpdateDenyAliasedEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2370,12 +2279,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2403,18 +2307,6 @@ public function testMethodUpdateDenyCorporateEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2453,12 +2345,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2486,18 +2373,6 @@ public function testMethodUpdateDenyDisposableEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2536,12 +2411,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2569,18 +2439,6 @@ public function testMethodUpdateDenyFreeEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2619,12 +2477,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2652,18 +2505,6 @@ public function testMethodUpdateMembershipPrivacyPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2702,12 +2543,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2733,18 +2569,6 @@ public function testMethodUpdateMFAFactorsPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2783,12 +2607,7 @@ public function testMethodUpdateMFAFactorsPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2814,18 +2633,6 @@ public function testMethodUpdatePasskeyPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2864,12 +2671,7 @@ public function testMethodUpdatePasskeyPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2897,18 +2699,6 @@ public function testMethodUpdatePasswordDictionaryPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2947,12 +2737,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2980,18 +2765,6 @@ public function testMethodUpdatePasswordHistoryPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3030,12 +2803,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3063,18 +2831,6 @@ public function testMethodUpdatePasswordPersonalDataPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3113,12 +2869,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3146,7 +2897,6 @@ public function testMethodUpdatePasswordPwnedPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3185,12 +2935,7 @@ public function testMethodUpdatePasswordPwnedPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3216,7 +2961,6 @@ public function testMethodUpdatePasswordRotationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3255,12 +2999,7 @@ public function testMethodUpdatePasswordRotationPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3308,18 +3047,6 @@ public function testMethodUpdateSessionAlertPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3358,12 +3085,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3391,18 +3113,6 @@ public function testMethodUpdateSessionDurationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3441,12 +3151,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3474,18 +3179,6 @@ public function testMethodUpdateSessionInvalidationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3524,12 +3217,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3557,18 +3245,6 @@ public function testMethodUpdateSessionLimitPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3607,12 +3283,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3640,18 +3311,6 @@ public function testMethodUpdateUserLimitPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3690,12 +3349,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3749,18 +3403,6 @@ public function testMethodUpdateProtocol(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3799,12 +3441,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3833,18 +3470,6 @@ public function testMethodUpdateService(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3883,12 +3508,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3917,18 +3537,6 @@ public function testMethodUpdateSMTP(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3967,12 +3575,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" diff --git a/tests/Appwrite/Services/SitesTest.php b/tests/Appwrite/Services/SitesTest.php index 1dd5e5aa..0b0f8581 100644 --- a/tests/Appwrite/Services/SitesTest.php +++ b/tests/Appwrite/Services/SitesTest.php @@ -829,7 +829,7 @@ public function testMethodListLogs(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ] ] ]; @@ -877,7 +877,7 @@ public function testMethodGetLog(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client diff --git a/tests/Appwrite/Services/TablesDBTest.php b/tests/Appwrite/Services/TablesDBTest.php index 51b883a9..5ef55c32 100644 --- a/tests/Appwrite/Services/TablesDBTest.php +++ b/tests/Appwrite/Services/TablesDBTest.php @@ -82,6 +82,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -90,13 +94,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -321,16 +319,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -340,6 +334,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -353,7 +349,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -613,10 +609,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1651,6 +1643,39 @@ public function testMethodCreateRelationshipColumn(): void $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); } + public function testMethodUpdateRelationshipColumn(): void + { + $data = [ + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "relatedTable" => "table", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->tablesDB->updateRelationshipColumn( + "", + "", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); + } public function testMethodCreateStringColumn(): void { $data = [ @@ -1939,39 +1964,6 @@ public function testMethodDeleteColumn(): void $this->assertSame($data, $response); } - public function testMethodUpdateRelationshipColumn(): void - { - $data = [ - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "relatedTable" => "table", - "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", - "twoWay" => true, - "twoWayKey" => "string", - "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child" - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->tablesDB->updateRelationshipColumn( - "", - "", - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); - } public function testMethodListIndexes(): void { $data = [ diff --git a/tests/Appwrite/Services/UsersTest.php b/tests/Appwrite/Services/UsersTest.php index 4179bae7..34677d39 100644 --- a/tests/Appwrite/Services/UsersTest.php +++ b/tests/Appwrite/Services/UsersTest.php @@ -224,7 +224,8 @@ public function testMethodListIdentities(): void "providerEmail" => "user@example.com", "providerAccessToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", "providerAccessTokenExpiry" => "2020-10-15T06:38:00.000+00:00", - "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3" + "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerIdToken" => "eyJhbGciOiJSUzI1NiIsImtpZCI6IjBhYzNmMWQwNWExYjhlN2YifQ.eyJzdWIiOiIxMTAxNjk0ODQ0NzQzODYyNzYzMzQifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ] ] ]; @@ -719,51 +720,6 @@ public function testMethodUpdateLabels(): void $this->assertInstanceOf(\Appwrite\Models\User::class, $response); } - public function testMethodListLogs(): void - { - $data = [ - "total" => 5, - "logs" => [ - [ - "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->users->listLogs( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } public function testMethodListMemberships(): void { $data = [ diff --git a/tests/Appwrite/Services/VectorsDBTest.php b/tests/Appwrite/Services/VectorsDBTest.php index fdb22e76..70fb88c4 100644 --- a/tests/Appwrite/Services/VectorsDBTest.php +++ b/tests/Appwrite/Services/VectorsDBTest.php @@ -81,6 +81,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -89,13 +93,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -950,16 +948,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -969,6 +963,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -982,7 +978,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1076,10 +1072,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, diff --git a/tests/Appwrite/TopicTest.php b/tests/Appwrite/TopicTest.php new file mode 100644 index 00000000..5eb0a3af --- /dev/null +++ b/tests/Appwrite/TopicTest.php @@ -0,0 +1,68 @@ +assertSame('user', (string) Topic::path(['user'])); + $this->assertSame('user/notification', (string) Topic::path(['user', 'notification'])); + $this->assertSame('user/notification', (string) Topic::path(['user'])->path(['notification'])); + } + + public function testAny(): void + { + $this->assertSame('user/+/notification', (string) Topic::path(['user'])->any()->path(['notification'])); + $this->assertSame('chat/+/+/message', (string) Topic::path(['chat'])->any()->any()->path(['message'])); + $this->assertSame('+/notification', (string) Topic::any()->path(['notification'])); + } + + public function testAll(): void + { + $this->assertSame('org/+/logs/#', (string) Topic::path(['org'])->any()->path(['logs'])->all()); + $this->assertSame('#', (string) Topic::all()); + } + + public function testNothingAfterAll(): void + { + $this->expectException(\BadMethodCallException::class); + Topic::all()->any(); + } + + /** + * @return \Iterator + */ + public static function invalidLevels(): \Iterator + { + yield 'not an array' => ['user']; + yield 'empty path' => [[]]; + yield 'not a string' => [['user', 42]]; + yield 'null' => [['user', null]]; + yield 'empty level' => [['user', '']]; + yield 'slash' => [['user/123']]; + yield 'plus' => [['user', '+']]; + yield 'contains plus' => [['user', 'a+b']]; + yield 'hash' => [['user', '#']]; + yield 'contains hash' => [['user', 'a#b']]; + } + + #[DataProvider('invalidLevels')] + public function testInvalidLevels(mixed $levels): void + { + $this->expectException(\InvalidArgumentException::class); + Topic::path($levels); + } + + #[DataProvider('invalidLevels')] + public function testInvalidLevelsWhenAppending(mixed $levels): void + { + $this->expectException(\InvalidArgumentException::class); + Topic::path(['user'])->path($levels); + } +} From ac7a24ec2fa80bb31c207798d176ba3e7b54e6b7 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 15 Oct 2026 11:09:57 +0100 Subject: [PATCH 3/4] feat: SDK update for the 2.5.x majors --- .gitignore | 1 + CHANGELOG.md | 22 + README.md | 33 +- composer.json | 1 + docs/account.md | 22 +- docs/apps.md | 2 +- docs/avatars.md | 4 +- docs/databases.md | 4 +- docs/documentsdb.md | 2 +- docs/examples/account/list-logs.md | 18 - docs/examples/avatars/get-screenshot.md | 3 +- docs/examples/databases/create-document.md | 2 +- docs/examples/databases/create-documents.md | 11 +- .../databases/create-enum-attribute.md | 5 +- docs/examples/databases/create-index.md | 4 +- .../databases/create-line-attribute.md | 15 +- docs/examples/databases/create-operations.md | 20 +- .../databases/create-point-attribute.md | 5 +- .../databases/create-polygon-attribute.md | 21 +- docs/examples/databases/delete-documents.md | 4 +- docs/examples/databases/update-document.md | 2 +- docs/examples/databases/update-documents.md | 2 +- .../databases/update-enum-attribute.md | 5 +- .../databases/update-line-attribute.md | 15 +- .../databases/update-point-attribute.md | 5 +- .../databases/update-polygon-attribute.md | 21 +- docs/examples/databases/upsert-document.md | 2 +- docs/examples/databases/upsert-documents.md | 11 +- docs/examples/documentsdb/create-document.md | 2 +- docs/examples/documentsdb/create-documents.md | 11 +- docs/examples/documentsdb/create-index.md | 4 +- .../examples/documentsdb/create-operations.md | 20 +- docs/examples/documentsdb/delete-documents.md | 4 +- docs/examples/documentsdb/upsert-documents.md | 11 +- .../embeddings/create-text-embeddings.md | 5 +- docs/examples/functions/create.md | 4 +- docs/examples/functions/update.md | 7 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- docs/examples/messaging/create-topic.md | 4 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/messaging/update-topic.md | 4 +- docs/examples/mongo/create-restoration.md | 5 +- .../promote-restoration.md} | 9 +- docs/examples/mysql/create-restoration.md | 5 +- .../promote-restoration.md} | 9 +- docs/examples/oauth2/approve.md | 4 +- docs/examples/oauth2/authorize-post.md | 6 +- docs/examples/oauth2/authorize.md | 6 +- .../oauth2/create-device-authorization.md | 6 +- docs/examples/oauth2/create-grant.md | 4 +- docs/examples/oauth2/create-par.md | 6 +- docs/examples/oauth2/create-token.md | 6 +- docs/examples/oauth2/get-grant.md | 4 +- docs/examples/oauth2/list-organizations.md | 4 +- docs/examples/oauth2/list-projects.md | 4 +- docs/examples/oauth2/reject.md | 4 +- docs/examples/oauth2/revoke.md | 4 +- docs/examples/organization/create-key.md | 21 - docs/examples/organization/update-key.md | 21 - .../examples/postgresql/create-restoration.md | 5 +- .../promote-restoration.md} | 11 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 4 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 4 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- .../create-smtp-rule.md} | 11 +- docs/examples/tablesdb/create-enum-column.md | 5 +- docs/examples/tablesdb/create-index.md | 4 +- docs/examples/tablesdb/create-line-column.md | 15 +- docs/examples/tablesdb/create-operations.md | 20 +- docs/examples/tablesdb/create-point-column.md | 5 +- .../tablesdb/create-polygon-column.md | 21 +- docs/examples/tablesdb/create-row.md | 2 +- docs/examples/tablesdb/create-rows.md | 11 +- docs/examples/tablesdb/delete-rows.md | 4 +- docs/examples/tablesdb/update-enum-column.md | 5 +- docs/examples/tablesdb/update-line-column.md | 15 +- docs/examples/tablesdb/update-point-column.md | 5 +- .../tablesdb/update-polygon-column.md | 21 +- docs/examples/tablesdb/update-row.md | 2 +- docs/examples/tablesdb/update-rows.md | 2 +- docs/examples/tablesdb/upsert-row.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 11 +- docs/examples/teams/create-membership.md | 4 +- docs/examples/teams/update-membership.md | 4 +- docs/examples/users/update-labels.md | 4 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-document.md | 8 +- docs/examples/vectorsdb/create-documents.md | 15 +- docs/examples/vectorsdb/create-index.md | 4 +- docs/examples/vectorsdb/create-operations.md | 28 +- docs/examples/vectorsdb/delete-documents.md | 4 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 15 +- docs/examples/webhooks/create.md | 4 +- docs/examples/webhooks/update.md | 4 +- docs/functions.md | 1 + docs/messaging.md | 14 +- docs/mongo.md | 32 +- docs/mysql.md | 38 +- docs/oauth2.md | 10 +- docs/organization.md | 74 +- docs/postgresql.md | 38 +- docs/project.md | 12 +- docs/proxy.md | 21 +- docs/storage.md | 2 +- docs/tablesdb.md | 46 +- docs/teams.md | 2 +- docs/users.md | 19 +- docs/vectorsdb.md | 2 +- docs/webhooks.md | 8 +- src/Appwrite/Client.php | 75 +- src/Appwrite/Enums/BillingPlanGroup.php | 8 - src/Appwrite/Enums/ExecutionTrigger.php | 8 + src/Appwrite/Enums/OrganizationKeyScopes.php | 162 ---- src/Appwrite/Enums/ProxyRuleProtocol.php | 50 ++ src/Appwrite/Models/ActivityEventList.php | 5 +- src/Appwrite/Models/App.php | 5 +- src/Appwrite/Models/AppInstallationList.php | 5 +- src/Appwrite/Models/AppKeyList.php | 5 +- src/Appwrite/Models/AppScopeList.php | 5 +- src/Appwrite/Models/AppSecretList.php | 5 +- src/Appwrite/Models/AppsList.php | 5 +- src/Appwrite/Models/AttributeEnum.php | 4 +- src/Appwrite/Models/AttributeList.php | 5 +- src/Appwrite/Models/BackupArchive.php | 27 +- src/Appwrite/Models/BackupArchiveList.php | 5 +- src/Appwrite/Models/BackupPolicy.php | 9 +- src/Appwrite/Models/BackupPolicyList.php | 5 +- src/Appwrite/Models/BackupRestoration.php | 24 +- src/Appwrite/Models/BackupRestorationList.php | 5 +- src/Appwrite/Models/BillingPlan.php | 16 +- src/Appwrite/Models/Block.php | 42 +- src/Appwrite/Models/BucketList.php | 5 +- src/Appwrite/Models/Collection.php | 13 +- src/Appwrite/Models/CollectionList.php | 5 +- src/Appwrite/Models/ColumnEnum.php | 4 +- src/Appwrite/Models/ColumnIndexList.php | 5 +- src/Appwrite/Models/ColumnList.php | 5 +- src/Appwrite/Models/ContinentList.php | 5 +- src/Appwrite/Models/CountryList.php | 5 +- src/Appwrite/Models/CurrencyList.php | 5 +- src/Appwrite/Models/Database.php | 2 +- src/Appwrite/Models/DatabaseList.php | 5 +- src/Appwrite/Models/DatabaseMigrationList.php | 5 +- src/Appwrite/Models/DatabaseStatus.php | 18 +- src/Appwrite/Models/DedicatedDatabase.php | 55 +- .../Models/DedicatedDatabaseBackupList.php | 5 +- .../Models/DedicatedDatabaseBranch.php | 14 +- .../Models/DedicatedDatabaseBranchList.php | 5 +- .../Models/DedicatedDatabaseExecution.php | 5 +- .../Models/DedicatedDatabaseExtensions.php | 5 +- src/Appwrite/Models/DedicatedDatabaseList.php | 5 +- .../Models/DedicatedDatabaseOperationList.php | 5 +- .../Models/DedicatedDatabaseReplicas.php | 5 +- .../Models/DedicatedDatabaseRestoration.php | 55 +- .../DedicatedDatabaseRestorationList.php | 5 +- .../Models/DedicatedDatabaseSpecification.php | 32 +- .../DedicatedDatabaseSpecificationList.php | 18 +- .../DedicatedDatabaseSpecificationPricing.php | 70 -- src/Appwrite/Models/DeploymentList.php | 5 +- src/Appwrite/Models/DevKey.php | 98 --- src/Appwrite/Models/Document.php | 5 +- src/Appwrite/Models/DocumentList.php | 5 +- src/Appwrite/Models/EmailTemplateList.php | 5 +- src/Appwrite/Models/EmbeddingList.php | 5 +- src/Appwrite/Models/EphemeralKey.php | 5 +- src/Appwrite/Models/Execution.php | 16 +- src/Appwrite/Models/ExecutionList.php | 5 +- src/Appwrite/Models/FileList.php | 5 +- src/Appwrite/Models/Framework.php | 9 +- src/Appwrite/Models/FrameworkList.php | 5 +- src/Appwrite/Models/FunctionList.php | 5 +- src/Appwrite/Models/FunctionModel.php | 15 +- src/Appwrite/Models/Identity.php | 7 +- src/Appwrite/Models/IdentityList.php | 5 +- src/Appwrite/Models/IndexList.php | 5 +- src/Appwrite/Models/Insight.php | 5 +- src/Appwrite/Models/InsightList.php | 5 +- src/Appwrite/Models/Key.php | 5 +- src/Appwrite/Models/KeyList.php | 5 +- src/Appwrite/Models/LanguageList.php | 5 +- src/Appwrite/Models/LocaleCodeList.php | 5 +- src/Appwrite/Models/Log.php | 196 ----- src/Appwrite/Models/LogList.php | 61 -- src/Appwrite/Models/MembershipList.php | 5 +- src/Appwrite/Models/Message.php | 13 +- src/Appwrite/Models/MessageList.php | 5 +- src/Appwrite/Models/MockNumberList.php | 5 +- src/Appwrite/Models/OAuth2Apple.php | 14 +- src/Appwrite/Models/OAuth2Auth0.php | 23 +- src/Appwrite/Models/OAuth2Discord.php | 19 +- src/Appwrite/Models/OAuth2Github.php | 19 +- src/Appwrite/Models/OAuth2Google.php | 16 +- src/Appwrite/Models/OAuth2Kakao.php | 2 +- src/Appwrite/Models/OAuth2Microsoft.php | 23 +- src/Appwrite/Models/OAuth2Oidc.php | 18 +- src/Appwrite/Models/OAuth2Okta.php | 25 +- src/Appwrite/Models/OAuth2ProviderList.php | 5 +- src/Appwrite/Models/OAuth2Salesforce.php | 19 +- src/Appwrite/Models/OAuth2Zoho.php | 19 +- src/Appwrite/Models/Oauth2ConsentList.php | 5 +- .../Models/Oauth2ConsentTokenList.php | 5 +- .../Models/Oauth2OrganizationList.php | 5 +- src/Appwrite/Models/Oauth2ProjectList.php | 5 +- src/Appwrite/Models/Organization.php | 63 +- src/Appwrite/Models/Passkey.php | 22 +- src/Appwrite/Models/PasskeyChallenge.php | 22 +- src/Appwrite/Models/PasskeyList.php | 10 +- src/Appwrite/Models/PhoneList.php | 5 +- src/Appwrite/Models/PlatformAndroid.php | 7 +- src/Appwrite/Models/PlatformList.php | 5 +- src/Appwrite/Models/PolicyList.php | 5 +- src/Appwrite/Models/PolicyPasskey.php | 14 +- src/Appwrite/Models/Presence.php | 5 +- src/Appwrite/Models/PresenceList.php | 5 +- src/Appwrite/Models/Project.php | 29 +- src/Appwrite/Models/ProjectList.php | 5 +- src/Appwrite/Models/ProviderList.php | 5 +- src/Appwrite/Models/ProxyRule.php | 10 +- src/Appwrite/Models/ProxyRuleList.php | 5 +- src/Appwrite/Models/Report.php | 5 +- src/Appwrite/Models/ReportList.php | 5 +- src/Appwrite/Models/ResourceTokenList.php | 5 +- src/Appwrite/Models/Row.php | 5 +- src/Appwrite/Models/RowList.php | 5 +- src/Appwrite/Models/Runtime.php | 5 +- src/Appwrite/Models/RuntimeList.php | 5 +- src/Appwrite/Models/SessionList.php | 5 +- src/Appwrite/Models/Site.php | 4 +- src/Appwrite/Models/SiteList.php | 5 +- src/Appwrite/Models/SpecificationList.php | 5 +- src/Appwrite/Models/SubscriberList.php | 5 +- src/Appwrite/Models/Table.php | 13 +- src/Appwrite/Models/TableList.php | 5 +- src/Appwrite/Models/TargetList.php | 5 +- src/Appwrite/Models/TeamList.php | 5 +- src/Appwrite/Models/TokenSecret.php | 26 +- src/Appwrite/Models/Topic.php | 2 +- src/Appwrite/Models/TopicList.php | 5 +- src/Appwrite/Models/TransactionList.php | 5 +- src/Appwrite/Models/UsageBillingPlan.php | 72 +- src/Appwrite/Models/User.php | 4 +- src/Appwrite/Models/UserList.php | 5 +- src/Appwrite/Models/VariableList.php | 5 +- src/Appwrite/Models/VectorsdbCollection.php | 13 +- .../Models/VectorsdbCollectionList.php | 5 +- src/Appwrite/Models/Webhook.php | 2 +- src/Appwrite/Models/WebhookList.php | 5 +- src/Appwrite/Query.php | 367 ++++++-- src/Appwrite/Query/Builder.php | 558 ++++++++++++ src/Appwrite/Services/Account.php | 100 ++- src/Appwrite/Services/Activities.php | 4 + src/Appwrite/Services/Advisor.php | 21 + src/Appwrite/Services/Apps.php | 100 +++ src/Appwrite/Services/Avatars.php | 6 +- src/Appwrite/Services/Backups.php | 24 + src/Appwrite/Services/Databases.php | 664 +++++++++++++- src/Appwrite/Services/DocumentsDB.php | 253 +++++- src/Appwrite/Services/Functions.php | 134 ++- src/Appwrite/Services/Messaging.php | 125 ++- src/Appwrite/Services/Mongo.php | 217 ++++- src/Appwrite/Services/Mysql.php | 233 ++++- src/Appwrite/Services/Oauth2.php | 14 +- src/Appwrite/Services/Organization.php | 222 +---- src/Appwrite/Services/Postgresql.php | 249 +++++- src/Appwrite/Services/Presences.php | 17 + src/Appwrite/Services/Project.php | 77 +- src/Appwrite/Services/Proxy.php | 56 ++ src/Appwrite/Services/Sites.php | 131 ++- src/Appwrite/Services/Storage.php | 88 +- src/Appwrite/Services/TablesDB.php | 812 ++++++++++++++++-- src/Appwrite/Services/Teams.php | 94 ++ src/Appwrite/Services/Tokens.php | 29 + src/Appwrite/Services/Users.php | 210 ++++- src/Appwrite/Services/VectorsDB.php | 234 ++++- src/Appwrite/Services/Webhooks.php | 22 +- src/Appwrite/Topic.php | 115 +++ tests/Appwrite/ClientTest.php | 159 +++- tests/Appwrite/QueryTest.php | 285 +++++- tests/Appwrite/Services/AccountTest.php | 46 +- tests/Appwrite/Services/BackupsTest.php | 17 +- tests/Appwrite/Services/DocumentsDBTest.php | 24 +- tests/Appwrite/Services/FunctionsTest.php | 6 +- tests/Appwrite/Services/MongoTest.php | 144 ++-- tests/Appwrite/Services/MysqlTest.php | 144 ++-- tests/Appwrite/Services/Oauth2Test.php | 4 +- tests/Appwrite/Services/OrganizationTest.php | 361 +------- tests/Appwrite/Services/PostgresqlTest.php | 160 ++-- tests/Appwrite/Services/ProjectTest.php | 499 ++--------- tests/Appwrite/Services/ProxyTest.php | 55 +- tests/Appwrite/Services/SitesTest.php | 4 +- tests/Appwrite/Services/TablesDBTest.php | 90 +- tests/Appwrite/Services/UsersTest.php | 48 +- tests/Appwrite/Services/VectorsDBTest.php | 24 +- tests/Appwrite/TopicTest.php | 50 ++ 298 files changed, 6783 insertions(+), 3640 deletions(-) delete mode 100644 docs/examples/account/list-logs.md rename docs/examples/{organization/delete-key.md => mongo/promote-restoration.md} (61%) rename docs/examples/{organization/get-key.md => mysql/promote-restoration.md} (61%) delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/update-key.md rename docs/examples/{users/list-logs.md => postgresql/promote-restoration.md} (58%) rename docs/examples/{organization/list-keys.md => proxy/create-smtp-rule.md} (58%) delete mode 100644 src/Appwrite/Enums/OrganizationKeyScopes.php create mode 100644 src/Appwrite/Enums/ProxyRuleProtocol.php delete mode 100644 src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php delete mode 100644 src/Appwrite/Models/DevKey.php delete mode 100644 src/Appwrite/Models/Log.php delete mode 100644 src/Appwrite/Models/LogList.php create mode 100644 src/Appwrite/Query/Builder.php create mode 100644 src/Appwrite/Topic.php create mode 100644 tests/Appwrite/TopicTest.php diff --git a/.gitignore b/.gitignore index d1502b08..d0757eb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor/ composer.lock +.phpunit.cache/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 7353dbb9..89bd3f0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Change Log +## 31.0.0 + +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `Account::listLogs`, `Users::listLogs` and the `Log`/`LogList` models +* Breaking: removed `Organization::createKey`, `getKey`, `listKeys`, `updateKey` and `deleteKey`, and `OrganizationKeyScopes`; use `Organization::listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` instead +* Breaking: removed `Client::setDevKey`, the `DevKey` model and `Project::$devKeys` +* Breaking: removed `BillingPlanGroup::STARTER()`; use `BillingPlanGroup::FREE()` +* Breaking: `listSpecifications` returns each specification's prices and overage rates on the row itself. Removed the list-level `$pricing` field and the `DedicatedDatabaseSpecificationPricing` model +* Breaking: removed `Block` fields `reason`, `projectName`, `region`, `organizationName`, `organizationId` and `billingPlan` +* Breaking: OAuth2 `resource` params now take `?array` +* Breaking: `Project::updateOAuth2Kakao` takes `$enabled` before `$prompt` +* Breaking: `BackupRestoration::$options` is now an array +* Breaking: some response fields became nullable, such as `BillingPlan::$usage` and `DedicatedDatabase::$engine` +* Breaking: the protected `Client::flatten` is renamed `flattenForm`; subclasses that override it must rename it +* Added: `Topic` helper to build MQTT topics for push messages +* Added: `Mongo`, `Mysql` and `Postgresql` `promoteRestoration`, `$restoreMode`, `$targetName` and `$autoPromote` on `createRestoration`, and `DedicatedDatabaseRestoration::$restoreMode` +* Added: `Proxy::createSMTPRule`, the `ProxyRuleProtocol` enum and `ProxyRule::$protocol` +* Added: `$emailEnabled` on `Functions::update` and `FunctionModel`, and `ExecutionTrigger::EMAIL()` +* Added: `Query` aggregates (`count`, `countDistinct`, `sum`, `avg`, `min`, `max` and more), `groupBy`, `having`, `distinct`, joins, `relationship`, `covers`, `spatialEquals` and `page` +* Added: `Query::builder()` to chain queries; `build()` returns the query list +* Fixed: OAuth2 models wrap a single `prompt` value in a list + ## 30.4.0 * Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones diff --git a/README.md b/README.md index bd76997b..abc2f231 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square&v=1) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 1.9.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-php/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-php/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -22,6 +22,33 @@ composer require appwrite/appwrite Requires PHP 8.5 or later. +### Custom HTTP transport + +For applications that configure their own HTTP transport, pass any PSR-18 client to the constructor. Hosts that run SDK calls concurrently, such as Swoole coroutines, should pass a pooled client so no cURL handle is shared between coroutines: + +```php +use Appwrite\Client; +use Utopia\Client\Adapter\SwooleCoroutine\Client as SwooleAdapter; +use Utopia\Client\Client as HttpClient; +use Utopia\Client\Pool as PooledClient; +use Utopia\Pools\Adapter\Swoole as SwoolePool; +use Utopia\Pools\Pool; + +$client = new Client(new PooledClient(new Pool( + new SwoolePool(), + 'appwrite', + 128, + fn (): HttpClient => new HttpClient(new SwooleAdapter()) + ->withConnectionReuse() + ->withTimeout(5) + ->withConnectTimeout(2), + timeout: 3.0, +))); +$client->setEndpoint('https://cloud.appwrite.io/v1'); +``` + +Configure timeouts, TLS, redirects, and connection reuse on the injected transport. The SDK's `setTimeout()`, `setConnectTimeout()`, and `setSelfSigned()` methods only configure the default cURL transport. Endpoint, authentication, headers, request encoding, and response handling remain the SDK's responsibility. A transport used with `responseType: 'location'` must have redirect following disabled. + ## Getting Started @@ -76,7 +103,7 @@ $users = new Users($client); try { $user = $users->create(ID::unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); } catch(AppwriteException $error) { - echo $error->message; + echo $error->getMessage(); } ``` diff --git a/composer.json b/composer.json index 21faff5f..135f6928 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "php": ">=8.5", "ext-curl": "*", "ext-json": "*", + "psr/http-client": "^1.0", "utopia-php/client": "^0.6", "adhocore/jwt": "^1.1" }, diff --git a/docs/account.md b/docs/account.md index 80e592a5..efbee573 100644 --- a/docs/account.md +++ b/docs/account.md @@ -150,20 +150,6 @@ DELETE https://cloud.appwrite.io/v1/account/identities/{identityId} | identityId | string | **Required** Identity ID. | | -```http request -GET https://cloud.appwrite.io/v1/account/logs -``` - -** Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. ** - -### 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). 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 PATCH https://cloud.appwrite.io/v1/account/mfa ``` @@ -591,7 +577,7 @@ GET https://cloud.appwrite.io/v1/account/sessions DELETE https://cloud.appwrite.io/v1/account/sessions ``` -** Delete all sessions from the user account and remove any sessions cookies from the end client. ** +** Delete all sessions from the user account and remove any sessions cookies from the end client. Pass `current` as false to keep the session making the request and sign out of every other session. ** ### Parameters @@ -611,7 +597,7 @@ POST https://cloud.appwrite.io/v1/account/sessions/anonymous POST https://cloud.appwrite.io/v1/account/sessions/email ``` -** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. +** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. Use the optional `duration` parameter to create a shorter session, for example when the user doesn't choose "remember me". It must be at least 60 seconds and cannot exceed the project maximum session length. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). ** @@ -786,13 +772,15 @@ GET https://cloud.appwrite.io/v1/account/tokens/oauth2/{provider} If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. +If there is already an active session, the OAuth2 identity is attached to the logged-in account and that session stays active until the token is exchanged for a new one. + A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). ** ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| provider | string | **Required** OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, 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, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, 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/apps.md b/docs/apps.md index fde01429..60c5d7f5 100644 --- a/docs/apps.md +++ b/docs/apps.md @@ -242,7 +242,7 @@ PUT https://cloud.appwrite.io/v1/apps/{appId}/labels | Field Name | Type | Description | Default | | --- | --- | --- | --- | | appId | string | **Required** Application unique ID. | | -| labels | array | Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | | +| labels | array | Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. Reserved labels are rejected. | | ```http request diff --git a/docs/avatars.md b/docs/avatars.md index 7b9377d2..d5713014 100644 --- a/docs/avatars.md +++ b/docs/avatars.md @@ -116,7 +116,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre GET https://cloud.appwrite.io/v1/avatars/photo ``` -** Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. +** Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: a custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. Passing `userId` — `current()` for the authenticated user — resolves the photo from everything known about that user: identity photos, email, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. ** @@ -186,7 +186,7 @@ When width and height are specified, the image is resized accordingly. If both d | Field Name | Type | Description | Default | | --- | --- | --- | --- | | url | string | **Required** Website URL which you want to capture. | | -| headers | object | HTTP headers to send with the browser request. Defaults to empty. | {} | +| headers | object | HTTP headers to send with the browser request. Only Accept and Accept-Language are allowed. Defaults to empty. | {} | | viewportWidth | integer | Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. | 1280 | | viewportHeight | integer | Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. | 720 | | scale | number | Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. | 1 | diff --git a/docs/databases.md b/docs/databases.md index 1b1f7bf6..042e19e4 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -188,7 +188,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections | documentSecurity | boolean | Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. | 1 | | attributes | array | Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. | [] | -| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | +| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | ```http request @@ -1210,7 +1210,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection ``` ** Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. -Attributes can be `key`, `fulltext`, and `unique`. ** +Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use an index. ** ### Parameters diff --git a/docs/documentsdb.md b/docs/documentsdb.md index 4f650b12..24756cc1 100644 --- a/docs/documentsdb.md +++ b/docs/documentsdb.md @@ -38,7 +38,7 @@ POST https://cloud.appwrite.io/v1/documentsdb GET https://cloud.appwrite.io/v1/documentsdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 17e51352..00000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,18 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with - -$account = new Account($client); - -$result = $account->listLogs( - queries: [], // optional - total: false // optional -); -``` diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 59fbd663..a5eb5e99 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -18,8 +18,7 @@ $avatars = new Avatars($client); $result = $avatars->getScreenshot( url: 'https://example.com', headers: [ - 'Authorization' => 'Bearer token123', - 'X-Custom-Header' => 'value' + 'Accept-Language' => 'en-US,en;q=0.9' ], // optional viewportWidth: 1920, // optional viewportHeight: 1080, // optional diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index efd3083f..bcd3575f 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -20,7 +20,7 @@ $result = $databases->createDocument( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 30, 'isAdmin' => false ], diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 1f64387b..e858ed67 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -14,7 +14,16 @@ $databases = new Databases($client); $result = $databases->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index 962b5a79..79d22785 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -15,7 +15,10 @@ $result = $databases->createEnumAttribute( databaseId: '', collectionId: '', key: '', - elements: ["active", "inactive"], + elements: [ + 'active', + 'inactive' + ], required: false, default: 'active', // optional array: false // optional diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 1005239e..43e6f00c 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -18,7 +18,9 @@ $result = $databases->createIndex( collectionId: '', key: '', type: DatabasesIndexType::KEY(), - attributes: [], + attributes: [ + 'username' + ], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index c892610a..218cb9aa 100644 --- a/docs/examples/databases/create-line-attribute.md +++ b/docs/examples/databases/create-line-attribute.md @@ -16,6 +16,19 @@ $result = $databases->createLineAttribute( collectionId: '', key: '', required: false, - default: [[1, 2], [3, 4], [5, 6]] // optional + default: [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ] // optional ); ``` diff --git a/docs/examples/databases/create-operations.md b/docs/examples/databases/create-operations.md index 82172a3f..f3b86d27 100644 --- a/docs/examples/databases/create-operations.md +++ b/docs/examples/databases/create-operations.md @@ -14,15 +14,15 @@ $databases = new Databases($client); $result = $databases->createOperations( transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + [ + 'action' => 'create', + 'databaseId' => '', + 'collectionId' => '', + 'documentId' => '', + 'data' => [ + 'name' => 'Walter O\'Brien' + ] + ] + ] // optional ); ``` diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md index 38541545..8512000a 100644 --- a/docs/examples/databases/create-point-attribute.md +++ b/docs/examples/databases/create-point-attribute.md @@ -16,6 +16,9 @@ $result = $databases->createPointAttribute( collectionId: '', key: '', required: false, - default: [1, 2] // optional + default: [ + 1, + 2 + ] // optional ); ``` diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md index 5a37c353..a2d99b17 100644 --- a/docs/examples/databases/create-polygon-attribute.md +++ b/docs/examples/databases/create-polygon-attribute.md @@ -16,6 +16,25 @@ $result = $databases->createPolygonAttribute( collectionId: '', key: '', required: false, - default: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional + default: [ + [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ] + ] // optional ); ``` diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index f39cbfe0..5e8a0f94 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -14,7 +14,9 @@ $databases = new Databases($client); $result = $databases->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}' + ], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 1f3b6359..9eecd2e6 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -20,7 +20,7 @@ $result = $databases->updateDocument( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 33, 'isAdmin' => false ], // optional diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 68c12217..aeaa43e2 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -17,7 +17,7 @@ $result = $databases->updateDocuments( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 33, 'isAdmin' => false ], // optional diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index 8a736beb..7b66ddf4 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -15,7 +15,10 @@ $result = $databases->updateEnumAttribute( databaseId: '', collectionId: '', key: '', - elements: ["active", "inactive"], + elements: [ + 'active', + 'inactive' + ], required: false, default: 'active', newKey: '' // optional diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md index a18dbb71..c8e30f7a 100644 --- a/docs/examples/databases/update-line-attribute.md +++ b/docs/examples/databases/update-line-attribute.md @@ -16,7 +16,20 @@ $result = $databases->updateLineAttribute( collectionId: '', key: '', required: false, - default: [[1, 2], [3, 4], [5, 6]], // optional + default: [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md index 54577171..febd27d9 100644 --- a/docs/examples/databases/update-point-attribute.md +++ b/docs/examples/databases/update-point-attribute.md @@ -16,7 +16,10 @@ $result = $databases->updatePointAttribute( collectionId: '', key: '', required: false, - default: [1, 2], // optional + default: [ + 1, + 2 + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md index 448b4ef9..2dd7dbe4 100644 --- a/docs/examples/databases/update-polygon-attribute.md +++ b/docs/examples/databases/update-polygon-attribute.md @@ -16,7 +16,26 @@ $result = $databases->updatePolygonAttribute( collectionId: '', key: '', required: false, - default: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional + default: [ + [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ] + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 94aad582..96da643f 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -20,7 +20,7 @@ $result = $databases->upsertDocument( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 30, 'isAdmin' => false ], // optional diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 0049fdc6..22bb46b0 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -14,7 +14,16 @@ $databases = new Databases($client); $result = $databases->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md index 4b894f41..66de5839 100644 --- a/docs/examples/documentsdb/create-document.md +++ b/docs/examples/documentsdb/create-document.md @@ -20,7 +20,7 @@ $result = $documentsDB->createDocument( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 30, 'isAdmin' => false ], diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index ec6a4355..76ba2d3d 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -14,7 +14,16 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index b64d1f8a..a84d75cf 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -18,7 +18,9 @@ $result = $documentsDB->createIndex( collectionId: '', key: '', type: DocumentsDBIndexType::KEY(), - attributes: [], + attributes: [ + 'username' + ], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md index 83d3bab2..e4038701 100644 --- a/docs/examples/documentsdb/create-operations.md +++ b/docs/examples/documentsdb/create-operations.md @@ -14,15 +14,15 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->createOperations( transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + [ + 'action' => 'create', + 'databaseId' => '', + 'collectionId' => '', + 'documentId' => '', + 'data' => [ + 'name' => 'Walter O\'Brien' + ] + ] + ] // optional ); ``` diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index b77b3756..1932e627 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -14,7 +14,9 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}' + ], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index 09021e0a..43dcf351 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -14,7 +14,16 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 70f0f7e1..f1c289bf 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -13,7 +13,10 @@ $client = (new Client()) $embeddings = new Embeddings($client); $result = $embeddings->createTextEmbeddings( - texts: [], + texts: [ + 'Appwrite helps developers build applications.', + 'Find documents with semantic search.' + ], model: EmbeddingModel::NOMICEMBEDTEXT() // optional ); ``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 1f09b2fb..593af4a0 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -17,7 +17,9 @@ $result = $functions->create( functionId: '', name: '', runtime: Runtime::NODE145(), - execute: ["any"], // optional + execute: [ + 'any' + ], // optional events: [], // optional schedule: '0 0 * * *', // optional timeout: 1, // optional diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index d4863701..723692eb 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -17,7 +17,9 @@ $result = $functions->update( functionId: '', name: '', runtime: Runtime::NODE145(), // optional - execute: ["any"], // optional + execute: [ + 'any' + ], // optional events: [], // optional schedule: '0 0 * * *', // optional timeout: 1, // optional @@ -36,6 +38,7 @@ $result = $functions->update( buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional - interval: 0 // optional + interval: 0, // optional + emailEnabled: false // optional ); ``` diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index c2f1b989..26792681 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -12,6 +12,8 @@ $client = (new Client()) $graphql = new Graphql($client); $result = $graphql->mutation( - query: [] + query: [ + 'query' => 'mutation { accountUpdateName(name: "Walter") { name } }' + ] ); ``` diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 9731e998..f5e562c1 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -12,6 +12,8 @@ $client = (new Client()) $graphql = new Graphql($client); $result = $graphql->query( - query: [] + query: [ + 'query' => 'query { localeGet { ip } }' + ] ); ``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index ffb578bb..4fc8933d 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -14,7 +14,9 @@ $messaging = new Messaging($client); $result = $messaging->createTopic( topicId: '', name: '', - subscribe: ["any"], // optional + subscribe: [ + 'any' + ], // optional qos: 0, // optional expiry: 0 // optional ); diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 568d28d9..4f96e8ac 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -14,7 +14,7 @@ $messaging = new Messaging($client); $result = $messaging->createTwilioProvider( providerId: '', name: '', - from: '+12065550100', // optional + from: '', // optional accountSid: '', // optional authToken: '', // optional enabled: false // optional diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index 6016049c..607785c3 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -14,7 +14,9 @@ $messaging = new Messaging($client); $result = $messaging->updateTopic( topicId: '', name: '', // optional - subscribe: ["any"], // optional + subscribe: [ + 'any' + ], // optional qos: 0, // optional expiry: 0 // optional ); diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index e16d2e31..ababb372 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -16,6 +16,9 @@ $result = $mongo->createRestoration( type: 'backup', // optional backupId: '', // optional targetDatabaseId: '', // optional - targetTime: '2020-10-15T06:38:00.000+00:00' // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '', // optional + autoPromote: false // optional ); ``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/mongo/promote-restoration.md similarity index 61% rename from docs/examples/organization/delete-key.md rename to docs/examples/mongo/promote-restoration.md index ca72f3dd..6532c647 100644 --- a/docs/examples/organization/delete-key.md +++ b/docs/examples/mongo/promote-restoration.md @@ -2,16 +2,17 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$organization = new Organization($client); +$mongo = new Mongo($client); -$result = $organization->deleteKey( - keyId: '' +$result = $mongo->promoteRestoration( + databaseId: '', + restorationId: '' ); ``` diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index b906838c..21c59a8b 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -16,6 +16,9 @@ $result = $mysql->createRestoration( type: 'backup', // optional backupId: '', // optional targetDatabaseId: '', // optional - targetTime: '2020-10-15T06:38:00.000+00:00' // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '', // optional + autoPromote: false // optional ); ``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/mysql/promote-restoration.md similarity index 61% rename from docs/examples/organization/get-key.md rename to docs/examples/mysql/promote-restoration.md index bf651e9e..887ed4b9 100644 --- a/docs/examples/organization/get-key.md +++ b/docs/examples/mysql/promote-restoration.md @@ -2,16 +2,17 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$organization = new Organization($client); +$mysql = new Mysql($client); -$result = $organization->getKey( - keyId: '' +$result = $mysql->promoteRestoration( + databaseId: '', + restorationId: '' ); ``` diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 5540b110..2a9f07aa 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index d7a465ad..a99f3604 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->authorizePost( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '' // optional ); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index ad373715..3765b5a3 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->authorize( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '' // optional ); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index 00358d8a..6385a1a1 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -15,7 +15,7 @@ $result = $oauth2->createDeviceAuthorization( clientId: '', // optional scope: '', // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 95467652..a0328e69 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index ddb3d7d6..9c57b1df 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->createPAR( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index a4be2d6f..8ec9d22f 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -20,7 +20,7 @@ $result = $oauth2->createToken( clientSecret: '', // optional codeVerifier: '', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index a6469c30..d83efe8f 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index 49c1f499..7237c3f8 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 3bbcf901..9abc1548 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index bd98d721..0cc9cf7f 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 7122ed7f..1e823003 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index c7cb7dde..00000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,21 +0,0 @@ -```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->createKey( - keyId: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTSREAD()], - expire: '2020-10-15T06:38:00.000+00:00' // optional -); -``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index 575e6119..00000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,21 +0,0 @@ -```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->updateKey( - keyId: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTSREAD()], - expire: '2020-10-15T06:38:00.000+00:00' // optional -); -``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index f94c6972..d5de4e01 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -16,6 +16,9 @@ $result = $postgresql->createRestoration( type: 'backup', // optional backupId: '', // optional targetDatabaseId: '', // optional - targetTime: '2020-10-15T06:38:00.000+00:00' // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '', // optional + autoPromote: false // optional ); ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/postgresql/promote-restoration.md similarity index 58% rename from docs/examples/users/list-logs.md rename to docs/examples/postgresql/promote-restoration.md index b050bab0..dc1fc49d 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/postgresql/promote-restoration.md @@ -2,18 +2,17 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$users = new Users($client); +$postgresql = new Postgresql($client); -$result = $users->listLogs( - userId: '', - queries: [], // optional - total: false // optional +$result = $postgresql->promoteRestoration( + databaseId: '', + restorationId: '' ); ``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 224dc841..763800e6 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -13,7 +13,7 @@ $client = (new Client()) $project = new Project($client); $result = $project->createEphemeralKey( - scopes: [ProjectKeyScopes::PROJECTREAD()], + scopes: [ProjectKeyScopes::USERSREAD()], duration: 600 ); ``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index a16026a8..be2a588b 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -12,6 +12,8 @@ $client = (new Client()) $project = new Project($client); $result = $project->createSMTPTest( - emails: [] + emails: [ + 'recipient@example.com' + ] ); ``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index db883945..ae2996b7 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -15,7 +15,7 @@ $project = new Project($client); $result = $project->updateKey( keyId: '', name: '', - scopes: [ProjectKeyScopes::PROJECTREAD()], + scopes: [ProjectKeyScopes::USERSREAD()], expire: '2020-10-15T06:38:00.000+00:00' // optional ); ``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index aace3165..e94b8406 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -12,6 +12,8 @@ $client = (new Client()) $project = new Project($client); $result = $project->updateLabels( - labels: [] + labels: [ + 'production' + ] ); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index 78fe1cbd..7f88288e 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -15,7 +15,7 @@ $project = new Project($client); $result = $project->updateOAuth2Kakao( clientId: '', // optional clientSecret: '', // optional - prompt: [ProjectOAuth2KakaoPrompt::NONE()], // optional - enabled: false // optional + enabled: false, // optional + prompt: [ProjectOAuth2KakaoPrompt::NONE()] // optional ); ``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/proxy/create-smtp-rule.md similarity index 58% rename from docs/examples/organization/list-keys.md rename to docs/examples/proxy/create-smtp-rule.md index dbe27502..ecffbf19 100644 --- a/docs/examples/organization/list-keys.md +++ b/docs/examples/proxy/create-smtp-rule.md @@ -2,17 +2,18 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$organization = new Organization($client); +$proxy = new Proxy($client); -$result = $organization->listKeys( - queries: [], // optional - total: false // optional +$result = $proxy->createSMTPRule( + domain: 'example.com', + functionId: '', + branch: '' // optional ); ``` diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md index c9e3f5fb..ba0f5ec0 100644 --- a/docs/examples/tablesdb/create-enum-column.md +++ b/docs/examples/tablesdb/create-enum-column.md @@ -15,7 +15,10 @@ $result = $tablesDB->createEnumColumn( databaseId: '', tableId: '', key: '', - elements: ["active", "inactive"], + elements: [ + 'active', + 'inactive' + ], required: false, default: 'active', // optional array: false // optional diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 2b840eb3..29327378 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -18,7 +18,9 @@ $result = $tablesDB->createIndex( tableId: '', key: '', type: TablesDBIndexType::KEY(), - columns: [], + columns: [ + 'username' + ], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md index 4d220468..d3ed71e8 100644 --- a/docs/examples/tablesdb/create-line-column.md +++ b/docs/examples/tablesdb/create-line-column.md @@ -16,6 +16,19 @@ $result = $tablesDB->createLineColumn( tableId: '', key: '', required: false, - default: [[1, 2], [3, 4], [5, 6]] // optional + default: [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ] // optional ); ``` diff --git a/docs/examples/tablesdb/create-operations.md b/docs/examples/tablesdb/create-operations.md index e60cf34e..f18a6c45 100644 --- a/docs/examples/tablesdb/create-operations.md +++ b/docs/examples/tablesdb/create-operations.md @@ -14,15 +14,15 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->createOperations( transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "tableId": "", - "rowId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + [ + 'action' => 'create', + 'databaseId' => '', + 'tableId' => '', + 'rowId' => '', + 'data' => [ + 'name' => 'Walter O\'Brien' + ] + ] + ] // optional ); ``` diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md index 76079b21..47deb73b 100644 --- a/docs/examples/tablesdb/create-point-column.md +++ b/docs/examples/tablesdb/create-point-column.md @@ -16,6 +16,9 @@ $result = $tablesDB->createPointColumn( tableId: '', key: '', required: false, - default: [1, 2] // optional + default: [ + 1, + 2 + ] // optional ); ``` diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md index 7018c1e1..66baac48 100644 --- a/docs/examples/tablesdb/create-polygon-column.md +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -16,6 +16,25 @@ $result = $tablesDB->createPolygonColumn( tableId: '', key: '', required: false, - default: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional + default: [ + [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ] + ] // optional ); ``` diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 1af62007..9f39591e 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -20,7 +20,7 @@ $result = $tablesDB->createRow( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 30, 'isAdmin' => false ], diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 6ae0f802..da4c43e6 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -14,7 +14,16 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->createRows( databaseId: '', tableId: '', - rows: [], + rows: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 2b13b6c7..a8149898 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -14,7 +14,9 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->deleteRows( databaseId: '', tableId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}' + ], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md index 9d657ba6..fc3bff58 100644 --- a/docs/examples/tablesdb/update-enum-column.md +++ b/docs/examples/tablesdb/update-enum-column.md @@ -15,7 +15,10 @@ $result = $tablesDB->updateEnumColumn( databaseId: '', tableId: '', key: '', - elements: ["active", "inactive"], + elements: [ + 'active', + 'inactive' + ], required: false, default: 'active', newKey: '' // optional diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md index 58257151..55665a78 100644 --- a/docs/examples/tablesdb/update-line-column.md +++ b/docs/examples/tablesdb/update-line-column.md @@ -16,7 +16,20 @@ $result = $tablesDB->updateLineColumn( tableId: '', key: '', required: false, - default: [[1, 2], [3, 4], [5, 6]], // optional + default: [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md index 3b55a7ab..a76649a7 100644 --- a/docs/examples/tablesdb/update-point-column.md +++ b/docs/examples/tablesdb/update-point-column.md @@ -16,7 +16,10 @@ $result = $tablesDB->updatePointColumn( tableId: '', key: '', required: false, - default: [1, 2], // optional + default: [ + 1, + 2 + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md index 05be2de0..86d67b81 100644 --- a/docs/examples/tablesdb/update-polygon-column.md +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -16,7 +16,26 @@ $result = $tablesDB->updatePolygonColumn( tableId: '', key: '', required: false, - default: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional + default: [ + [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ] + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 197179e8..bce35dea 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -20,7 +20,7 @@ $result = $tablesDB->updateRow( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 33, 'isAdmin' => false ], // optional diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 5e9dd0aa..aa59212c 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -17,7 +17,7 @@ $result = $tablesDB->updateRows( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 33, 'isAdmin' => false ], // optional diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 37786239..1127cb9b 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -20,7 +20,7 @@ $result = $tablesDB->upsertRow( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 33, 'isAdmin' => false ], // optional diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index 56aa2657..8d920bd5 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -14,7 +14,16 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->upsertRows( databaseId: '', tableId: '', - rows: [], + rows: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index cd9524a7..9470ad59 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -13,7 +13,9 @@ $teams = new Teams($client); $result = $teams->createMembership( teamId: '', - roles: [], + roles: [ + 'editor' + ], email: 'email@example.com', // optional userId: '', // optional phone: '+12065550100', // optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 87741774..15391122 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -14,6 +14,8 @@ $teams = new Teams($client); $result = $teams->updateMembership( teamId: '', membershipId: '', - roles: [] + roles: [ + 'editor' + ] ); ``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 7ac457f5..7b6cc3b3 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -13,6 +13,8 @@ $users = new Users($client); $result = $users->updateLabels( userId: '', - labels: [] + labels: [ + 'subscriber' + ] ); ``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index c3ed6628..3bbdb076 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -17,7 +17,7 @@ $result = $vectorsDB->createCollection( databaseId: '', collectionId: '', name: '', - dimension: 1, + dimension: 4, permissions: [Permission::read(Role::any())], // optional documentSecurity: false, // optional enabled: false // optional diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md index b97f81e4..f72c5fda 100644 --- a/docs/examples/vectorsdb/create-document.md +++ b/docs/examples/vectorsdb/create-document.md @@ -19,10 +19,10 @@ $result = $vectorsDB->createDocument( documentId: '', data: [ 'embeddings' => [ - '0' => 0.12, - '1' => -0.55, - '2' => 0.88, - '3' => 1.02 + 0.12, + -0.55, + 0.88, + 1.02 ], 'metadata' => [ 'key' => 'value' diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 2d1c9c2f..0a7123ca 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -14,7 +14,20 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'embeddings' => [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + 'metadata' => [ + 'name' => 'First document' + ] + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index d3e699cb..4883ccb8 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -18,7 +18,9 @@ $result = $vectorsDB->createIndex( collectionId: '', key: '', type: VectorsDBIndexType::HNSWEUCLIDEAN(), - attributes: [], + attributes: [ + 'embeddings' + ], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index c311d5e4..dac52647 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -14,15 +14,23 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->createOperations( transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + [ + 'action' => 'create', + 'databaseId' => '', + 'collectionId' => '', + 'documentId' => '', + 'data' => [ + 'embeddings' => [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + 'metadata' => [ + 'name' => 'First document' + ] + ] + ] + ] // optional ); ``` diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index 17b0831d..77811f17 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -14,7 +14,9 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}' + ], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 7898ee03..d9815b61 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -17,7 +17,7 @@ $result = $vectorsDB->updateCollection( databaseId: '', collectionId: '', name: '', - dimension: 1, // optional + dimension: 4, // optional permissions: [Permission::read(Role::any())], // optional documentSecurity: false, // optional enabled: false // optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index 11e5d31f..7d89dcdb 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -14,7 +14,20 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'embeddings' => [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + 'metadata' => [ + 'name' => 'First document' + ] + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 2b437a54..1e0ae9f9 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -15,7 +15,9 @@ $result = $webhooks->create( webhookId: '', url: 'https://example.com/webhook', name: '', - events: [], + events: [ + 'users.*.create' + ], enabled: false, // optional tls: false, // optional authUsername: '', // optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 95dafcf0..104a58b1 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -15,7 +15,9 @@ $result = $webhooks->update( webhookId: '', name: '', url: 'https://example.com/webhook', - events: [], + events: [ + 'users.*.create' + ], enabled: false, // optional tls: false, // optional authUsername: '', // optional diff --git a/docs/functions.md b/docs/functions.md index 9d6f555c..5cddf805 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -124,6 +124,7 @@ PUT https://cloud.appwrite.io/v1/functions/{functionId} | 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 | | interval | integer | Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. | | +| emailEnabled | boolean | Enable inbound email triggering for this function. When false or omitted on create, SMTP recipients are rejected. Opt-in; default is off. | | ```http request diff --git a/docs/messaging.md b/docs/messaging.md index e2d897da..5dbed35d 100644 --- a/docs/messaging.md +++ b/docs/messaging.md @@ -11,7 +11,7 @@ GET https://cloud.appwrite.io/v1/messaging/messages | 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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType | [] | +| 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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType, users, targets | [] | | 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 | @@ -363,7 +363,7 @@ POST https://cloud.appwrite.io/v1/messaging/providers/appwrite | name | string | Provider name. | | | enabled | boolean | Set as enabled. | | | qos | integer | Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. | | -| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. | | ```http request @@ -380,7 +380,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/providers/appwrite/{providerId} | name | string | Provider name. | | | enabled | boolean | Set as enabled. | | | qos | integer | Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. | | -| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. | | ```http request @@ -839,7 +839,7 @@ POST https://cloud.appwrite.io/v1/messaging/providers/twilio | --- | --- | --- | --- | | providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | name | string | Provider name. | | -| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| from | string | Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. | | | accountSid | string | Twilio account secret ID. | | | authToken | string | Twilio authentication token. | | | enabled | boolean | Set as enabled. | | @@ -860,7 +860,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/providers/twilio/{providerId} | enabled | boolean | Set as enabled. | | | accountSid | string | Twilio account secret ID. | | | authToken | string | Twilio authentication token. | | -| from | string | Sender number. | | +| from | string | Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. | | ```http request @@ -955,7 +955,7 @@ POST https://cloud.appwrite.io/v1/messaging/topics | name | string | Topic Name. | | | subscribe | array | An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | ["users"] | | qos | integer | MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. | | -| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. | | ```http request @@ -987,7 +987,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/topics/{topicId} | name | string | Topic Name. | | | subscribe | array | An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | | | qos | integer | MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. | | -| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. | | ```http request diff --git a/docs/mongo.md b/docs/mongo.md index 084c9fca..1eaebc24 100644 --- a/docs/mongo.md +++ b/docs/mongo.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/mongo | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/mongo/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request @@ -423,7 +423,9 @@ GET https://cloud.appwrite.io/v1/mongo/{databaseId}/restorations POST https://cloud.appwrite.io/v1/mongo/{databaseId}/restorations ``` -** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. ** +** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. ** ### Parameters @@ -432,8 +434,11 @@ POST https://cloud.appwrite.io/v1/mongo/{databaseId}/restorations | databaseId | string | **Required** Database ID. | | | type | string | Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. | backup | | backupId | string | Backup ID to restore from (required for backup type). | | -| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. | | +| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. | | | targetTime | string | Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. | | +| restoreMode | string | Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. | | +| targetName | string | Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. | | +| autoPromote | boolean | Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. | 1 | ```http request @@ -450,6 +455,23 @@ GET https://cloud.appwrite.io/v1/mongo/{databaseId}/restorations/{restorationId} | restorationId | string | **Required** Restoration ID. | | +```http request +POST https://cloud.appwrite.io/v1/mongo/{databaseId}/restorations/{restorationId}/promotions +``` + +** Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| restorationId | string | **Required** Restoration ID. | | + + ```http request GET https://cloud.appwrite.io/v1/mongo/{databaseId}/status ``` diff --git a/docs/mysql.md b/docs/mysql.md index ced7ecea..e4444440 100644 --- a/docs/mysql.md +++ b/docs/mysql.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/mysql | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/mysql/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request @@ -320,7 +320,7 @@ PATCH https://cloud.appwrite.io/v1/mysql/{databaseId}/credentials POST https://cloud.appwrite.io/v1/mysql/{databaseId}/executions ``` -** Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. ** +** Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. ** ### Parameters @@ -329,7 +329,7 @@ POST https://cloud.appwrite.io/v1/mysql/{databaseId}/executions | databaseId | string | **Required** Database ID. | | | sql | string | SQL statement to execute. Exactly one statement per request. | | | bindings | object | Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. | {} | -| timeoutSeconds | integer | Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. | | +| timeoutSeconds | integer | Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. | | ```http request @@ -432,7 +432,7 @@ PATCH https://cloud.appwrite.io/v1/mysql/{databaseId}/pooler | mode | string | Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. | | | maxConnections | integer | Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. | | | defaultPoolSize | integer | Default pool size per user. | | -| readWriteSplitting | boolean | Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. | | +| readWriteSplitting | boolean | Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. | | | poolerCpuRequest | string | Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). | | | poolerCpuLimit | string | Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. | | | poolerMemoryRequest | string | Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). | | @@ -473,7 +473,9 @@ GET https://cloud.appwrite.io/v1/mysql/{databaseId}/restorations POST https://cloud.appwrite.io/v1/mysql/{databaseId}/restorations ``` -** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. ** +** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. ** ### Parameters @@ -482,8 +484,11 @@ POST https://cloud.appwrite.io/v1/mysql/{databaseId}/restorations | databaseId | string | **Required** Database ID. | | | type | string | Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. | backup | | backupId | string | Backup ID to restore from (required for backup type). | | -| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. | | +| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. | | | targetTime | string | Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. | | +| restoreMode | string | Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. | | +| targetName | string | Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. | | +| autoPromote | boolean | Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. | 1 | ```http request @@ -500,6 +505,23 @@ GET https://cloud.appwrite.io/v1/mysql/{databaseId}/restorations/{restorationId} | restorationId | string | **Required** Restoration ID. | | +```http request +POST https://cloud.appwrite.io/v1/mysql/{databaseId}/restorations/{restorationId}/promotions +``` + +** Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| restorationId | string | **Required** Restoration ID. | | + + ```http request GET https://cloud.appwrite.io/v1/mysql/{databaseId}/status ``` diff --git a/docs/oauth2.md b/docs/oauth2.md index 46c3bc67..e9928cbf 100644 --- a/docs/oauth2.md +++ b/docs/oauth2.md @@ -39,7 +39,7 @@ GET https://cloud.appwrite.io/v1/oauth2/{project_id}/authorize | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | | request_uri | string | OAuth2 authorization request handle returned by the pushed authorization request endpoint. | | @@ -66,7 +66,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/authorize | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | | request_uri | string | OAuth2 authorization request handle returned by the pushed authorization request endpoint. | | @@ -85,7 +85,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/device_authorization | client_id | string | OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. | | | scope | string | Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | @@ -172,7 +172,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/par | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age parameter for customization of consent screen. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | @@ -242,6 +242,6 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/token | client_secret | string | OAuth2 client secret. Required for confidential apps. | | | code_verifier | string | PKCE code verifier. Required for public apps. | | | redirect_uri | string | Redirect URI. Required for `authorization_code` grant type. | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | diff --git a/docs/organization.md b/docs/organization.md index dc3895c1..350a7d14 100644 --- a/docs/organization.md +++ b/docs/organization.md @@ -96,78 +96,6 @@ DELETE https://cloud.appwrite.io/v1/organization/installations/{installationId} | installationId | string | **Required** Installation unique ID. | | -```http request -GET https://cloud.appwrite.io/v1/organization/keys -``` - -** Get a list of all API keys 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: expire, accessedAt, name, scopes | [] | -| 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/keys -``` - -** Create a new organization API key. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| 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 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. | | - - -```http request -GET https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including its scopes. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | - - -```http request -PUT https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | -| name | string | Key name. Max length: 128 chars. | | -| 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. | | - - -```http request -DELETE https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | - - ```http request GET https://cloud.appwrite.io/v1/organization/memberships ``` @@ -268,7 +196,7 @@ POST https://cloud.appwrite.io/v1/organization/projects | --- | --- | --- | --- | | projectId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. | | | name | string | Project name. Max length: 128 chars. | | -| region | string | Project Region. | default | +| region | string | Project Region. | | ```http request diff --git a/docs/postgresql.md b/docs/postgresql.md index d1af41f3..90c8ceb0 100644 --- a/docs/postgresql.md +++ b/docs/postgresql.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/postgresql | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/postgresql/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request @@ -320,7 +320,7 @@ PATCH https://cloud.appwrite.io/v1/postgresql/{databaseId}/credentials POST https://cloud.appwrite.io/v1/postgresql/{databaseId}/executions ``` -** Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. ** +** Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. ** ### Parameters @@ -329,7 +329,7 @@ POST https://cloud.appwrite.io/v1/postgresql/{databaseId}/executions | databaseId | string | **Required** Database ID. | | | sql | string | SQL statement to execute. Exactly one statement per request. | | | bindings | object | Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. | {} | -| timeoutSeconds | integer | Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. | | +| timeoutSeconds | integer | Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. | | ```http request @@ -473,7 +473,7 @@ PATCH https://cloud.appwrite.io/v1/postgresql/{databaseId}/pooler | mode | string | Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. | | | maxConnections | integer | Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. | | | defaultPoolSize | integer | Default pool size per user. | | -| readWriteSplitting | boolean | Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. | | +| readWriteSplitting | boolean | Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. | | | poolerCpuRequest | string | Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). | | | poolerCpuLimit | string | Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. | | | poolerMemoryRequest | string | Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). | | @@ -514,7 +514,9 @@ GET https://cloud.appwrite.io/v1/postgresql/{databaseId}/restorations POST https://cloud.appwrite.io/v1/postgresql/{databaseId}/restorations ``` -** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. ** +** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. ** ### Parameters @@ -523,8 +525,11 @@ POST https://cloud.appwrite.io/v1/postgresql/{databaseId}/restorations | databaseId | string | **Required** Database ID. | | | type | string | Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. | backup | | backupId | string | Backup ID to restore from (required for backup type). | | -| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. | | +| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. | | | targetTime | string | Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. | | +| restoreMode | string | Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. | | +| targetName | string | Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. | | +| autoPromote | boolean | Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. | 1 | ```http request @@ -541,6 +546,23 @@ GET https://cloud.appwrite.io/v1/postgresql/{databaseId}/restorations/{restorati | restorationId | string | **Required** Restoration ID. | | +```http request +POST https://cloud.appwrite.io/v1/postgresql/{databaseId}/restorations/{restorationId}/promotions +``` + +** Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| restorationId | string | **Required** Restoration ID. | | + + ```http request GET https://cloud.appwrite.io/v1/postgresql/{databaseId}/status ``` diff --git a/docs/project.md b/docs/project.md index add475e8..df5337f8 100644 --- a/docs/project.md +++ b/docs/project.md @@ -25,7 +25,7 @@ PATCH https://cloud.appwrite.io/v1/project/auth-methods/{methodId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| methodId | string | **Required** Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone | | +| methodId | string | **Required** Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey | | | enabled | boolean | Auth method status. | | @@ -648,8 +648,8 @@ PATCH https://cloud.appwrite.io/v1/project/oauth2/kakao | --- | --- | --- | --- | | clientId | string | 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de | | | clientSecret | string | 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled | | -| prompt | array | Array of Kakao OAuth2 prompt values. 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. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. | | | 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. | | +| prompt | array | Array of Kakao OAuth2 prompt values. 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. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. | | ```http request @@ -1104,7 +1104,7 @@ POST https://cloud.appwrite.io/v1/project/platforms/android PUT https://cloud.appwrite.io/v1/project/platforms/android/{platformId} ``` -** Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. ** +** Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. ** ### Parameters @@ -1537,7 +1537,7 @@ GET https://cloud.appwrite.io/v1/project/policies/{policyId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| policyId | string | **Required** Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. | | +| policyId | string | **Required** Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. | | ```http request @@ -1627,7 +1627,7 @@ PATCH https://cloud.appwrite.io/v1/project/templates/email | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| templateId | string | Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession | | +| templateId | string | Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery | | | locale | string | Custom email template locale. If left empty, the fallback locale (en) will be used. | | | subject | string | Subject of the email template. Can be up to 255 characters. | | | message | string | Plain or HTML body of the email template message. Can be up to 10MB of content. | | @@ -1647,7 +1647,7 @@ GET https://cloud.appwrite.io/v1/project/templates/email/{templateId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| templateId | string | **Required** Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession | | +| templateId | string | **Required** Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery | | | locale | string | Custom email template locale. If left empty, the fallback locale (en) will be used. | | diff --git a/docs/proxy.md b/docs/proxy.md index baf24feb..2ed4f707 100644 --- a/docs/proxy.md +++ b/docs/proxy.md @@ -7,7 +7,9 @@ POST https://cloud.appwrite.io/v1/proxy/invalidations ** Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. -Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. ** +Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. + +Domains that route to a function do not support cache invalidation. ** ### Parameters @@ -28,7 +30,7 @@ GET https://cloud.appwrite.io/v1/proxy/rules | 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch | [] | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch, protocol | [] | | total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | @@ -100,6 +102,21 @@ Rule ID is automatically generated as MD5 hash of a rule domain for performance | branch | string | Name of VCS branch to deploy changes automatically | | +```http request +POST https://cloud.appwrite.io/v1/proxy/rules/smtp +``` + +** Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| domain | string | Domain that receives email. | | +| functionId | string | ID of function to execute. | | +| branch | string | Name of VCS branch to deploy changes automatically. | | + + ```http request GET https://cloud.appwrite.io/v1/proxy/rules/{ruleId} ``` diff --git a/docs/storage.md b/docs/storage.md index cecf8af3..e24fa98a 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -201,7 +201,7 @@ GET https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId}/previ | fileId | string | **Required** File ID | | | width | integer | Resize preview image width, Pass an integer between 0 to 4000. | 0 | | height | integer | Resize preview image height, Pass an integer between 0 to 4000. | 0 | -| gravity | string | Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right | center | +| gravity | string | Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right | center | | quality | integer | Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. | -1 | | borderWidth | integer | Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. | 0 | | borderColor | string | Preview image border color. Use a valid HEX color, no # is needed for prefix. | | diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 4f2816ef..61642ce3 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -39,7 +39,7 @@ POST https://cloud.appwrite.io/v1/tablesdb GET https://cloud.appwrite.io/v1/tablesdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request @@ -199,7 +199,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations ``` -** Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live, with a brief read-only window during cutover. ** +** Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live. Reads continue throughout. Row writes are held for up to a few seconds while routing switches to the dedicated compute; a write the switch has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. Schema changes (tables, columns, indexes) are refused from creation until the cutover completes, and resume once the migration is `soaking`. ** ### Parameters @@ -242,7 +242,7 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations/{migrationI POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations/{migrationId}/cutovers ``` -** Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns, with a brief read-only window. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. ** +** Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns. Reads are unaffected; row writes are held for up to a few seconds while it lands, and a write the flip has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. ** ### Parameters @@ -327,7 +327,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables | rowSecurity | boolean | Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. | 1 | | columns | array | Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. | [] | -| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | +| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | ```http request @@ -911,6 +911,24 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | restrict | +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key} +``` + +** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | | +| newKey | string | New Column Key. | | + + ```http request POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/string ``` @@ -1100,24 +1118,6 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/colum | key | string | **Required** Column Key. | | -```http request -PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship -``` - -** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | | -| newKey | string | New Column Key. | | - - ```http request GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes ``` @@ -1139,7 +1139,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes ``` ** Creates an index on the columns listed. Your index should include all the columns you will query in a single request. -Type can be `key`, `fulltext`, or `unique`. ** +Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. ** ### Parameters diff --git a/docs/teams.md b/docs/teams.md index c08fa9b7..d7477399 100644 --- a/docs/teams.md +++ b/docs/teams.md @@ -28,7 +28,7 @@ POST https://cloud.appwrite.io/v1/teams | --- | --- | --- | --- | | teamId | string | Team 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 | Team name. Max length: 128 chars. | | -| roles | array | Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. | ["owner"] | +| roles | array | Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. 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. | ["owner"] | ```http request diff --git a/docs/users.md b/docs/users.md index 17e7c54d..4c70df69 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, accessedAt | [] | +| 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, passwordPwned, 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 | @@ -226,7 +226,7 @@ PATCH https://cloud.appwrite.io/v1/users/{userId}/email PATCH https://cloud.appwrite.io/v1/users/{userId}/impersonator ``` -** Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. +** Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. Account endpoints are read-only while impersonating: they report the target's account, and anything that would change it is refused, so an impersonator cannot alter the target's credentials or delete their account. ** ### Parameters @@ -268,21 +268,6 @@ Labels can be used to grant access to resources. While teams are a way for user' | labels | array | Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | | -```http request -GET https://cloud.appwrite.io/v1/users/{userId}/logs -``` - -** Get the user activity logs list by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User 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/users/{userId}/memberships ``` diff --git a/docs/vectorsdb.md b/docs/vectorsdb.md index 70da401a..d94cc7b0 100644 --- a/docs/vectorsdb.md +++ b/docs/vectorsdb.md @@ -38,7 +38,7 @@ POST https://cloud.appwrite.io/v1/vectorsdb GET https://cloud.appwrite.io/v1/vectorsdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/webhooks.md b/docs/webhooks.md index c8b7ec5c..5ed6ad59 100644 --- a/docs/webhooks.md +++ b/docs/webhooks.md @@ -31,8 +31,8 @@ POST https://cloud.appwrite.io/v1/webhooks | events | array | Events list. Maximum of 100 events are allowed. | | | enabled | boolean | Enable or disable a webhook. | 1 | | tls | boolean | Certificate verification, false for disabled or true for enabled. | | -| authUsername | string | Webhook HTTP user. Max length: 256 chars. | | -| authPassword | string | Webhook HTTP password. Max length: 256 chars. | | +| authUsername | string | Webhook HTTP user. Max length: 255 chars. | | +| authPassword | string | Webhook HTTP password. Max length: 2048 chars. | | | secret | string | Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. | | @@ -65,8 +65,8 @@ PUT https://cloud.appwrite.io/v1/webhooks/{webhookId} | events | array | Events list. Maximum of 100 events are allowed. | | | enabled | boolean | Enable or disable a webhook. | 1 | | tls | boolean | Certificate verification, false for disabled or true for enabled. | | -| authUsername | string | Webhook HTTP user. Max length: 256 chars. | | -| authPassword | string | Webhook HTTP password. Max length: 256 chars. | | +| authUsername | string | Webhook HTTP user. Max length: 255 chars. | | +| authPassword | string | Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. | | ```http request diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 7aaf3809..194e66bb 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -4,8 +4,10 @@ namespace Appwrite; +use Appwrite\Query\Builder as QueryBuilder; use Ahc\Jwt\JWT; use Psr\Http\Client\ClientExceptionInterface; +use Psr\Http\Client\ClientInterface; use Utopia\Client\Adapter\Curl\Client as CurlAdapter; use Utopia\Client\Client as HttpClient; use Utopia\Psr7\Request\Factory as RequestFactory; @@ -43,11 +45,11 @@ class Client * */ protected array $headers = [ - 'user-agent' => 'AppwritePHPSDK/30.4.0 ()', + 'user-agent' => 'AppwritePHPSDK/31.0.0 ()', 'x-sdk-name' => 'PHP', 'x-sdk-platform' => 'server', 'x-sdk-language' => 'php', - 'x-sdk-version' => '30.4.0', + 'x-sdk-version' => '31.0.0', ]; /** @@ -105,12 +107,13 @@ class Client protected RequestFactory $requestFactory; /** - * Client constructor. + * An injected PSR-18 transport owns its timeout, TLS, connection reuse and + * redirect configuration. Without one, the SDK configures its cURL client. */ - public function __construct() + public function __construct(private readonly ?ClientInterface $transport = null) { $this->requestFactory = new RequestFactory(); - $this->headers['X-Appwrite-Response-Format'] = '2.0.0'; + $this->headers['X-Appwrite-Response-Format'] = '2.5.0'; } /** @@ -233,21 +236,6 @@ public function setForwardedUserAgent(string $value): Client return $this; } - /** - * Set DevKey - * - * Your secret dev API key - * - * - */ - public function setDevKey(string $value): Client - { - $this->addHeader('X-Appwrite-Dev-Key', $value); - $this->config['devkey'] = $value; - - return $this; - } - /** * Set Cookie * @@ -433,6 +421,7 @@ public function call( $this->headers['authorization'] = $this->getAuthorization(); } $headers = array_merge($this->headers, $headers); + $params = \array_map(self::flatten(...), $params); $contentType = strtolower((string) ($headers['content-type'] ?? '')); if ($contentType === '') { unset($headers['content-type']); @@ -505,7 +494,7 @@ public function call( * Flatten params array to PHP multiple format * */ - protected function flatten(array $data, string $prefix = ''): array + protected function flattenForm(array $data, string $prefix = ''): array { $output = []; @@ -513,7 +502,7 @@ protected function flatten(array $data, string $prefix = ''): array $finalKey = $prefix ? "{$prefix}[{$key}]" : $key; if (is_array($value)) { - $output = array_merge($output, $this->flatten($value, $finalKey)); + $output = array_merge($output, $this->flattenForm($value, $finalKey)); } else { $output[$finalKey] = $value; } @@ -539,6 +528,40 @@ protected function prepareParams($data) return $data; } + public static function flatten(mixed $value): mixed + { + if ($value instanceof QueryBuilder) { + return $value->build(); + } + if ($value instanceof Query) { + return $value->__toString(); + } + if (!\is_array($value) || !\array_is_list($value)) { + return $value; + } + + $out = []; + $changed = false; + foreach ($value as $item) { + $flat = self::flatten($item); + if ($item instanceof QueryBuilder || $item instanceof Query) { + if (\is_array($flat)) { + array_push($out, ...$flat); + } else { + $out[] = $flat; + } + $changed = true; + continue; + } + if ($flat !== $item) { + $changed = true; + } + $out[] = $flat; + } + + return $changed ? $out : $value; + } + /** * Convert flattened params into Utopia multipart parts. * @@ -549,7 +572,7 @@ protected function toMultipartParts(array $data): array { $parts = []; - foreach ($this->flatten($data) as $name => $value) { + foreach ($this->flattenForm($data) as $name => $value) { $name = (string) $name; if ($value instanceof Part) { @@ -578,8 +601,12 @@ protected function toMultipartParts(array $data): array return $parts; } - protected function getHttpClient(bool $followRedirects): HttpClient + protected function getHttpClient(bool $followRedirects): ClientInterface { + if ($this->transport instanceof ClientInterface) { + return $this->transport; + } + if ($followRedirects) { return $this->httpClient ??= $this->createHttpClient(true); } diff --git a/src/Appwrite/Enums/BillingPlanGroup.php b/src/Appwrite/Enums/BillingPlanGroup.php index 59b1adab..c3a69534 100644 --- a/src/Appwrite/Enums/BillingPlanGroup.php +++ b/src/Appwrite/Enums/BillingPlanGroup.php @@ -9,7 +9,6 @@ class BillingPlanGroup implements JsonSerializable, Stringable { - private static BillingPlanGroup $STARTER; private static BillingPlanGroup $FREE; private static BillingPlanGroup $START; private static BillingPlanGroup $PRO; @@ -29,12 +28,6 @@ public function jsonSerialize(): string return $this->value; } - public static function STARTER(): BillingPlanGroup - { - self::$STARTER ??= new BillingPlanGroup('starter'); - - return self::$STARTER; - } public static function FREE(): BillingPlanGroup { self::$FREE ??= new BillingPlanGroup('free'); @@ -63,7 +56,6 @@ public static function SCALE(): BillingPlanGroup public static function from(string $value): self { return match ($value) { - 'starter' => self::STARTER(), 'free' => self::FREE(), 'start' => self::START(), 'pro' => self::PRO(), diff --git a/src/Appwrite/Enums/ExecutionTrigger.php b/src/Appwrite/Enums/ExecutionTrigger.php index fccf3f23..99ed21da 100644 --- a/src/Appwrite/Enums/ExecutionTrigger.php +++ b/src/Appwrite/Enums/ExecutionTrigger.php @@ -12,6 +12,7 @@ class ExecutionTrigger implements JsonSerializable, Stringable private static ExecutionTrigger $HTTP; private static ExecutionTrigger $SCHEDULE; private static ExecutionTrigger $EVENT; + private static ExecutionTrigger $EMAIL; private function __construct(private readonly string $value) { @@ -45,6 +46,12 @@ public static function EVENT(): ExecutionTrigger return self::$EVENT; } + public static function EMAIL(): ExecutionTrigger + { + self::$EMAIL ??= new ExecutionTrigger('email'); + + return self::$EMAIL; + } public static function from(string $value): self { @@ -52,6 +59,7 @@ public static function from(string $value): self 'http' => self::HTTP(), 'schedule' => self::SCHEDULE(), 'event' => self::EVENT(), + 'email' => self::EMAIL(), default => throw new \InvalidArgumentException('Unknown ExecutionTrigger value: ' . $value), }; } diff --git a/src/Appwrite/Enums/OrganizationKeyScopes.php b/src/Appwrite/Enums/OrganizationKeyScopes.php deleted file mode 100644 index b28e58e9..00000000 --- a/src/Appwrite/Enums/OrganizationKeyScopes.php +++ /dev/null @@ -1,162 +0,0 @@ -value; - } - - public function jsonSerialize(): string - { - return $this->value; - } - - public static function PROJECTSREAD(): OrganizationKeyScopes - { - self::$PROJECTSREAD ??= new OrganizationKeyScopes('projects.read'); - - return self::$PROJECTSREAD; - } - public static function PROJECTSWRITE(): OrganizationKeyScopes - { - self::$PROJECTSWRITE ??= new OrganizationKeyScopes('projects.write'); - - return self::$PROJECTSWRITE; - } - public static function DEVKEYSREAD(): OrganizationKeyScopes - { - self::$DEVKEYSREAD ??= new OrganizationKeyScopes('devKeys.read'); - - return self::$DEVKEYSREAD; - } - public static function DEVKEYSWRITE(): OrganizationKeyScopes - { - self::$DEVKEYSWRITE ??= new OrganizationKeyScopes('devKeys.write'); - - return self::$DEVKEYSWRITE; - } - public static function ORGANIZATIONKEYSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONKEYSREAD ??= new OrganizationKeyScopes('organization.keys.read'); - - return self::$ORGANIZATIONKEYSREAD; - } - public static function ORGANIZATIONKEYSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONKEYSWRITE ??= new OrganizationKeyScopes('organization.keys.write'); - - return self::$ORGANIZATIONKEYSWRITE; - } - public static function ORGANIZATIONINSTALLATIONSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONINSTALLATIONSREAD ??= new OrganizationKeyScopes('organization.installations.read'); - - return self::$ORGANIZATIONINSTALLATIONSREAD; - } - public static function ORGANIZATIONINSTALLATIONSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONINSTALLATIONSWRITE ??= new OrganizationKeyScopes('organization.installations.write'); - - return self::$ORGANIZATIONINSTALLATIONSWRITE; - } - public static function ORGANIZATIONMEMBERSHIPSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONMEMBERSHIPSREAD ??= new OrganizationKeyScopes('organization.memberships.read'); - - return self::$ORGANIZATIONMEMBERSHIPSREAD; - } - public static function ORGANIZATIONMEMBERSHIPSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONMEMBERSHIPSWRITE ??= new OrganizationKeyScopes('organization.memberships.write'); - - return self::$ORGANIZATIONMEMBERSHIPSWRITE; - } - public static function ORGANIZATIONREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONREAD ??= new OrganizationKeyScopes('organization.read'); - - return self::$ORGANIZATIONREAD; - } - public static function ORGANIZATIONWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONWRITE ??= new OrganizationKeyScopes('organization.write'); - - return self::$ORGANIZATIONWRITE; - } - public static function DOMAINSREAD(): OrganizationKeyScopes - { - self::$DOMAINSREAD ??= new OrganizationKeyScopes('domains.read'); - - return self::$DOMAINSREAD; - } - public static function DOMAINSWRITE(): OrganizationKeyScopes - { - self::$DOMAINSWRITE ??= new OrganizationKeyScopes('domains.write'); - - return self::$DOMAINSWRITE; - } - public static function KEYSREAD(): OrganizationKeyScopes - { - self::$KEYSREAD ??= new OrganizationKeyScopes('keys.read'); - - return self::$KEYSREAD; - } - public static function KEYSWRITE(): OrganizationKeyScopes - { - self::$KEYSWRITE ??= new OrganizationKeyScopes('keys.write'); - - return self::$KEYSWRITE; - } - - public static function from(string $value): self - { - return match ($value) { - 'projects.read' => self::PROJECTSREAD(), - 'projects.write' => self::PROJECTSWRITE(), - 'devKeys.read' => self::DEVKEYSREAD(), - 'devKeys.write' => self::DEVKEYSWRITE(), - 'organization.keys.read' => self::ORGANIZATIONKEYSREAD(), - 'organization.keys.write' => self::ORGANIZATIONKEYSWRITE(), - 'organization.installations.read' => self::ORGANIZATIONINSTALLATIONSREAD(), - 'organization.installations.write' => self::ORGANIZATIONINSTALLATIONSWRITE(), - '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(), - 'keys.write' => self::KEYSWRITE(), - default => throw new \InvalidArgumentException('Unknown OrganizationKeyScopes value: ' . $value), - }; - } -} diff --git a/src/Appwrite/Enums/ProxyRuleProtocol.php b/src/Appwrite/Enums/ProxyRuleProtocol.php new file mode 100644 index 00000000..0c7423de --- /dev/null +++ b/src/Appwrite/Enums/ProxyRuleProtocol.php @@ -0,0 +1,50 @@ +value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function HTTP(): ProxyRuleProtocol + { + self::$HTTP ??= new ProxyRuleProtocol('http'); + + return self::$HTTP; + } + public static function SMTP(): ProxyRuleProtocol + { + self::$SMTP ??= new ProxyRuleProtocol('smtp'); + + return self::$SMTP; + } + + public static function from(string $value): self + { + return match ($value) { + 'http' => self::HTTP(), + 'smtp' => self::SMTP(), + default => throw new \InvalidArgumentException('Unknown ProxyRuleProtocol value: ' . $value), + }; + } +} diff --git a/src/Appwrite/Models/ActivityEventList.php b/src/Appwrite/Models/ActivityEventList.php index 8fd47418..357d7578 100644 --- a/src/Appwrite/Models/ActivityEventList.php +++ b/src/Appwrite/Models/ActivityEventList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'events' => [], ]; - if (!array_key_exists('events', $data)) { - throw new \InvalidArgumentException('Missing required field "events" for ' . static::class . '.'); - } - return new static( total: $data['total'], events: is_array($data['events']) diff --git a/src/Appwrite/Models/App.php b/src/Appwrite/Models/App.php index 24d11d56..7b0f9e16 100644 --- a/src/Appwrite/Models/App.php +++ b/src/Appwrite/Models/App.php @@ -104,12 +104,9 @@ public static function from(array $data): static 'userId' => "", 'installationScopes' => [], 'installationRedirectUrl' => "", + 'secrets' => [], ]; - if (!array_key_exists('secrets', $data)) { - throw new \InvalidArgumentException('Missing required field "secrets" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/AppInstallationList.php b/src/Appwrite/Models/AppInstallationList.php index cd5c3396..09803f30 100644 --- a/src/Appwrite/Models/AppInstallationList.php +++ b/src/Appwrite/Models/AppInstallationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'installations' => [], ]; - if (!array_key_exists('installations', $data)) { - throw new \InvalidArgumentException('Missing required field "installations" for ' . static::class . '.'); - } - return new static( total: $data['total'], installations: is_array($data['installations']) diff --git a/src/Appwrite/Models/AppKeyList.php b/src/Appwrite/Models/AppKeyList.php index 25f9edf9..577dfc64 100644 --- a/src/Appwrite/Models/AppKeyList.php +++ b/src/Appwrite/Models/AppKeyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'keys' => [], ]; - if (!array_key_exists('keys', $data)) { - throw new \InvalidArgumentException('Missing required field "keys" for ' . static::class . '.'); - } - return new static( total: $data['total'], keys: is_array($data['keys']) diff --git a/src/Appwrite/Models/AppScopeList.php b/src/Appwrite/Models/AppScopeList.php index 7ccaf66a..06bace42 100644 --- a/src/Appwrite/Models/AppScopeList.php +++ b/src/Appwrite/Models/AppScopeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'scopes' => [], ]; - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } - return new static( total: $data['total'], scopes: is_array($data['scopes']) diff --git a/src/Appwrite/Models/AppSecretList.php b/src/Appwrite/Models/AppSecretList.php index eae43eb6..9eb22f83 100644 --- a/src/Appwrite/Models/AppSecretList.php +++ b/src/Appwrite/Models/AppSecretList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'secrets' => [], ]; - if (!array_key_exists('secrets', $data)) { - throw new \InvalidArgumentException('Missing required field "secrets" for ' . static::class . '.'); - } - return new static( total: $data['total'], secrets: is_array($data['secrets']) diff --git a/src/Appwrite/Models/AppsList.php b/src/Appwrite/Models/AppsList.php index 4b028315..5685206d 100644 --- a/src/Appwrite/Models/AppsList.php +++ b/src/Appwrite/Models/AppsList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'apps' => [], ]; - if (!array_key_exists('apps', $data)) { - throw new \InvalidArgumentException('Missing required field "apps" for ' . static::class . '.'); - } - return new static( total: $data['total'], apps: is_array($data['apps']) diff --git a/src/Appwrite/Models/AttributeEnum.php b/src/Appwrite/Models/AttributeEnum.php index d2d84316..c99bdc57 100644 --- a/src/Appwrite/Models/AttributeEnum.php +++ b/src/Appwrite/Models/AttributeEnum.php @@ -57,15 +57,13 @@ public static function from(array $data): static 'required' => false, '$createdAt' => "", '$updatedAt' => "", + 'elements' => [], 'format' => "enum", ]; if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('elements', $data)) { - throw new \InvalidArgumentException('Missing required field "elements" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeList.php b/src/Appwrite/Models/AttributeList.php index 0dd3e89e..b583570c 100644 --- a/src/Appwrite/Models/AttributeList.php +++ b/src/Appwrite/Models/AttributeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'attributes' => [], ]; - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - return new static( total: $data['total'], attributes: $data['attributes'] diff --git a/src/Appwrite/Models/BackupArchive.php b/src/Appwrite/Models/BackupArchive.php index 44422c20..949c9466 100644 --- a/src/Appwrite/Models/BackupArchive.php +++ b/src/Appwrite/Models/BackupArchive.php @@ -20,12 +20,12 @@ * @param string $createdAt archive creation time in iso 8601 format. * @param string $updatedAt archive update date in iso 8601 format. * @param string $policyId archive policy id. - * @param int $size archive size in bytes. * @param string $status the status of the archive creation. possible values: pending, processing, uploading, completed, failed, skipped. - * @param string $startedAt the backup start time. * @param string $migrationId migration id. * @param array $services the services that are backed up by this archive. * @param array $resources the resources that are backed up by this archive. + * @param int|null $size archive size in bytes. null until the size is known. + * @param string|null $startedAt the backup start time. null until the backup starts. * @param string|null $resourceId the resource id to backup. set only if this archive should backup a single resource. * @param string|null $resourceType the resource type to backup. set only if this archive should backup a single resource. */ @@ -34,12 +34,12 @@ public function __construct( public string $createdAt, public string $updatedAt, public string $policyId, - public int $size, public string $status, - public string $startedAt, public string $migrationId, public array $services, public array $resources, + public ?int $size = null, + public ?string $startedAt = null, public ?string $resourceId = null, public ?string $resourceType = null ) { @@ -57,32 +57,21 @@ public static function from(array $data): static 'policyId' => "", 'status' => "", 'migrationId' => "", + 'services' => [], + 'resources' => [], ]; - if (!array_key_exists('size', $data)) { - throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); - } - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], updatedAt: $data['$updatedAt'], policyId: $data['policyId'], - size: $data['size'], status: $data['status'], - startedAt: $data['startedAt'], migrationId: $data['migrationId'], services: $data['services'], resources: $data['resources'], + size: $data['size'] ?? null, + startedAt: $data['startedAt'] ?? null, resourceId: $data['resourceId'] ?? null, resourceType: $data['resourceType'] ?? null ); diff --git a/src/Appwrite/Models/BackupArchiveList.php b/src/Appwrite/Models/BackupArchiveList.php index 49691da9..e166d7a7 100644 --- a/src/Appwrite/Models/BackupArchiveList.php +++ b/src/Appwrite/Models/BackupArchiveList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'archives' => [], ]; - if (!array_key_exists('archives', $data)) { - throw new \InvalidArgumentException('Missing required field "archives" for ' . static::class . '.'); - } - return new static( total: $data['total'], archives: is_array($data['archives']) diff --git a/src/Appwrite/Models/BackupPolicy.php b/src/Appwrite/Models/BackupPolicy.php index 790139c0..b527ffbc 100644 --- a/src/Appwrite/Models/BackupPolicy.php +++ b/src/Appwrite/Models/BackupPolicy.php @@ -55,19 +55,14 @@ public static function from(array $data): static 'name' => "", '$createdAt' => "", '$updatedAt' => "", + 'services' => [], + 'resources' => [], 'retention' => 1, 'schedule' => "0 * * * *", 'type' => "full", 'enabled' => false, ]; - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], name: $data['name'], diff --git a/src/Appwrite/Models/BackupPolicyList.php b/src/Appwrite/Models/BackupPolicyList.php index f27fe912..ab81c662 100644 --- a/src/Appwrite/Models/BackupPolicyList.php +++ b/src/Appwrite/Models/BackupPolicyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'policies' => [], ]; - if (!array_key_exists('policies', $data)) { - throw new \InvalidArgumentException('Missing required field "policies" for ' . static::class . '.'); - } - return new static( total: $data['total'], policies: is_array($data['policies']) diff --git a/src/Appwrite/Models/BackupRestoration.php b/src/Appwrite/Models/BackupRestoration.php index c6581f63..0a588ec3 100644 --- a/src/Appwrite/Models/BackupRestoration.php +++ b/src/Appwrite/Models/BackupRestoration.php @@ -22,11 +22,11 @@ * @param string $archiveId backup archive id. * @param string $policyId backup policy id. * @param string $status the status of the restoration. possible values: pending, downloading, processing, completed, failed. - * @param string $startedAt the backup start time. * @param string $migrationId migration id. * @param array $services the services that are backed up by this policy. * @param array $resources the resources that are backed up by this policy. - * @param string $options optional data in key-value object. + * @param array $options restoration options as a key-value object. + * @param string|null $startedAt the restoration start time. null until the restoration starts. */ public function __construct( public string $id, @@ -35,11 +35,11 @@ public function __construct( public string $archiveId, public string $policyId, public string $status, - public string $startedAt, public string $migrationId, public array $services, public array $resources, - public string $options + public array $options, + public ?string $startedAt = null ) { } @@ -56,19 +56,11 @@ public static function from(array $data): static 'policyId' => "", 'status' => "", 'migrationId' => "", + 'services' => [], + 'resources' => [], 'options' => [], ]; - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], @@ -76,11 +68,11 @@ public static function from(array $data): static archiveId: $data['archiveId'], policyId: $data['policyId'], status: $data['status'], - startedAt: $data['startedAt'], migrationId: $data['migrationId'], services: $data['services'], resources: $data['resources'], - options: $data['options'] + options: $data['options'], + startedAt: $data['startedAt'] ?? null ); } diff --git a/src/Appwrite/Models/BackupRestorationList.php b/src/Appwrite/Models/BackupRestorationList.php index 6d7f13dc..86759d45 100644 --- a/src/Appwrite/Models/BackupRestorationList.php +++ b/src/Appwrite/Models/BackupRestorationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'restorations' => [], ]; - if (!array_key_exists('restorations', $data)) { - throw new \InvalidArgumentException('Missing required field "restorations" for ' . static::class . '.'); - } - return new static( total: $data['total'], restorations: is_array($data['restorations']) diff --git a/src/Appwrite/Models/BillingPlan.php b/src/Appwrite/Models/BillingPlan.php index c8da4643..29ad81c0 100644 --- a/src/Appwrite/Models/BillingPlan.php +++ b/src/Appwrite/Models/BillingPlan.php @@ -30,6 +30,7 @@ * @param int $screenshotsGenerated screenshots generated * @param int $webhooks webhooks * @param int $wafRules maximum waf rules per project + * @param int $environments maximum environments per project. 0 when the plan does not offer environments. * @param int $projects projects * @param int $platforms platforms * @param int $users users @@ -54,7 +55,6 @@ * @param int $usageLogs usage history days * @param int $projectInactivityDays number of days of console inactivity before a project is paused. 0 means pausing is disabled. * @param int $alertLimit alert threshold percentage - * @param UsageBillingPlan $usage additional resources * @param BillingPlanAddon $addons addons * @param bool $budgetCapEnabled budget cap enabled or disabled. * @param bool $customSmtp custom smtp @@ -83,10 +83,10 @@ * @param BillingPlanGroup $group group of this billing plan for variants * @param float $databaseComputeCredit included monthly dedicated-database compute credit in usd. resets each billing cycle with no roll-over. * @param int|null $members members - * @param int|null $environments maximum environments per project. 0 when the plan does not offer environments. * @param int|null $activityLogs activity log days * @param array|null $usageLogsIntervals usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). * @param array|null $usageAggregateOnlyMetrics metrics this plan only records as a total. they cannot be broken down by dimension or filtered, because the stored events cover a fraction of the real traffic. + * @param UsageBillingPlan|null $usage additional resources. null when the plan does not support usage billing. * @param array|null $eligibleCountries iso country codes eligible for this regional plan. empty means no restriction. * @param bool|null $backupsEnabled does plan support backup policies. * @param int|null $backupPolicies how many policies does plan support @@ -107,6 +107,7 @@ public function __construct( public int $screenshotsGenerated, public int $webhooks, public int $wafRules, + public int $environments, public int $projects, public int $platforms, public int $users, @@ -131,7 +132,6 @@ public function __construct( public int $usageLogs, public int $projectInactivityDays, public int $alertLimit, - public UsageBillingPlan $usage, public BillingPlanAddon $addons, public bool $budgetCapEnabled, public bool $customSmtp, @@ -160,10 +160,10 @@ public function __construct( public BillingPlanGroup $group, public float $databaseComputeCredit, public ?int $members = null, - public ?int $environments = null, public ?int $activityLogs = null, public ?array $usageLogsIntervals = null, public ?array $usageAggregateOnlyMetrics = null, + public ?UsageBillingPlan $usage = null, public ?array $eligibleCountries = null, public ?bool $backupsEnabled = null, public ?int $backupPolicies = null, @@ -191,6 +191,7 @@ public static function from(array $data): static 'screenshotsGenerated' => 0, 'webhooks' => 0, 'wafRules' => 0, + 'environments' => 0, 'projects' => 0, 'platforms' => 0, 'users' => 0, @@ -241,9 +242,6 @@ public static function from(array $data): static 'databaseComputeCredit' => 0, ]; - 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 . '.'); } @@ -267,6 +265,7 @@ public static function from(array $data): static screenshotsGenerated: $data['screenshotsGenerated'], webhooks: $data['webhooks'], wafRules: $data['wafRules'], + environments: $data['environments'], projects: $data['projects'], platforms: $data['platforms'], users: $data['users'], @@ -291,7 +290,6 @@ functions: $data['functions'], 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'], @@ -320,10 +318,10 @@ functionsIntervalMinimum: $data['functionsIntervalMinimum'], group: static::hydrateTypedValue(BillingPlanGroup::class, $data['group']), databaseComputeCredit: $data['databaseComputeCredit'], members: $data['members'] ?? null, - environments: $data['environments'] ?? null, activityLogs: $data['activityLogs'] ?? null, usageLogsIntervals: $data['usageLogsIntervals'] ?? null, usageAggregateOnlyMetrics: $data['usageAggregateOnlyMetrics'] ?? null, + usage: array_key_exists('usage', $data) ? static::hydrateTypedValue(UsageBillingPlan::class, $data['usage'], true) : null, eligibleCountries: $data['eligibleCountries'] ?? null, backupsEnabled: $data['backupsEnabled'] ?? null, backupPolicies: $data['backupPolicies'] ?? null, diff --git a/src/Appwrite/Models/Block.php b/src/Appwrite/Models/Block.php index f40cb573..3b918222 100644 --- a/src/Appwrite/Models/Block.php +++ b/src/Appwrite/Models/Block.php @@ -20,12 +20,6 @@ * @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. - * @param string $organizationId id of the organization that owns the project. - * @param string $billingPlan billing plan of the organization that owns the project. - * @param string|null $reason reason for the block. can be null if no reason was provided. * @param string|null $expiredAt block expiration date in iso 8601 format. can be null if the block does not expire. */ public function __construct( @@ -33,12 +27,6 @@ public function __construct( public string $resourceType, public string $resourceId, public string $mode, - public string $projectName, - public string $region, - public string $organizationName, - public string $organizationId, - public string $billingPlan, - public ?string $reason = null, public ?string $expiredAt = null ) { } @@ -55,33 +43,11 @@ public static function from(array $data): static 'mode' => "full", ]; - if (!array_key_exists('projectName', $data)) { - throw new \InvalidArgumentException('Missing required field "projectName" for ' . static::class . '.'); - } - if (!array_key_exists('region', $data)) { - throw new \InvalidArgumentException('Missing required field "region" for ' . static::class . '.'); - } - if (!array_key_exists('organizationName', $data)) { - throw new \InvalidArgumentException('Missing required field "organizationName" for ' . static::class . '.'); - } - if (!array_key_exists('organizationId', $data)) { - throw new \InvalidArgumentException('Missing required field "organizationId" for ' . static::class . '.'); - } - if (!array_key_exists('billingPlan', $data)) { - throw new \InvalidArgumentException('Missing required field "billingPlan" for ' . static::class . '.'); - } - return new static( createdAt: $data['$createdAt'], resourceType: $data['resourceType'], resourceId: $data['resourceId'], mode: $data['mode'], - projectName: $data['projectName'], - region: $data['region'], - organizationName: $data['organizationName'], - organizationId: $data['organizationId'], - billingPlan: $data['billingPlan'], - reason: $data['reason'] ?? null, expiredAt: $data['expiredAt'] ?? null ); } @@ -96,13 +62,7 @@ public function toArray(): array '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), - 'region' => static::serializeValue($this->region), - 'organizationName' => static::serializeValue($this->organizationName), - 'organizationId' => static::serializeValue($this->organizationId), - 'billingPlan' => static::serializeValue($this->billingPlan) + 'expiredAt' => static::serializeValue($this->expiredAt) ]; } } diff --git a/src/Appwrite/Models/BucketList.php b/src/Appwrite/Models/BucketList.php index 4ee13e87..d5e2831f 100644 --- a/src/Appwrite/Models/BucketList.php +++ b/src/Appwrite/Models/BucketList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'buckets' => [], ]; - if (!array_key_exists('buckets', $data)) { - throw new \InvalidArgumentException('Missing required field "buckets" for ' . static::class . '.'); - } - return new static( total: $data['total'], buckets: is_array($data['buckets']) diff --git a/src/Appwrite/Models/Collection.php b/src/Appwrite/Models/Collection.php index 34e1ff95..cf23cf70 100644 --- a/src/Appwrite/Models/Collection.php +++ b/src/Appwrite/Models/Collection.php @@ -54,24 +54,17 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'documentSecurity' => false, + 'attributes' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/CollectionList.php b/src/Appwrite/Models/CollectionList.php index 435e41ad..19110117 100644 --- a/src/Appwrite/Models/CollectionList.php +++ b/src/Appwrite/Models/CollectionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'collections' => [], ]; - if (!array_key_exists('collections', $data)) { - throw new \InvalidArgumentException('Missing required field "collections" for ' . static::class . '.'); - } - return new static( total: $data['total'], collections: is_array($data['collections']) diff --git a/src/Appwrite/Models/ColumnEnum.php b/src/Appwrite/Models/ColumnEnum.php index f9c4c458..31b43871 100644 --- a/src/Appwrite/Models/ColumnEnum.php +++ b/src/Appwrite/Models/ColumnEnum.php @@ -57,15 +57,13 @@ public static function from(array $data): static 'required' => false, '$createdAt' => "", '$updatedAt' => "", + 'elements' => [], 'format' => "enum", ]; if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('elements', $data)) { - throw new \InvalidArgumentException('Missing required field "elements" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnIndexList.php b/src/Appwrite/Models/ColumnIndexList.php index b5eaf075..1ce04240 100644 --- a/src/Appwrite/Models/ColumnIndexList.php +++ b/src/Appwrite/Models/ColumnIndexList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'indexes' => [], ]; - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( total: $data['total'], indexes: is_array($data['indexes']) diff --git a/src/Appwrite/Models/ColumnList.php b/src/Appwrite/Models/ColumnList.php index 108ff6a4..bc3a30f3 100644 --- a/src/Appwrite/Models/ColumnList.php +++ b/src/Appwrite/Models/ColumnList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'columns' => [], ]; - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - return new static( total: $data['total'], columns: $data['columns'] diff --git a/src/Appwrite/Models/ContinentList.php b/src/Appwrite/Models/ContinentList.php index 3af16511..dbf1b56c 100644 --- a/src/Appwrite/Models/ContinentList.php +++ b/src/Appwrite/Models/ContinentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'continents' => [], ]; - if (!array_key_exists('continents', $data)) { - throw new \InvalidArgumentException('Missing required field "continents" for ' . static::class . '.'); - } - return new static( total: $data['total'], continents: is_array($data['continents']) diff --git a/src/Appwrite/Models/CountryList.php b/src/Appwrite/Models/CountryList.php index 0a9210a9..84ce278a 100644 --- a/src/Appwrite/Models/CountryList.php +++ b/src/Appwrite/Models/CountryList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'countries' => [], ]; - if (!array_key_exists('countries', $data)) { - throw new \InvalidArgumentException('Missing required field "countries" for ' . static::class . '.'); - } - return new static( total: $data['total'], countries: is_array($data['countries']) diff --git a/src/Appwrite/Models/CurrencyList.php b/src/Appwrite/Models/CurrencyList.php index d2b33e37..9243c75f 100644 --- a/src/Appwrite/Models/CurrencyList.php +++ b/src/Appwrite/Models/CurrencyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'currencies' => [], ]; - if (!array_key_exists('currencies', $data)) { - throw new \InvalidArgumentException('Missing required field "currencies" for ' . static::class . '.'); - } - return new static( total: $data['total'], currencies: is_array($data['currencies']) diff --git a/src/Appwrite/Models/Database.php b/src/Appwrite/Models/Database.php index bd3a45e1..6cbaff98 100644 --- a/src/Appwrite/Models/Database.php +++ b/src/Appwrite/Models/Database.php @@ -30,7 +30,7 @@ * @param string|null $specification compute specification identifier of the dedicated backing, e.g. s-2vcpu-2gb. null when the database has no dedicated backing. * @param int|null $replicas number of secondary high availability replicas, excluding the primary. null when backing configuration is unavailable. * @param string|null $error error message when the dedicated backing failed. null when the database has no dedicated backing or has not failed. - * @param string|null $containerStatus container status of the dedicated backing: active or inactive. null when the database has no dedicated backing or the runtime has not reported one. + * @param string|null $containerStatus container status of the dedicated backing: active, inactive, or failed (a wake was declined because the backing namespace is gone). null when the database has no dedicated backing or the runtime has not reported one. * @param string|null $lifecycleState idle-lifecycle state of the dedicated backing: active, warm, cold, or hibernated. null when the database has no dedicated backing or the runtime has not reported one. * @param list|null $policies database backup policies. * @param list|null $archives database backup archives. diff --git a/src/Appwrite/Models/DatabaseList.php b/src/Appwrite/Models/DatabaseList.php index 86fb3468..8a1dd971 100644 --- a/src/Appwrite/Models/DatabaseList.php +++ b/src/Appwrite/Models/DatabaseList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'databases' => [], ]; - if (!array_key_exists('databases', $data)) { - throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); - } - return new static( total: $data['total'], databases: is_array($data['databases']) diff --git a/src/Appwrite/Models/DatabaseMigrationList.php b/src/Appwrite/Models/DatabaseMigrationList.php index ae2528dd..480bf847 100644 --- a/src/Appwrite/Models/DatabaseMigrationList.php +++ b/src/Appwrite/Models/DatabaseMigrationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'migrations' => [], ]; - if (!array_key_exists('migrations', $data)) { - throw new \InvalidArgumentException('Missing required field "migrations" for ' . static::class . '.'); - } - return new static( total: $data['total'], migrations: is_array($data['migrations']) diff --git a/src/Appwrite/Models/DatabaseStatus.php b/src/Appwrite/Models/DatabaseStatus.php index 6fdaf141..b685e035 100644 --- a/src/Appwrite/Models/DatabaseStatus.php +++ b/src/Appwrite/Models/DatabaseStatus.php @@ -21,13 +21,13 @@ * @param string $engine database engine: postgresql, mysql, or mongodb. * @param string $version database engine version. * @param int $uptime database uptime in seconds. - * @param DatabaseStatusConnections $connections connection statistics. * @param string $syncMode requested replication sync mode. possible values: async, sync, quorum. compare with effectivesyncmode for what the primary is enforcing. * @param bool $syncDegraded whether the enforced replication is weaker than the requested syncmode. * @param int $syncAcknowledgements number of standby acknowledgements the primary waits for before a write is committed. * @param int $syncStandbyCount number of standbys registered with the primary for synchronous replication. * @param list $replicas list of database replicas and their status. every configured member appears, including one the backend has not brought up, which is reported as not healthy. * @param list $volumes storage volume information. + * @param DatabaseStatusConnections|null $connections connection statistics. null when the database has not been probed. * @param string|null $effectiveSyncMode replication sync mode the primary is actually enforcing. null when high availability is disabled or the state could not be read. * @param bool|null $syncStateConfirmed whether the other sync fields are an engine reading rather than a recorded estimate. true when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. false when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. false never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ @@ -37,13 +37,13 @@ public function __construct( public string $engine, public string $version, public int $uptime, - public DatabaseStatusConnections $connections, public string $syncMode, public bool $syncDegraded, public int $syncAcknowledgements, public int $syncStandbyCount, public array $replicas, public array $volumes, + public ?DatabaseStatusConnections $connections = null, public ?string $effectiveSyncMode = null, public ?bool $syncStateConfirmed = null ) { @@ -64,25 +64,16 @@ public static function from(array $data): static 'syncDegraded' => false, 'syncAcknowledgements' => 0, 'syncStandbyCount' => 0, + 'replicas' => [], + 'volumes' => [], ]; - if (!array_key_exists('connections', $data)) { - throw new \InvalidArgumentException('Missing required field "connections" for ' . static::class . '.'); - } - if (!array_key_exists('replicas', $data)) { - throw new \InvalidArgumentException('Missing required field "replicas" for ' . static::class . '.'); - } - if (!array_key_exists('volumes', $data)) { - throw new \InvalidArgumentException('Missing required field "volumes" for ' . static::class . '.'); - } - return new static( health: $data['health'], ready: $data['ready'], engine: $data['engine'], version: $data['version'], uptime: $data['uptime'], - connections: static::hydrateTypedValue(DatabaseStatusConnections::class, $data['connections']), syncMode: $data['syncMode'], syncDegraded: $data['syncDegraded'], syncAcknowledgements: $data['syncAcknowledgements'], @@ -99,6 +90,7 @@ public static function from(array $data): static $data['volumes'] ) : $data['volumes'], + connections: array_key_exists('connections', $data) ? static::hydrateTypedValue(DatabaseStatusConnections::class, $data['connections'], true) : null, effectiveSyncMode: $data['effectiveSyncMode'] ?? null, syncStateConfirmed: $data['syncStateConfirmed'] ?? null ); diff --git a/src/Appwrite/Models/DedicatedDatabase.php b/src/Appwrite/Models/DedicatedDatabase.php index acd6c5d1..fd356542 100644 --- a/src/Appwrite/Models/DedicatedDatabase.php +++ b/src/Appwrite/Models/DedicatedDatabase.php @@ -21,25 +21,23 @@ * @param string $updatedAt database update date in iso 8601 format. * @param string $projectId project id that owns this database. * @param string $name database display name. - * @param string $api product api that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. - * @param string $engine database engine: postgresql, mysql, or mongodb. null until the backing reports one. * @param string $version database engine version. * @param string $specification specification identifier. * @param string $backend database backend provider. possible values: edge. * @param string $hostname database hostname for connections. - * @param int $connectionPort database port for connections. derived from the engine when the backing has not reported one yet. * @param string $connectionUser database username for connections. * @param string $connectionPassword database password for connections. - * @param int $credentialGeneration committed generation of the primary connection credentials. null until the rotation contract has been initialized. * @param string $connectionString full database connection string (uri format). * @param bool $ssl whether ssl/tls is required for client connections. * @param string $status database status. possible values: provisioning, ready, inactive, paused, failed, deleted, restoring, scaling. - * @param string $containerStatus container status for lifecycle-managed database runtimes: active or inactive. + * @param string $containerStatus container status for lifecycle-managed database runtimes: active, inactive, or failed (a wake was declined because the backing namespace is gone). * @param string $lifecycleState idle-lifecycle state of the database. possible values: active, warm, cold, hibernated. * @param int $idleTimeoutMinutes minutes of inactivity before container scales to zero. * @param int $cpu cpu allocated in millicores. * @param int $memory memory allocated in mb. * @param int $storage storage allocated in gb. + * @param string $storageStatus storage resize status. possible values: idle (no resize in flight), resizing (the volume is growing towards storagetargetgb). + * @param int $storageTargetGb size in gb the volume is growing towards while storagestatus is resizing. 0 when no resize is in flight. * @param string $storageClass storage class. currently always 'ssd'; digitalocean exposes a single block-storage class. * @param int $storageMaxGb maximum storage allowed in gb. 0 means use system default. * @param string $nodePool kubernetes node pool where the database is scheduled. @@ -53,7 +51,7 @@ * @param int $pitrRetentionDays number of days to retain pitr data. * @param bool $storageAutoscaling whether automatic storage expansion is enabled. * @param int $storageAutoscalingThresholdPercent storage usage percentage that triggers automatic expansion. - * @param int $storageAutoscalingMaxGb maximum storage size in gb for autoscaling. 0 means no limit. + * @param int $storageAutoscalingMaxGb maximum storage size in gb for autoscaling. defaults to 3 times the specification's storage. 0 means no limit. * @param string $maintenanceWindowDay day of the week for the maintenance window. possible values: sun, mon, tue, wed, thu, fri, sat. * @param int $maintenanceWindowHourUtc hour in utc (0-23) when the maintenance window starts. * @param bool $metricsEnabled whether metrics collection is enabled. @@ -63,10 +61,12 @@ * @param int $sqlApiMaxBytes maximum serialised sql api result payload in bytes. results larger than this are truncated. * @param int $sqlApiTimeoutSeconds maximum server-side sql api execution time in seconds before the query is cancelled. * @param string $error error message if status is failed. + * @param string|null $api product api that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. + * @param string|null $engine database engine: postgresql, mysql, or mongodb. null until the backing reports one. + * @param int|null $connectionPort database port for connections. derived from the engine when the backing has not reported one yet. + * @param int|null $credentialGeneration committed generation of the primary connection credentials. null until the rotation contract has been initialized. * @param string|null $lastAccessedAt last activity timestamp in iso 8601 format. * @param string|null $idleUntil display-only timestamp when the database is expected to be considered idle (iso 8601 format). derived from last activity; lifecycle transitions are driven by lifecyclestate. - * @param string|null $storageStatus storage resize status. possible values: idle (no resize in flight), resizing (the volume is growing towards storagetargetgb). - * @param int|null $storageTargetGb size in gb the volume is growing towards while storagestatus is resizing. 0 when no resize is in flight. * @param string|null $storageResizeStartedAt time the in-flight storage resize started, in iso 8601 format. */ public function __construct( @@ -75,16 +75,12 @@ public function __construct( public string $updatedAt, public string $projectId, public string $name, - public string $api, - public string $engine, public string $version, public string $specification, public string $backend, public string $hostname, - public int $connectionPort, public string $connectionUser, public string $connectionPassword, - public int $credentialGeneration, public string $connectionString, public bool $ssl, public string $status, @@ -94,6 +90,8 @@ public function __construct( public int $cpu, public int $memory, public int $storage, + public string $storageStatus, + public int $storageTargetGb, public string $storageClass, public int $storageMaxGb, public string $nodePool, @@ -117,10 +115,12 @@ public function __construct( public int $sqlApiMaxBytes, public int $sqlApiTimeoutSeconds, public string $error, + public ?string $api = null, + public ?string $engine = null, + public ?int $connectionPort = null, + public ?int $credentialGeneration = null, public ?string $lastAccessedAt = null, public ?string $idleUntil = null, - public ?string $storageStatus = null, - public ?int $storageTargetGb = null, public ?string $storageResizeStartedAt = null ) { } @@ -151,6 +151,8 @@ public static function from(array $data): static 'cpu' => 500, 'memory' => 512, 'storage' => 10, + 'storageStatus' => "idle", + 'storageTargetGb' => 0, 'storageClass' => "ssd", 'storageMaxGb' => 0, 'nodePool' => "", @@ -176,35 +178,18 @@ public static function from(array $data): static 'error' => "", ]; - if (!array_key_exists('api', $data)) { - throw new \InvalidArgumentException('Missing required field "api" for ' . static::class . '.'); - } - if (!array_key_exists('engine', $data)) { - throw new \InvalidArgumentException('Missing required field "engine" for ' . static::class . '.'); - } - if (!array_key_exists('connectionPort', $data)) { - throw new \InvalidArgumentException('Missing required field "connectionPort" for ' . static::class . '.'); - } - if (!array_key_exists('credentialGeneration', $data)) { - throw new \InvalidArgumentException('Missing required field "credentialGeneration" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], updatedAt: $data['$updatedAt'], projectId: $data['projectId'], name: $data['name'], - api: $data['api'], - engine: $data['engine'], version: $data['version'], specification: $data['specification'], backend: $data['backend'], hostname: $data['hostname'], - connectionPort: $data['connectionPort'], connectionUser: $data['connectionUser'], connectionPassword: $data['connectionPassword'], - credentialGeneration: $data['credentialGeneration'], connectionString: $data['connectionString'], ssl: $data['ssl'], status: $data['status'], @@ -214,6 +199,8 @@ public static function from(array $data): static cpu: $data['cpu'], memory: $data['memory'], storage: $data['storage'], + storageStatus: $data['storageStatus'], + storageTargetGb: $data['storageTargetGb'], storageClass: $data['storageClass'], storageMaxGb: $data['storageMaxGb'], nodePool: $data['nodePool'], @@ -237,10 +224,12 @@ public static function from(array $data): static sqlApiMaxBytes: $data['sqlApiMaxBytes'], sqlApiTimeoutSeconds: $data['sqlApiTimeoutSeconds'], error: $data['error'], + api: $data['api'] ?? null, + engine: $data['engine'] ?? null, + connectionPort: $data['connectionPort'] ?? null, + credentialGeneration: $data['credentialGeneration'] ?? null, lastAccessedAt: $data['lastAccessedAt'] ?? null, idleUntil: $data['idleUntil'] ?? null, - storageStatus: $data['storageStatus'] ?? null, - storageTargetGb: $data['storageTargetGb'] ?? null, storageResizeStartedAt: $data['storageResizeStartedAt'] ?? null ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseBackupList.php b/src/Appwrite/Models/DedicatedDatabaseBackupList.php index fb6b0225..745fe62c 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBackupList.php +++ b/src/Appwrite/Models/DedicatedDatabaseBackupList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'backups' => [], ]; - if (!array_key_exists('backups', $data)) { - throw new \InvalidArgumentException('Missing required field "backups" for ' . static::class . '.'); - } - return new static( total: $data['total'], backups: is_array($data['backups']) diff --git a/src/Appwrite/Models/DedicatedDatabaseBranch.php b/src/Appwrite/Models/DedicatedDatabaseBranch.php index 47704627..7ddfe531 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBranch.php +++ b/src/Appwrite/Models/DedicatedDatabaseBranch.php @@ -21,13 +21,13 @@ * @param string $namespace kubernetes namespace where the branch is deployed. * @param int $expiresAt unix timestamp when the branch expires. * @param string $host branch hostname for direct connections. - * @param int $port branch port. null until the backing reports one. * @param string $database advertised catalog the client connects to. mysql/mariadb use default; postgres uses the routing label. * @param string $username database username. shared with the parent database. * @param string $password database password. shared with the parent database. * @param bool $ssl whether ssl is required. * @param string $engine database engine. possible values: postgresql, mysql, mongodb. * @param string $connectionString full connection string for the branch. + * @param int|null $port branch port. null until the backing reports one. */ public function __construct( public string $branchId, @@ -35,13 +35,13 @@ public function __construct( public string $namespace, public int $expiresAt, public string $host, - public int $port, public string $database, public string $username, public string $password, public bool $ssl, public string $engine, - public string $connectionString + public string $connectionString, + public ?int $port = null ) { } @@ -64,23 +64,19 @@ public static function from(array $data): static 'connectionString' => "", ]; - if (!array_key_exists('port', $data)) { - throw new \InvalidArgumentException('Missing required field "port" for ' . static::class . '.'); - } - return new static( branchId: $data['branchId'], branchName: $data['branchName'], namespace: $data['namespace'], expiresAt: $data['expiresAt'], host: $data['host'], - port: $data['port'], database: $data['database'], username: $data['username'], password: $data['password'], ssl: $data['ssl'], engine: $data['engine'], - connectionString: $data['connectionString'] + connectionString: $data['connectionString'], + port: $data['port'] ?? null ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseBranchList.php b/src/Appwrite/Models/DedicatedDatabaseBranchList.php index 4212a97d..c7bd5afc 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBranchList.php +++ b/src/Appwrite/Models/DedicatedDatabaseBranchList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'branches' => [], ]; - if (!array_key_exists('branches', $data)) { - throw new \InvalidArgumentException('Missing required field "branches" for ' . static::class . '.'); - } - return new static( total: $data['total'], branches: is_array($data['branches']) diff --git a/src/Appwrite/Models/DedicatedDatabaseExecution.php b/src/Appwrite/Models/DedicatedDatabaseExecution.php index 12e54077..283c9897 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExecution.php +++ b/src/Appwrite/Models/DedicatedDatabaseExecution.php @@ -41,15 +41,12 @@ public static function from(array $data): static $data += [ 'rows' => [], 'rowCount' => 0, + 'columns' => [], 'durationMs' => 0, 'truncated' => false, 'bytes' => 0, ]; - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - return new static( rows: $data['rows'], rowCount: $data['rowCount'], diff --git a/src/Appwrite/Models/DedicatedDatabaseExtensions.php b/src/Appwrite/Models/DedicatedDatabaseExtensions.php index b1532138..9f294000 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExtensions.php +++ b/src/Appwrite/Models/DedicatedDatabaseExtensions.php @@ -35,12 +35,9 @@ public static function from(array $data): static $data += [ 'installed' => [], 'available' => [], + 'metadata' => [], ]; - if (!array_key_exists('metadata', $data)) { - throw new \InvalidArgumentException('Missing required field "metadata" for ' . static::class . '.'); - } - return new static( installed: $data['installed'], available: $data['available'], diff --git a/src/Appwrite/Models/DedicatedDatabaseList.php b/src/Appwrite/Models/DedicatedDatabaseList.php index a9784de3..796742c0 100644 --- a/src/Appwrite/Models/DedicatedDatabaseList.php +++ b/src/Appwrite/Models/DedicatedDatabaseList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'databases' => [], ]; - if (!array_key_exists('databases', $data)) { - throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); - } - return new static( total: $data['total'], databases: is_array($data['databases']) diff --git a/src/Appwrite/Models/DedicatedDatabaseOperationList.php b/src/Appwrite/Models/DedicatedDatabaseOperationList.php index 7710285e..c8d97389 100644 --- a/src/Appwrite/Models/DedicatedDatabaseOperationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseOperationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'operations' => [], ]; - if (!array_key_exists('operations', $data)) { - throw new \InvalidArgumentException('Missing required field "operations" for ' . static::class . '.'); - } - return new static( total: $data['total'], operations: is_array($data['operations']) diff --git a/src/Appwrite/Models/DedicatedDatabaseReplicas.php b/src/Appwrite/Models/DedicatedDatabaseReplicas.php index 563630fe..451679fc 100644 --- a/src/Appwrite/Models/DedicatedDatabaseReplicas.php +++ b/src/Appwrite/Models/DedicatedDatabaseReplicas.php @@ -48,12 +48,9 @@ public static function from(array $data): static 'syncDegraded' => false, 'syncAcknowledgements' => 0, 'syncStandbyCount' => 0, + 'members' => [], ]; - if (!array_key_exists('members', $data)) { - throw new \InvalidArgumentException('Missing required field "members" for ' . static::class . '.'); - } - return new static( replicas: $data['replicas'], syncMode: $data['syncMode'], diff --git a/src/Appwrite/Models/DedicatedDatabaseRestoration.php b/src/Appwrite/Models/DedicatedDatabaseRestoration.php index 02927028..8502ddf7 100644 --- a/src/Appwrite/Models/DedicatedDatabaseRestoration.php +++ b/src/Appwrite/Models/DedicatedDatabaseRestoration.php @@ -19,29 +19,31 @@ * @param string $id restoration id. * @param string $createdAt restoration creation time in iso 8601 format. * @param string $databaseId database id being restored into. - * @param string $sourceDatabaseId source database id when restoring a backup into another database. * @param string $projectId project id. - * @param string $backupId backup id used for restoration (null for pitr). * @param string $type restoration type. possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). + * @param string $restoreMode where the backup was restored. possible values: in_place (replayed over the database that took the backup), clone (recovered onto a second workload beside the database, which keeps serving until the clone is promoted onto its endpoint), copy (recovered onto a separate database with its own endpoint). * @param string $status restoration status. possible values: pending (queued for processing), running (currently in progress), completed (successfully finished), failed (encountered an error). - * @param string $targetTime target time for pitr restoration in iso 8601 format. - * @param string $startedAt restoration start time in iso 8601 format. - * @param string $completedAt restoration completion time in iso 8601 format. * @param string $error error message if restoration failed. + * @param string|null $sourceDatabaseId source database id when restoring a backup into another database. + * @param string|null $backupId backup id used for restoration (null for pitr). + * @param string|null $targetTime target time for pitr restoration in iso 8601 format. + * @param string|null $startedAt restoration start time in iso 8601 format. + * @param string|null $completedAt restoration completion time in iso 8601 format. */ public function __construct( public string $id, public string $createdAt, public string $databaseId, - public string $sourceDatabaseId, public string $projectId, - public string $backupId, public string $type, + public string $restoreMode, public string $status, - public string $targetTime, - public string $startedAt, - public string $completedAt, - public string $error + public string $error, + public ?string $sourceDatabaseId = null, + public ?string $backupId = null, + public ?string $targetTime = null, + public ?string $startedAt = null, + public ?string $completedAt = null ) { } @@ -56,39 +58,25 @@ public static function from(array $data): static 'databaseId' => "", 'projectId' => "", 'type' => "backup", + 'restoreMode' => "in_place", 'status' => "pending", 'error' => "", ]; - if (!array_key_exists('sourceDatabaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "sourceDatabaseId" for ' . static::class . '.'); - } - if (!array_key_exists('backupId', $data)) { - throw new \InvalidArgumentException('Missing required field "backupId" for ' . static::class . '.'); - } - if (!array_key_exists('targetTime', $data)) { - throw new \InvalidArgumentException('Missing required field "targetTime" for ' . static::class . '.'); - } - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('completedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "completedAt" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], databaseId: $data['databaseId'], - sourceDatabaseId: $data['sourceDatabaseId'], projectId: $data['projectId'], - backupId: $data['backupId'], type: $data['type'], + restoreMode: $data['restoreMode'], status: $data['status'], - targetTime: $data['targetTime'], - startedAt: $data['startedAt'], - completedAt: $data['completedAt'], - error: $data['error'] + error: $data['error'], + sourceDatabaseId: $data['sourceDatabaseId'] ?? null, + backupId: $data['backupId'] ?? null, + targetTime: $data['targetTime'] ?? null, + startedAt: $data['startedAt'] ?? null, + completedAt: $data['completedAt'] ?? null ); } @@ -105,6 +93,7 @@ public function toArray(): array 'projectId' => static::serializeValue($this->projectId), 'backupId' => static::serializeValue($this->backupId), 'type' => static::serializeValue($this->type), + 'restoreMode' => static::serializeValue($this->restoreMode), 'status' => static::serializeValue($this->status), 'targetTime' => static::serializeValue($this->targetTime), 'startedAt' => static::serializeValue($this->startedAt), diff --git a/src/Appwrite/Models/DedicatedDatabaseRestorationList.php b/src/Appwrite/Models/DedicatedDatabaseRestorationList.php index b4491a49..b599e127 100644 --- a/src/Appwrite/Models/DedicatedDatabaseRestorationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseRestorationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'restorations' => [], ]; - if (!array_key_exists('restorations', $data)) { - throw new \InvalidArgumentException('Missing required field "restorations" for ' . static::class . '.'); - } - return new static( total: $data['total'], restorations: is_array($data['restorations']) diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecification.php b/src/Appwrite/Models/DedicatedDatabaseSpecification.php index a4612cc0..aa10cd8e 100644 --- a/src/Appwrite/Models/DedicatedDatabaseSpecification.php +++ b/src/Appwrite/Models/DedicatedDatabaseSpecification.php @@ -19,31 +19,31 @@ * @param string $slug specification slug. use this value when creating a dedicated database. * @param string $name human readable specification name. * @param float $price monthly price of the specification in usd. + * @param float $storageOverageRate price per gb of storage above the included amount, per month, in usd. + * @param float $bandwidthOverageRate price per gb of bandwidth above the included amount, per month, in usd. + * @param float $replicaRate high availability replica price as a fraction of the specification price. + * @param float $pitrRate point-in-time recovery price as a fraction of the specification price. * @param int $cpu allocated cpu in millicores. * @param int $memory allocated memory in mb. * @param int $maxConnections maximum number of concurrent connections. * @param int $includedStorage included storage in gb before overage charges apply. * @param int $includedBandwidth included bandwidth in gb before overage charges apply. * @param bool $enabled whether the specification is available on the current plan. - * @param float|null $storageOverageRate price per gb of storage above the included amount, per month, in usd. - * @param float|null $bandwidthOverageRate price per gb of bandwidth above the included amount, per month, in usd. - * @param float|null $replicaRate high availability replica price as a fraction of the specification price. - * @param float|null $pitrRate point-in-time recovery price as a fraction of the specification price. */ public function __construct( public string $slug, public string $name, public float $price, + public float $storageOverageRate, + public float $bandwidthOverageRate, + public float $replicaRate, + public float $pitrRate, public int $cpu, public int $memory, public int $maxConnections, public int $includedStorage, public int $includedBandwidth, - public bool $enabled, - public ?float $storageOverageRate = null, - public ?float $bandwidthOverageRate = null, - public ?float $replicaRate = null, - public ?float $pitrRate = null + public bool $enabled ) { } @@ -56,6 +56,10 @@ public static function from(array $data): static 'slug' => "", 'name' => "", 'price' => 0, + 'storageOverageRate' => 0, + 'bandwidthOverageRate' => 0, + 'replicaRate' => 0, + 'pitrRate' => 0, 'cpu' => 0, 'memory' => 0, 'maxConnections' => 0, @@ -68,16 +72,16 @@ public static function from(array $data): static slug: $data['slug'], name: $data['name'], price: $data['price'], + storageOverageRate: $data['storageOverageRate'], + bandwidthOverageRate: $data['bandwidthOverageRate'], + replicaRate: $data['replicaRate'], + pitrRate: $data['pitrRate'], cpu: $data['cpu'], memory: $data['memory'], maxConnections: $data['maxConnections'], includedStorage: $data['includedStorage'], includedBandwidth: $data['includedBandwidth'], - enabled: $data['enabled'], - storageOverageRate: $data['storageOverageRate'] ?? null, - bandwidthOverageRate: $data['bandwidthOverageRate'] ?? null, - replicaRate: $data['replicaRate'] ?? null, - pitrRate: $data['pitrRate'] ?? null + enabled: $data['enabled'] ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php b/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php index 9ac12067..3f3aca02 100644 --- a/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php @@ -18,12 +18,10 @@ * * @param list $specifications list of dedicated database specifications. * @param int $total total number of specifications. - * @param DedicatedDatabaseSpecificationPricing $pricing overage and add-on pricing shared across all specifications. */ public function __construct( public array $specifications, - public int $total, - public DedicatedDatabaseSpecificationPricing $pricing + public int $total ) { } @@ -33,16 +31,10 @@ public function __construct( public static function from(array $data): static { $data += [ + 'specifications' => [], 'total' => 0, ]; - if (!array_key_exists('specifications', $data)) { - throw new \InvalidArgumentException('Missing required field "specifications" for ' . static::class . '.'); - } - if (!array_key_exists('pricing', $data)) { - throw new \InvalidArgumentException('Missing required field "pricing" for ' . static::class . '.'); - } - return new static( specifications: is_array($data['specifications']) ? array_map( @@ -50,8 +42,7 @@ public static function from(array $data): static $data['specifications'] ) : $data['specifications'], - total: $data['total'], - pricing: static::hydrateTypedValue(DedicatedDatabaseSpecificationPricing::class, $data['pricing']) + total: $data['total'] ); } @@ -62,8 +53,7 @@ public function toArray(): array { return [ 'specifications' => static::serializeValue($this->specifications), - 'total' => static::serializeValue($this->total), - 'pricing' => static::serializeValue($this->pricing) + 'total' => static::serializeValue($this->total) ]; } } diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php b/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php deleted file mode 100644 index c8a11f5f..00000000 --- a/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php +++ /dev/null @@ -1,70 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('storageOverageRate', $data)) { - throw new \InvalidArgumentException('Missing required field "storageOverageRate" for ' . static::class . '.'); - } - if (!array_key_exists('bandwidthOverageRate', $data)) { - throw new \InvalidArgumentException('Missing required field "bandwidthOverageRate" for ' . static::class . '.'); - } - if (!array_key_exists('replicaRate', $data)) { - throw new \InvalidArgumentException('Missing required field "replicaRate" for ' . static::class . '.'); - } - if (!array_key_exists('pitrRate', $data)) { - throw new \InvalidArgumentException('Missing required field "pitrRate" for ' . static::class . '.'); - } - - return new static( - storageOverageRate: $data['storageOverageRate'], - bandwidthOverageRate: $data['bandwidthOverageRate'], - replicaRate: $data['replicaRate'], - pitrRate: $data['pitrRate'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'storageOverageRate' => static::serializeValue($this->storageOverageRate), - 'bandwidthOverageRate' => static::serializeValue($this->bandwidthOverageRate), - 'replicaRate' => static::serializeValue($this->replicaRate), - 'pitrRate' => static::serializeValue($this->pitrRate) - ]; - } -} diff --git a/src/Appwrite/Models/DeploymentList.php b/src/Appwrite/Models/DeploymentList.php index 84e99d1e..cd39aa38 100644 --- a/src/Appwrite/Models/DeploymentList.php +++ b/src/Appwrite/Models/DeploymentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'deployments' => [], ]; - if (!array_key_exists('deployments', $data)) { - throw new \InvalidArgumentException('Missing required field "deployments" for ' . static::class . '.'); - } - return new static( total: $data['total'], deployments: is_array($data['deployments']) diff --git a/src/Appwrite/Models/DevKey.php b/src/Appwrite/Models/DevKey.php deleted file mode 100644 index 971c16fa..00000000 --- a/src/Appwrite/Models/DevKey.php +++ /dev/null @@ -1,98 +0,0 @@ - $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('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - - return new static( - id: $data['$id'], - createdAt: $data['$createdAt'], - updatedAt: $data['$updatedAt'], - name: $data['name'], - expire: $data['expire'], - secret: $data['secret'], - accessedAt: $data['accessedAt'], - sdks: $data['sdks'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - '$id' => static::serializeValue($this->id), - '$createdAt' => static::serializeValue($this->createdAt), - '$updatedAt' => static::serializeValue($this->updatedAt), - 'name' => static::serializeValue($this->name), - 'expire' => static::serializeValue($this->expire), - 'secret' => static::serializeValue($this->secret), - 'accessedAt' => static::serializeValue($this->accessedAt), - 'sdks' => static::serializeValue($this->sdks) - ]; - } -} diff --git a/src/Appwrite/Models/Document.php b/src/Appwrite/Models/Document.php index b0cf5b9c..fa1231f8 100644 --- a/src/Appwrite/Models/Document.php +++ b/src/Appwrite/Models/Document.php @@ -49,12 +49,9 @@ public static function from(array $data): static '$databaseId' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - $additionalProperties = static::extractAdditionalPropertiesFromFields( $data, [ diff --git a/src/Appwrite/Models/DocumentList.php b/src/Appwrite/Models/DocumentList.php index 8a34e498..68bfb14e 100644 --- a/src/Appwrite/Models/DocumentList.php +++ b/src/Appwrite/Models/DocumentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'documents' => [], ]; - if (!array_key_exists('documents', $data)) { - throw new \InvalidArgumentException('Missing required field "documents" for ' . static::class . '.'); - } - return new static( total: $data['total'], documents: is_array($data['documents']) diff --git a/src/Appwrite/Models/EmailTemplateList.php b/src/Appwrite/Models/EmailTemplateList.php index 934220ab..015cc0db 100644 --- a/src/Appwrite/Models/EmailTemplateList.php +++ b/src/Appwrite/Models/EmailTemplateList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'templates' => [], ]; - if (!array_key_exists('templates', $data)) { - throw new \InvalidArgumentException('Missing required field "templates" for ' . static::class . '.'); - } - return new static( total: $data['total'], templates: is_array($data['templates']) diff --git a/src/Appwrite/Models/EmbeddingList.php b/src/Appwrite/Models/EmbeddingList.php index dde35f28..7e362a18 100644 --- a/src/Appwrite/Models/EmbeddingList.php +++ b/src/Appwrite/Models/EmbeddingList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'embeddings' => [], ]; - if (!array_key_exists('embeddings', $data)) { - throw new \InvalidArgumentException('Missing required field "embeddings" for ' . static::class . '.'); - } - return new static( total: $data['total'], embeddings: is_array($data['embeddings']) diff --git a/src/Appwrite/Models/EphemeralKey.php b/src/Appwrite/Models/EphemeralKey.php index 0709c91c..c338f61e 100644 --- a/src/Appwrite/Models/EphemeralKey.php +++ b/src/Appwrite/Models/EphemeralKey.php @@ -53,12 +53,9 @@ public static function from(array $data): static 'scopes' => [], 'secret' => "", 'accessedAt' => "", + 'sdks' => [], ]; - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/Execution.php b/src/Appwrite/Models/Execution.php index 8ac7d6fa..1b462770 100644 --- a/src/Appwrite/Models/Execution.php +++ b/src/Appwrite/Models/Execution.php @@ -27,7 +27,7 @@ * @param string $resourceId function or site id. * @param ExecutionResourceType $resourceType execution resource type. * @param string $deploymentId deployment id used to create the execution. - * @param ExecutionTrigger $trigger the trigger that caused the resource to execute. possible values can be: `http`, `schedule`, or `event`. + * @param ExecutionTrigger $trigger the trigger that caused the resource to execute. possible values can be: `http`, `schedule`, `event`, or `email`. * @param ExecutionStatus $status the status of the resource execution. possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. * @param string $requestMethod http request method type. * @param string $requestPath http request path and query. @@ -37,7 +37,7 @@ * @param list $responseHeaders http response headers as a key-value object. this will return only whitelisted headers. all headers are returned if execution is created as synchronous. * @param string $logs resource logs. includes the last 4,000 characters. this will return an empty string unless the response is returned using an api key or as part of a webhook payload. * @param string $errors resource errors. includes the last 4,000 characters. this will return an empty string unless the response is returned using an api key or as part of a webhook payload. - * @param float $duration resource(function/site) execution duration in seconds. + * @param float $duration total time the resource(function/site) took to respond, in seconds. * @param string|null $scheduledAt the scheduled time for execution. if left empty, execution will be queued immediately. */ public function __construct( @@ -72,33 +72,27 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'resourceId' => "", 'resourceType' => "functions", 'deploymentId' => "", 'requestMethod' => "", 'requestPath' => "", + 'requestHeaders' => [], 'responseStatusCode' => 0, 'responseBody' => "", + 'responseHeaders' => [], 'logs' => "", 'errors' => "", 'duration' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } if (!array_key_exists('trigger', $data)) { throw new \InvalidArgumentException('Missing required field "trigger" for ' . static::class . '.'); } if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('requestHeaders', $data)) { - throw new \InvalidArgumentException('Missing required field "requestHeaders" for ' . static::class . '.'); - } - if (!array_key_exists('responseHeaders', $data)) { - throw new \InvalidArgumentException('Missing required field "responseHeaders" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/ExecutionList.php b/src/Appwrite/Models/ExecutionList.php index ee91c286..2b164511 100644 --- a/src/Appwrite/Models/ExecutionList.php +++ b/src/Appwrite/Models/ExecutionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'executions' => [], ]; - if (!array_key_exists('executions', $data)) { - throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.'); - } - return new static( total: $data['total'], executions: is_array($data['executions']) diff --git a/src/Appwrite/Models/FileList.php b/src/Appwrite/Models/FileList.php index f934a390..cab60fc5 100644 --- a/src/Appwrite/Models/FileList.php +++ b/src/Appwrite/Models/FileList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'files' => [], ]; - if (!array_key_exists('files', $data)) { - throw new \InvalidArgumentException('Missing required field "files" for ' . static::class . '.'); - } - return new static( total: $data['total'], files: is_array($data['files']) diff --git a/src/Appwrite/Models/Framework.php b/src/Appwrite/Models/Framework.php index 7c3efaff..20a43d42 100644 --- a/src/Appwrite/Models/Framework.php +++ b/src/Appwrite/Models/Framework.php @@ -40,15 +40,10 @@ public static function from(array $data): static 'key' => "", 'name' => "", 'buildRuntime' => "", + 'runtimes' => [], + 'adapters' => [], ]; - if (!array_key_exists('runtimes', $data)) { - throw new \InvalidArgumentException('Missing required field "runtimes" for ' . static::class . '.'); - } - if (!array_key_exists('adapters', $data)) { - throw new \InvalidArgumentException('Missing required field "adapters" for ' . static::class . '.'); - } - return new static( key: $data['key'], name: $data['name'], diff --git a/src/Appwrite/Models/FrameworkList.php b/src/Appwrite/Models/FrameworkList.php index 8188732e..9397daa1 100644 --- a/src/Appwrite/Models/FrameworkList.php +++ b/src/Appwrite/Models/FrameworkList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'frameworks' => [], ]; - if (!array_key_exists('frameworks', $data)) { - throw new \InvalidArgumentException('Missing required field "frameworks" for ' . static::class . '.'); - } - return new static( total: $data['total'], frameworks: is_array($data['frameworks']) diff --git a/src/Appwrite/Models/FunctionList.php b/src/Appwrite/Models/FunctionList.php index e5f38db1..39fca279 100644 --- a/src/Appwrite/Models/FunctionList.php +++ b/src/Appwrite/Models/FunctionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'functions' => [], ]; - if (!array_key_exists('functions', $data)) { - throw new \InvalidArgumentException('Missing required field "functions" for ' . static::class . '.'); - } - return new static( total: $data['total'], functions: is_array($data['functions']) diff --git a/src/Appwrite/Models/FunctionModel.php b/src/Appwrite/Models/FunctionModel.php index a6fbc219..f582965b 100644 --- a/src/Appwrite/Models/FunctionModel.php +++ b/src/Appwrite/Models/FunctionModel.php @@ -49,6 +49,7 @@ * @param string $buildSpecification machine specification for deployment builds. * @param string $runtimeSpecification machine specification for executions. * @param int|null $interval minutes between scheduled executions. 0 when the function has no interval. + * @param bool|null $emailEnabled whether inbound email (smtp) may trigger this function. opt-in; default is false. when disabled, recipients for this function are rejected. */ public function __construct( public string $id, @@ -83,7 +84,8 @@ public function __construct( public array $providerPaths, public string $buildSpecification, public string $runtimeSpecification, - public ?int $interval = null + public ?int $interval = null, + public ?bool $emailEnabled = null ) { } @@ -109,6 +111,7 @@ public static function from(array $data): static 'latestDeploymentCreatedAt' => "", 'latestDeploymentStatus' => "", 'scopes' => [], + 'vars' => [], 'events' => [], 'schedule' => "", 'timeout' => 15, @@ -126,10 +129,6 @@ public static function from(array $data): static 'runtimeSpecification' => "s-1vcpu-512mb", ]; - if (!array_key_exists('vars', $data)) { - throw new \InvalidArgumentException('Missing required field "vars" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], @@ -168,7 +167,8 @@ public static function from(array $data): static providerPaths: $data['providerPaths'], buildSpecification: $data['buildSpecification'], runtimeSpecification: $data['runtimeSpecification'], - interval: $data['interval'] ?? null + interval: $data['interval'] ?? null, + emailEnabled: $data['emailEnabled'] ?? null ); } @@ -210,7 +210,8 @@ public function toArray(): array 'providerBranches' => static::serializeValue($this->providerBranches), 'providerPaths' => static::serializeValue($this->providerPaths), 'buildSpecification' => static::serializeValue($this->buildSpecification), - 'runtimeSpecification' => static::serializeValue($this->runtimeSpecification) + 'runtimeSpecification' => static::serializeValue($this->runtimeSpecification), + 'emailEnabled' => static::serializeValue($this->emailEnabled) ]; } } diff --git a/src/Appwrite/Models/Identity.php b/src/Appwrite/Models/Identity.php index 7b208ff5..d7cc7c47 100644 --- a/src/Appwrite/Models/Identity.php +++ b/src/Appwrite/Models/Identity.php @@ -26,7 +26,7 @@ * @param string $providerAccessToken identity provider access token. * @param string $providerAccessTokenExpiry the date of when the access token expires in iso 8601 format. * @param string $providerRefreshToken identity provider refresh token. - * @param string|null $providerIdToken identity provider id token (jwt) from the most recent native sign-in. empty for identities created through the browser oauth2 flow. + * @param string $providerIdToken identity provider id token (jwt) from the most recent native sign-in. empty for identities created through the browser oauth2 flow. */ public function __construct( public string $id, @@ -39,7 +39,7 @@ public function __construct( public string $providerAccessToken, public string $providerAccessTokenExpiry, public string $providerRefreshToken, - public ?string $providerIdToken = null + public string $providerIdToken ) { } @@ -59,6 +59,7 @@ public static function from(array $data): static 'providerAccessToken' => "", 'providerAccessTokenExpiry' => "", 'providerRefreshToken' => "", + 'providerIdToken' => "", ]; return new static( @@ -72,7 +73,7 @@ public static function from(array $data): static providerAccessToken: $data['providerAccessToken'], providerAccessTokenExpiry: $data['providerAccessTokenExpiry'], providerRefreshToken: $data['providerRefreshToken'], - providerIdToken: $data['providerIdToken'] ?? null + providerIdToken: $data['providerIdToken'] ); } diff --git a/src/Appwrite/Models/IdentityList.php b/src/Appwrite/Models/IdentityList.php index f16cced6..d999ce18 100644 --- a/src/Appwrite/Models/IdentityList.php +++ b/src/Appwrite/Models/IdentityList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'identities' => [], ]; - if (!array_key_exists('identities', $data)) { - throw new \InvalidArgumentException('Missing required field "identities" for ' . static::class . '.'); - } - return new static( total: $data['total'], identities: is_array($data['identities']) diff --git a/src/Appwrite/Models/IndexList.php b/src/Appwrite/Models/IndexList.php index 4f2fbb8e..b9c1b65d 100644 --- a/src/Appwrite/Models/IndexList.php +++ b/src/Appwrite/Models/IndexList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'indexes' => [], ]; - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( total: $data['total'], indexes: is_array($data['indexes']) diff --git a/src/Appwrite/Models/Insight.php b/src/Appwrite/Models/Insight.php index b5b50f95..f05df485 100644 --- a/src/Appwrite/Models/Insight.php +++ b/src/Appwrite/Models/Insight.php @@ -74,12 +74,9 @@ public static function from(array $data): static 'parentResourceId' => "", 'title' => "", 'summary' => "", + 'ctas' => [], ]; - if (!array_key_exists('ctas', $data)) { - throw new \InvalidArgumentException('Missing required field "ctas" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/InsightList.php b/src/Appwrite/Models/InsightList.php index dfa3e4a9..3eee4fe6 100644 --- a/src/Appwrite/Models/InsightList.php +++ b/src/Appwrite/Models/InsightList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'insights' => [], ]; - if (!array_key_exists('insights', $data)) { - throw new \InvalidArgumentException('Missing required field "insights" for ' . static::class . '.'); - } - return new static( total: $data['total'], insights: is_array($data['insights']) diff --git a/src/Appwrite/Models/Key.php b/src/Appwrite/Models/Key.php index 216deb87..6b8e6841 100644 --- a/src/Appwrite/Models/Key.php +++ b/src/Appwrite/Models/Key.php @@ -53,12 +53,9 @@ public static function from(array $data): static 'scopes' => [], 'secret' => "", 'accessedAt' => "", + 'sdks' => [], ]; - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/KeyList.php b/src/Appwrite/Models/KeyList.php index 042450fb..92c164b9 100644 --- a/src/Appwrite/Models/KeyList.php +++ b/src/Appwrite/Models/KeyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'keys' => [], ]; - if (!array_key_exists('keys', $data)) { - throw new \InvalidArgumentException('Missing required field "keys" for ' . static::class . '.'); - } - return new static( total: $data['total'], keys: is_array($data['keys']) diff --git a/src/Appwrite/Models/LanguageList.php b/src/Appwrite/Models/LanguageList.php index 6a57c4b8..7cf1275f 100644 --- a/src/Appwrite/Models/LanguageList.php +++ b/src/Appwrite/Models/LanguageList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'languages' => [], ]; - if (!array_key_exists('languages', $data)) { - throw new \InvalidArgumentException('Missing required field "languages" for ' . static::class . '.'); - } - return new static( total: $data['total'], languages: is_array($data['languages']) diff --git a/src/Appwrite/Models/LocaleCodeList.php b/src/Appwrite/Models/LocaleCodeList.php index 59223a66..a9f1dfcd 100644 --- a/src/Appwrite/Models/LocaleCodeList.php +++ b/src/Appwrite/Models/LocaleCodeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'localeCodes' => [], ]; - if (!array_key_exists('localeCodes', $data)) { - throw new \InvalidArgumentException('Missing required field "localeCodes" for ' . static::class . '.'); - } - return new static( total: $data['total'], localeCodes: is_array($data['localeCodes']) diff --git a/src/Appwrite/Models/Log.php b/src/Appwrite/Models/Log.php deleted file mode 100644 index 01bfb02f..00000000 --- a/src/Appwrite/Models/Log.php +++ /dev/null @@ -1,196 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('event', $data)) { - throw new \InvalidArgumentException('Missing required field "event" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('userEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "userEmail" for ' . static::class . '.'); - } - if (!array_key_exists('userName', $data)) { - throw new \InvalidArgumentException('Missing required field "userName" for ' . static::class . '.'); - } - if (!array_key_exists('mode', $data)) { - throw new \InvalidArgumentException('Missing required field "mode" for ' . static::class . '.'); - } - if (!array_key_exists('userType', $data)) { - throw new \InvalidArgumentException('Missing required field "userType" for ' . static::class . '.'); - } - if (!array_key_exists('ip', $data)) { - throw new \InvalidArgumentException('Missing required field "ip" for ' . static::class . '.'); - } - if (!array_key_exists('time', $data)) { - throw new \InvalidArgumentException('Missing required field "time" for ' . static::class . '.'); - } - if (!array_key_exists('osCode', $data)) { - throw new \InvalidArgumentException('Missing required field "osCode" for ' . static::class . '.'); - } - if (!array_key_exists('osName', $data)) { - throw new \InvalidArgumentException('Missing required field "osName" for ' . static::class . '.'); - } - if (!array_key_exists('osVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "osVersion" for ' . static::class . '.'); - } - if (!array_key_exists('clientType', $data)) { - throw new \InvalidArgumentException('Missing required field "clientType" for ' . static::class . '.'); - } - if (!array_key_exists('clientCode', $data)) { - throw new \InvalidArgumentException('Missing required field "clientCode" for ' . static::class . '.'); - } - if (!array_key_exists('clientName', $data)) { - throw new \InvalidArgumentException('Missing required field "clientName" for ' . static::class . '.'); - } - if (!array_key_exists('clientVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "clientVersion" for ' . static::class . '.'); - } - if (!array_key_exists('clientEngine', $data)) { - throw new \InvalidArgumentException('Missing required field "clientEngine" for ' . static::class . '.'); - } - if (!array_key_exists('clientEngineVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "clientEngineVersion" for ' . static::class . '.'); - } - if (!array_key_exists('deviceName', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceName" for ' . static::class . '.'); - } - if (!array_key_exists('deviceBrand', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceBrand" for ' . static::class . '.'); - } - if (!array_key_exists('deviceModel', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceModel" 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( - event: $data['event'], - userId: $data['userId'], - userEmail: $data['userEmail'], - userName: $data['userName'], - mode: $data['mode'], - userType: $data['userType'], - ip: $data['ip'], - time: $data['time'], - osCode: $data['osCode'], - osName: $data['osName'], - osVersion: $data['osVersion'], - clientType: $data['clientType'], - clientCode: $data['clientCode'], - clientName: $data['clientName'], - clientVersion: $data['clientVersion'], - clientEngine: $data['clientEngine'], - clientEngineVersion: $data['clientEngineVersion'], - deviceName: $data['deviceName'], - deviceBrand: $data['deviceBrand'], - deviceModel: $data['deviceModel'], - countryCode: $data['countryCode'], - countryName: $data['countryName'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'event' => static::serializeValue($this->event), - 'userId' => static::serializeValue($this->userId), - 'userEmail' => static::serializeValue($this->userEmail), - 'userName' => static::serializeValue($this->userName), - 'mode' => static::serializeValue($this->mode), - 'userType' => static::serializeValue($this->userType), - 'ip' => static::serializeValue($this->ip), - 'time' => static::serializeValue($this->time), - 'osCode' => static::serializeValue($this->osCode), - 'osName' => static::serializeValue($this->osName), - 'osVersion' => static::serializeValue($this->osVersion), - 'clientType' => static::serializeValue($this->clientType), - 'clientCode' => static::serializeValue($this->clientCode), - 'clientName' => static::serializeValue($this->clientName), - 'clientVersion' => static::serializeValue($this->clientVersion), - 'clientEngine' => static::serializeValue($this->clientEngine), - 'clientEngineVersion' => static::serializeValue($this->clientEngineVersion), - 'deviceName' => static::serializeValue($this->deviceName), - 'deviceBrand' => static::serializeValue($this->deviceBrand), - 'deviceModel' => static::serializeValue($this->deviceModel), - 'countryCode' => static::serializeValue($this->countryCode), - 'countryName' => static::serializeValue($this->countryName) - ]; - } -} diff --git a/src/Appwrite/Models/LogList.php b/src/Appwrite/Models/LogList.php deleted file mode 100644 index 944b82ca..00000000 --- a/src/Appwrite/Models/LogList.php +++ /dev/null @@ -1,61 +0,0 @@ - $logs list of logs. - */ - public function __construct( - public int $total, - public array $logs - ) { - } - - /** - * @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('logs', $data)) { - throw new \InvalidArgumentException('Missing required field "logs" for ' . static::class . '.'); - } - - return new static( - total: $data['total'], - logs: is_array($data['logs']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(Log::class, $item), - $data['logs'] - ) - : $data['logs'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'total' => static::serializeValue($this->total), - 'logs' => static::serializeValue($this->logs) - ]; - } -} diff --git a/src/Appwrite/Models/MembershipList.php b/src/Appwrite/Models/MembershipList.php index 48529162..ece0e4b1 100644 --- a/src/Appwrite/Models/MembershipList.php +++ b/src/Appwrite/Models/MembershipList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'memberships' => [], ]; - if (!array_key_exists('memberships', $data)) { - throw new \InvalidArgumentException('Missing required field "memberships" for ' . static::class . '.'); - } - return new static( total: $data['total'], memberships: is_array($data['memberships']) diff --git a/src/Appwrite/Models/Message.php b/src/Appwrite/Models/Message.php index 267901bc..3d6ea590 100644 --- a/src/Appwrite/Models/Message.php +++ b/src/Appwrite/Models/Message.php @@ -59,21 +59,14 @@ public static function from(array $data): static '$createdAt' => "", '$updatedAt' => "", 'providerType' => "", + 'topics' => [], + 'users' => [], + 'targets' => [], 'deliveredTotal' => 0, 'data' => [], 'status' => "draft", ]; - if (!array_key_exists('topics', $data)) { - throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); - } - if (!array_key_exists('users', $data)) { - throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); - } - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/MessageList.php b/src/Appwrite/Models/MessageList.php index ea36b3e9..0f341543 100644 --- a/src/Appwrite/Models/MessageList.php +++ b/src/Appwrite/Models/MessageList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'messages' => [], ]; - if (!array_key_exists('messages', $data)) { - throw new \InvalidArgumentException('Missing required field "messages" for ' . static::class . '.'); - } - return new static( total: $data['total'], messages: is_array($data['messages']) diff --git a/src/Appwrite/Models/MockNumberList.php b/src/Appwrite/Models/MockNumberList.php index 60291620..b444d1b0 100644 --- a/src/Appwrite/Models/MockNumberList.php +++ b/src/Appwrite/Models/MockNumberList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'mockNumbers' => [], ]; - if (!array_key_exists('mockNumbers', $data)) { - throw new \InvalidArgumentException('Missing required field "mockNumbers" for ' . static::class . '.'); - } - return new static( total: $data['total'], mockNumbers: is_array($data['mockNumbers']) diff --git a/src/Appwrite/Models/OAuth2Apple.php b/src/Appwrite/Models/OAuth2Apple.php index 91b6b61c..0e9d8915 100644 --- a/src/Appwrite/Models/OAuth2Apple.php +++ b/src/Appwrite/Models/OAuth2Apple.php @@ -22,8 +22,8 @@ * @param string $keyId apple oauth2 key id. * @param string $teamId apple oauth2 team id. * @param string $p8File apple oauth2 .p8 private key file contents. the secret key wrapped by the pem markers is 200 characters long. - * @param bool|null $nativeEnabled native sign in with apple is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. - * @param array|null $nativeClientIds app bundle ids accepted as id token audiences for native sign in with apple, next to the services id. + * @param bool $nativeEnabled native sign in with apple is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. + * @param array $nativeClientIds app bundle ids accepted as id token audiences for native sign in with apple, next to the services id. */ public function __construct( public string $id, @@ -32,8 +32,8 @@ public function __construct( public string $keyId, public string $teamId, public string $p8File, - public ?bool $nativeEnabled = null, - public ?array $nativeClientIds = null + public bool $nativeEnabled, + public array $nativeClientIds ) { } @@ -49,6 +49,8 @@ public static function from(array $data): static 'keyId' => "", 'teamId' => "", 'p8File' => "", + 'nativeEnabled' => false, + 'nativeClientIds' => [], ]; return new static( @@ -58,8 +60,8 @@ public static function from(array $data): static keyId: $data['keyId'], teamId: $data['teamId'], p8File: $data['p8File'], - nativeEnabled: $data['nativeEnabled'] ?? null, - nativeClientIds: $data['nativeClientIds'] ?? null + nativeEnabled: $data['nativeEnabled'], + nativeClientIds: $data['nativeClientIds'] ); } diff --git a/src/Appwrite/Models/OAuth2Auth0.php b/src/Appwrite/Models/OAuth2Auth0.php index 2e119529..f76d028f 100644 --- a/src/Appwrite/Models/OAuth2Auth0.php +++ b/src/Appwrite/Models/OAuth2Auth0.php @@ -22,16 +22,16 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId auth0 oauth2 client id. * @param string $clientSecret auth0 oauth2 client secret. + * @param list $prompt auth0 oauth2 prompt values. * @param string $endpoint auth0 oauth2 endpoint domain. - * @param list|null $prompt auth0 oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public string $endpoint, - public ?array $prompt = null + public array $prompt, + public string $endpoint ) { } @@ -45,6 +45,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'endpoint' => "", ]; @@ -53,17 +54,13 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - endpoint: $data['endpoint'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2Auth0Prompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2Auth0Prompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2Auth0Prompt::class, $data['prompt'])], + endpoint: $data['endpoint'] ); } diff --git a/src/Appwrite/Models/OAuth2Discord.php b/src/Appwrite/Models/OAuth2Discord.php index 34d4d3d0..ce554f36 100644 --- a/src/Appwrite/Models/OAuth2Discord.php +++ b/src/Appwrite/Models/OAuth2Discord.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId discord oauth2 client id. * @param string $clientSecret discord oauth2 client secret. - * @param list|null $prompt discord oauth2 prompt values. + * @param list $prompt discord oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2DiscordPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2DiscordPrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2DiscordPrompt::class, $data['prompt'])] ); } diff --git a/src/Appwrite/Models/OAuth2Github.php b/src/Appwrite/Models/OAuth2Github.php index 3e40437f..b7b2e1c0 100644 --- a/src/Appwrite/Models/OAuth2Github.php +++ b/src/Appwrite/Models/OAuth2Github.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId github oauth2 client id. for github apps, use the "app id" when both an app id and client id are available. * @param string $clientSecret github oauth2 client secret. - * @param list|null $prompt github oauth2 prompt values. + * @param list $prompt github oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GithubPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GithubPrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2GithubPrompt::class, $data['prompt'])] ); } diff --git a/src/Appwrite/Models/OAuth2Google.php b/src/Appwrite/Models/OAuth2Google.php index ac2a6bef..8f6e47b8 100644 --- a/src/Appwrite/Models/OAuth2Google.php +++ b/src/Appwrite/Models/OAuth2Google.php @@ -23,8 +23,8 @@ * @param string $clientId google oauth2 client id. * @param string $clientSecret google oauth2 client secret. * @param list $prompt google oauth2 prompt values. - * @param bool|null $nativeEnabled native google sign-in is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. - * @param array|null $nativeClientIds additional oauth2 client ids accepted as id token audiences for native sign-in, next to the client id. + * @param bool $nativeEnabled native google sign-in is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. + * @param array $nativeClientIds additional oauth2 client ids accepted as id token audiences for native sign-in, next to the client id. */ public function __construct( public string $id, @@ -32,8 +32,8 @@ public function __construct( public string $clientId, public string $clientSecret, public array $prompt, - public ?bool $nativeEnabled = null, - public ?array $nativeClientIds = null + public bool $nativeEnabled, + public array $nativeClientIds ) { } @@ -48,6 +48,8 @@ public static function from(array $data): static 'clientId' => "", 'clientSecret' => "", 'prompt' => ["consent"], + 'nativeEnabled' => false, + 'nativeClientIds' => [], ]; return new static( @@ -60,9 +62,9 @@ public static function from(array $data): static static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GooglePrompt::class, $item), $data['prompt'] ) - : $data['prompt'], - nativeEnabled: $data['nativeEnabled'] ?? null, - nativeClientIds: $data['nativeClientIds'] ?? null + : [static::hydrateTypedValue(OAuth2GooglePrompt::class, $data['prompt'])], + nativeEnabled: $data['nativeEnabled'], + nativeClientIds: $data['nativeClientIds'] ); } diff --git a/src/Appwrite/Models/OAuth2Kakao.php b/src/Appwrite/Models/OAuth2Kakao.php index 2d329b74..c1f3264d 100644 --- a/src/Appwrite/Models/OAuth2Kakao.php +++ b/src/Appwrite/Models/OAuth2Kakao.php @@ -56,7 +56,7 @@ public static function from(array $data): static static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2KakaoPrompt::class, $item), $data['prompt'] ) - : $data['prompt'] + : [static::hydrateTypedValue(OAuth2KakaoPrompt::class, $data['prompt'])] ); } diff --git a/src/Appwrite/Models/OAuth2Microsoft.php b/src/Appwrite/Models/OAuth2Microsoft.php index 12cddc22..ad51fd2c 100644 --- a/src/Appwrite/Models/OAuth2Microsoft.php +++ b/src/Appwrite/Models/OAuth2Microsoft.php @@ -22,16 +22,16 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $applicationId microsoft oauth2 application id. * @param string $applicationSecret microsoft oauth2 application secret. + * @param list $prompt microsoft oauth2 prompt values. * @param string $tenant microsoft entra id tenant identifier. use 'common', 'organizations', 'consumers' or a specific tenant id. - * @param list|null $prompt microsoft oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $applicationId, public string $applicationSecret, - public string $tenant, - public ?array $prompt = null + public array $prompt, + public string $tenant ) { } @@ -45,6 +45,7 @@ public static function from(array $data): static 'enabled' => false, 'applicationId' => "", 'applicationSecret' => "", + 'prompt' => [], 'tenant' => "", ]; @@ -53,17 +54,13 @@ public static function from(array $data): static enabled: $data['enabled'], applicationId: $data['applicationId'], applicationSecret: $data['applicationSecret'], - tenant: $data['tenant'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2MicrosoftPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2MicrosoftPrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2MicrosoftPrompt::class, $data['prompt'])], + tenant: $data['tenant'] ); } diff --git a/src/Appwrite/Models/OAuth2Oidc.php b/src/Appwrite/Models/OAuth2Oidc.php index 3f4a32f6..a7602e43 100644 --- a/src/Appwrite/Models/OAuth2Oidc.php +++ b/src/Appwrite/Models/OAuth2Oidc.php @@ -22,11 +22,11 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId openid connect oauth2 client id. * @param string $clientSecret openid connect oauth2 client secret. + * @param list $prompt openid connect prompt values controlling the authentication and consent screens. * @param string $wellKnownURL openid connect well-known configuration url. when set, authorization, token, and user info endpoints can be discovered automatically. * @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( @@ -34,11 +34,11 @@ public function __construct( public bool $enabled, public string $clientId, public string $clientSecret, + public array $prompt, public string $wellKnownURL, public string $authorizationURL, public string $tokenURL, public string $userInfoURL, - public array $prompt, public ?int $maxAge = null ) { } @@ -53,11 +53,11 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'wellKnownURL' => "", 'authorizationURL' => "", 'tokenURL' => "", 'userInfoURL' => "", - 'prompt' => [], ]; return new static( @@ -65,16 +65,16 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - wellKnownURL: $data['wellKnownURL'], - authorizationURL: $data['authorizationURL'], - tokenURL: $data['tokenURL'], - userInfoURL: $data['userInfoURL'], prompt: is_array($data['prompt']) ? array_map( static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OidcPrompt::class, $item), $data['prompt'] ) - : $data['prompt'], + : [static::hydrateTypedValue(OAuth2OidcPrompt::class, $data['prompt'])], + wellKnownURL: $data['wellKnownURL'], + authorizationURL: $data['authorizationURL'], + tokenURL: $data['tokenURL'], + userInfoURL: $data['userInfoURL'], maxAge: $data['maxAge'] ?? null ); } @@ -89,11 +89,11 @@ public function toArray(): array 'enabled' => static::serializeValue($this->enabled), 'clientId' => static::serializeValue($this->clientId), 'clientSecret' => static::serializeValue($this->clientSecret), + 'prompt' => static::serializeValue($this->prompt), 'wellKnownURL' => static::serializeValue($this->wellKnownURL), 'authorizationURL' => static::serializeValue($this->authorizationURL), 'tokenURL' => static::serializeValue($this->tokenURL), 'userInfoURL' => static::serializeValue($this->userInfoURL), - 'prompt' => static::serializeValue($this->prompt), 'maxAge' => static::serializeValue($this->maxAge) ]; } diff --git a/src/Appwrite/Models/OAuth2Okta.php b/src/Appwrite/Models/OAuth2Okta.php index 10f220af..b5c12a20 100644 --- a/src/Appwrite/Models/OAuth2Okta.php +++ b/src/Appwrite/Models/OAuth2Okta.php @@ -22,18 +22,18 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId okta oauth2 client id. * @param string $clientSecret okta oauth2 client secret. + * @param list $prompt okta oauth2 prompt values. * @param string $domain okta oauth2 domain. * @param string $authorizationServerId okta oauth2 authorization server id. - * @param list|null $prompt okta oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, + public array $prompt, public string $domain, - public string $authorizationServerId, - public ?array $prompt = null + public string $authorizationServerId ) { } @@ -47,6 +47,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'domain' => "", 'authorizationServerId' => "", ]; @@ -56,18 +57,14 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - domain: $data['domain'], - authorizationServerId: $data['authorizationServerId'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OktaPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OktaPrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2OktaPrompt::class, $data['prompt'])], + domain: $data['domain'], + authorizationServerId: $data['authorizationServerId'] ); } diff --git a/src/Appwrite/Models/OAuth2ProviderList.php b/src/Appwrite/Models/OAuth2ProviderList.php index bd2607be..4e278802 100644 --- a/src/Appwrite/Models/OAuth2ProviderList.php +++ b/src/Appwrite/Models/OAuth2ProviderList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'providers' => [], ]; - if (!array_key_exists('providers', $data)) { - throw new \InvalidArgumentException('Missing required field "providers" for ' . static::class . '.'); - } - return new static( total: $data['total'], providers: $data['providers'] diff --git a/src/Appwrite/Models/OAuth2Salesforce.php b/src/Appwrite/Models/OAuth2Salesforce.php index bea4ea61..1317fb68 100644 --- a/src/Appwrite/Models/OAuth2Salesforce.php +++ b/src/Appwrite/Models/OAuth2Salesforce.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $customerKey salesforce oauth2 consumer key. * @param string $customerSecret salesforce oauth2 consumer secret. - * @param list|null $prompt salesforce oauth2 prompt values. + * @param list $prompt salesforce oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $customerKey, public string $customerSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'customerKey' => "", 'customerSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], customerKey: $data['customerKey'], customerSecret: $data['customerSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2SalesforcePrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2SalesforcePrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2SalesforcePrompt::class, $data['prompt'])] ); } diff --git a/src/Appwrite/Models/OAuth2Zoho.php b/src/Appwrite/Models/OAuth2Zoho.php index 31966c63..a8a09e0d 100644 --- a/src/Appwrite/Models/OAuth2Zoho.php +++ b/src/Appwrite/Models/OAuth2Zoho.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId zoho oauth2 client id. * @param string $clientSecret zoho oauth2 client secret. - * @param list|null $prompt zoho oauth2 prompt values. + * @param list $prompt zoho oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2ZohoPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2ZohoPrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2ZohoPrompt::class, $data['prompt'])] ); } diff --git a/src/Appwrite/Models/Oauth2ConsentList.php b/src/Appwrite/Models/Oauth2ConsentList.php index 5b83a171..1397c04b 100644 --- a/src/Appwrite/Models/Oauth2ConsentList.php +++ b/src/Appwrite/Models/Oauth2ConsentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'consents' => [], ]; - if (!array_key_exists('consents', $data)) { - throw new \InvalidArgumentException('Missing required field "consents" for ' . static::class . '.'); - } - return new static( total: $data['total'], consents: is_array($data['consents']) diff --git a/src/Appwrite/Models/Oauth2ConsentTokenList.php b/src/Appwrite/Models/Oauth2ConsentTokenList.php index 0a0a7bb4..1b23700d 100644 --- a/src/Appwrite/Models/Oauth2ConsentTokenList.php +++ b/src/Appwrite/Models/Oauth2ConsentTokenList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tokens' => [], ]; - if (!array_key_exists('tokens', $data)) { - throw new \InvalidArgumentException('Missing required field "tokens" for ' . static::class . '.'); - } - return new static( total: $data['total'], tokens: is_array($data['tokens']) diff --git a/src/Appwrite/Models/Oauth2OrganizationList.php b/src/Appwrite/Models/Oauth2OrganizationList.php index 6549f554..c5134675 100644 --- a/src/Appwrite/Models/Oauth2OrganizationList.php +++ b/src/Appwrite/Models/Oauth2OrganizationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'organizations' => [], ]; - if (!array_key_exists('organizations', $data)) { - throw new \InvalidArgumentException('Missing required field "organizations" for ' . static::class . '.'); - } - return new static( total: $data['total'], organizations: is_array($data['organizations']) diff --git a/src/Appwrite/Models/Oauth2ProjectList.php b/src/Appwrite/Models/Oauth2ProjectList.php index 111dda83..ad709350 100644 --- a/src/Appwrite/Models/Oauth2ProjectList.php +++ b/src/Appwrite/Models/Oauth2ProjectList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'projects' => [], ]; - if (!array_key_exists('projects', $data)) { - throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); - } - return new static( total: $data['total'], projects: is_array($data['projects']) diff --git a/src/Appwrite/Models/Organization.php b/src/Appwrite/Models/Organization.php index 569bc18f..dbed5cbc 100644 --- a/src/Appwrite/Models/Organization.php +++ b/src/Appwrite/Models/Organization.php @@ -27,19 +27,19 @@ * @param string $billingPlanId organization's billing plan id. * @param BillingPlan $billingPlanDetails organization's billing plan. * @param string $billingEmail billing email set for the organization. - * @param string $billingStartDate billing cycle start date. - * @param string $billingCurrentInvoiceDate current invoice cycle start date. - * @param string $billingNextInvoiceDate next invoice cycle start date. - * @param int $billingTrialDays number of trial days. - * @param string $billingAggregationId current active aggregation id. - * @param string $billingInvoiceId current active aggregation id. - * @param string $paymentMethodId default payment method. * @param string $status team status. * @param bool $markedForDeletion marked for deletion * @param string $platform product with which the organization is associated (appwrite or imagine) * @param array $projects selected projects * @param int|null $billingBudget project budget limit. null when no budget is set. + * @param string|null $billingStartDate billing cycle start date. + * @param string|null $billingCurrentInvoiceDate current invoice cycle start date. + * @param string|null $billingNextInvoiceDate next invoice cycle start date. * @param string|null $billingTrialStartDate start date of trial. + * @param int|null $billingTrialDays number of trial days. + * @param string|null $billingAggregationId current active aggregation id. + * @param string|null $billingInvoiceId current active aggregation id. + * @param string|null $paymentMethodId default payment method. * @param string|null $billingAddressId default payment method. * @param string|null $backupPaymentMethodId backup payment method. * @param string|null $remarks remarks on team status. @@ -64,19 +64,19 @@ public function __construct( public string $billingPlanId, public BillingPlan $billingPlanDetails, public string $billingEmail, - public string $billingStartDate, - public string $billingCurrentInvoiceDate, - public string $billingNextInvoiceDate, - public int $billingTrialDays, - public string $billingAggregationId, - public string $billingInvoiceId, - public string $paymentMethodId, public string $status, public bool $markedForDeletion, public string $platform, public array $projects, public ?int $billingBudget = null, + public ?string $billingStartDate = null, + public ?string $billingCurrentInvoiceDate = null, + public ?string $billingNextInvoiceDate = null, public ?string $billingTrialStartDate = null, + public ?int $billingTrialDays = null, + public ?string $billingAggregationId = null, + public ?string $billingInvoiceId = null, + public ?string $paymentMethodId = null, public ?string $billingAddressId = null, public ?string $backupPaymentMethodId = null, public ?string $remarks = null, @@ -118,27 +118,6 @@ public static function from(array $data): static if (!array_key_exists('billingPlanDetails', $data)) { throw new \InvalidArgumentException('Missing required field "billingPlanDetails" 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('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 . '.'); - } return new static( id: $data['$id'], @@ -152,19 +131,19 @@ public static function from(array $data): static billingPlanId: $data['billingPlanId'], billingPlanDetails: static::hydrateTypedValue(BillingPlan::class, $data['billingPlanDetails']), billingEmail: $data['billingEmail'], - billingStartDate: $data['billingStartDate'], - billingCurrentInvoiceDate: $data['billingCurrentInvoiceDate'], - billingNextInvoiceDate: $data['billingNextInvoiceDate'], - billingTrialDays: $data['billingTrialDays'], - billingAggregationId: $data['billingAggregationId'], - billingInvoiceId: $data['billingInvoiceId'], - paymentMethodId: $data['paymentMethodId'], status: $data['status'], markedForDeletion: $data['markedForDeletion'], platform: $data['platform'], projects: $data['projects'], billingBudget: $data['billingBudget'] ?? null, + billingStartDate: $data['billingStartDate'] ?? null, + billingCurrentInvoiceDate: $data['billingCurrentInvoiceDate'] ?? null, + billingNextInvoiceDate: $data['billingNextInvoiceDate'] ?? null, billingTrialStartDate: $data['billingTrialStartDate'] ?? null, + billingTrialDays: $data['billingTrialDays'] ?? null, + billingAggregationId: $data['billingAggregationId'] ?? null, + billingInvoiceId: $data['billingInvoiceId'] ?? null, + paymentMethodId: $data['paymentMethodId'] ?? null, billingAddressId: $data['billingAddressId'] ?? null, backupPaymentMethodId: $data['backupPaymentMethodId'] ?? null, remarks: $data['remarks'] ?? null, diff --git a/src/Appwrite/Models/Passkey.php b/src/Appwrite/Models/Passkey.php index 19e27794..61233db4 100644 --- a/src/Appwrite/Models/Passkey.php +++ b/src/Appwrite/Models/Passkey.php @@ -36,21 +36,13 @@ public function __construct( */ 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('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'accessedAt' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PasskeyChallenge.php b/src/Appwrite/Models/PasskeyChallenge.php index bb415366..c0ba66ca 100644 --- a/src/Appwrite/Models/PasskeyChallenge.php +++ b/src/Appwrite/Models/PasskeyChallenge.php @@ -36,21 +36,13 @@ public function __construct( */ 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('passkeyId', $data)) { - throw new \InvalidArgumentException('Missing required field "passkeyId" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('publicKey', $data)) { - throw new \InvalidArgumentException('Missing required field "publicKey" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'passkeyId' => "", + 'expire' => "", + 'publicKey' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PasskeyList.php b/src/Appwrite/Models/PasskeyList.php index f9506e55..7ef3d4b0 100644 --- a/src/Appwrite/Models/PasskeyList.php +++ b/src/Appwrite/Models/PasskeyList.php @@ -30,12 +30,10 @@ public function __construct( */ 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('passkeys', $data)) { - throw new \InvalidArgumentException('Missing required field "passkeys" for ' . static::class . '.'); - } + $data += [ + 'total' => 0, + 'passkeys' => [], + ]; return new static( total: $data['total'], diff --git a/src/Appwrite/Models/PhoneList.php b/src/Appwrite/Models/PhoneList.php index ac802484..318a2782 100644 --- a/src/Appwrite/Models/PhoneList.php +++ b/src/Appwrite/Models/PhoneList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'phones' => [], ]; - if (!array_key_exists('phones', $data)) { - throw new \InvalidArgumentException('Missing required field "phones" for ' . static::class . '.'); - } - return new static( total: $data['total'], phones: is_array($data['phones']) diff --git a/src/Appwrite/Models/PlatformAndroid.php b/src/Appwrite/Models/PlatformAndroid.php index 246df74b..bc9f9662 100644 --- a/src/Appwrite/Models/PlatformAndroid.php +++ b/src/Appwrite/Models/PlatformAndroid.php @@ -24,7 +24,7 @@ * @param string $name platform name. * @param PlatformType $type platform type. possible values are: windows, apple, android, linux, web. * @param string $applicationId android application id. - * @param array|null $fingerprints sha-256 fingerprints of the certificates the app is signed with. passkeys created in the app are accepted when its signature matches one. + * @param array $fingerprints sha-256 fingerprints of the certificates the app is signed with. passkeys created in the app are accepted when its signature matches one. */ public function __construct( public string $id, @@ -33,7 +33,7 @@ public function __construct( public string $name, public PlatformType $type, public string $applicationId, - public ?array $fingerprints = null + public array $fingerprints ) { } @@ -48,6 +48,7 @@ public static function from(array $data): static '$updatedAt' => "", 'name' => "", 'applicationId' => "", + 'fingerprints' => [], ]; if (!array_key_exists('type', $data)) { @@ -61,7 +62,7 @@ public static function from(array $data): static name: $data['name'], type: static::hydrateTypedValue(PlatformType::class, $data['type']), applicationId: $data['applicationId'], - fingerprints: $data['fingerprints'] ?? null + fingerprints: $data['fingerprints'] ); } diff --git a/src/Appwrite/Models/PlatformList.php b/src/Appwrite/Models/PlatformList.php index c8d64a41..6819d824 100644 --- a/src/Appwrite/Models/PlatformList.php +++ b/src/Appwrite/Models/PlatformList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'platforms' => [], ]; - if (!array_key_exists('platforms', $data)) { - throw new \InvalidArgumentException('Missing required field "platforms" for ' . static::class . '.'); - } - return new static( total: $data['total'], platforms: $data['platforms'] diff --git a/src/Appwrite/Models/PolicyList.php b/src/Appwrite/Models/PolicyList.php index a1599a40..16069c98 100644 --- a/src/Appwrite/Models/PolicyList.php +++ b/src/Appwrite/Models/PolicyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'policies' => [], ]; - if (!array_key_exists('policies', $data)) { - throw new \InvalidArgumentException('Missing required field "policies" for ' . static::class . '.'); - } - return new static( total: $data['total'], policies: $data['policies'] diff --git a/src/Appwrite/Models/PolicyPasskey.php b/src/Appwrite/Models/PolicyPasskey.php index 5dd5735a..f094bda4 100644 --- a/src/Appwrite/Models/PolicyPasskey.php +++ b/src/Appwrite/Models/PolicyPasskey.php @@ -32,15 +32,11 @@ public function __construct( */ 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('rpId', $data)) { - throw new \InvalidArgumentException('Missing required field "rpId" for ' . static::class . '.'); - } - if (!array_key_exists('origins', $data)) { - throw new \InvalidArgumentException('Missing required field "origins" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'rpId' => "", + 'origins' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Presence.php b/src/Appwrite/Models/Presence.php index 95ae696c..bd211ffe 100644 --- a/src/Appwrite/Models/Presence.php +++ b/src/Appwrite/Models/Presence.php @@ -48,14 +48,11 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'userId' => "", 'source' => "", ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/PresenceList.php b/src/Appwrite/Models/PresenceList.php index c363e108..c2e12147 100644 --- a/src/Appwrite/Models/PresenceList.php +++ b/src/Appwrite/Models/PresenceList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'presences' => [], ]; - if (!array_key_exists('presences', $data)) { - throw new \InvalidArgumentException('Missing required field "presences" for ' . static::class . '.'); - } - return new static( total: $data['total'], presences: is_array($data['presences']) diff --git a/src/Appwrite/Models/Project.php b/src/Appwrite/Models/Project.php index 256193bd..9735a0d8 100644 --- a/src/Appwrite/Models/Project.php +++ b/src/Appwrite/Models/Project.php @@ -22,7 +22,6 @@ * @param string $name project name. * @param string $teamId project team id. * @param string $region project region - * @param list $devKeys deprecated since 1.9.5: list of dev keys. * @param bool $smtpEnabled status for custom smtp * @param string $smtpSenderName smtp sender name * @param string $smtpSenderEmail smtp sender email @@ -73,7 +72,6 @@ public function __construct( public string $name, public string $teamId, public string $region, - public array $devKeys, public bool $smtpEnabled, public string $smtpSenderName, public string $smtpSenderEmail, @@ -146,25 +144,13 @@ public static function from(array $data): static 'labels' => [], 'status' => "active", 'onboarding' => [], + 'authMethods' => [], + 'services' => [], + 'protocols' => [], + 'blocks' => [], 'consoleAccessedAt' => "", ]; - if (!array_key_exists('devKeys', $data)) { - throw new \InvalidArgumentException('Missing required field "devKeys" for ' . static::class . '.'); - } - if (!array_key_exists('authMethods', $data)) { - throw new \InvalidArgumentException('Missing required field "authMethods" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('protocols', $data)) { - throw new \InvalidArgumentException('Missing required field "protocols" for ' . static::class . '.'); - } - if (!array_key_exists('blocks', $data)) { - throw new \InvalidArgumentException('Missing required field "blocks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], @@ -172,12 +158,6 @@ public static function from(array $data): static name: $data['name'], teamId: $data['teamId'], region: $data['region'], - devKeys: is_array($data['devKeys']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(DevKey::class, $item), - $data['devKeys'] - ) - : $data['devKeys'], smtpEnabled: $data['smtpEnabled'], smtpSenderName: $data['smtpSenderName'], smtpSenderEmail: $data['smtpSenderEmail'], @@ -255,7 +235,6 @@ public function toArray(): array 'name' => static::serializeValue($this->name), 'teamId' => static::serializeValue($this->teamId), 'region' => static::serializeValue($this->region), - 'devKeys' => static::serializeValue($this->devKeys), 'smtpEnabled' => static::serializeValue($this->smtpEnabled), 'smtpSenderName' => static::serializeValue($this->smtpSenderName), 'smtpSenderEmail' => static::serializeValue($this->smtpSenderEmail), diff --git a/src/Appwrite/Models/ProjectList.php b/src/Appwrite/Models/ProjectList.php index f7261447..17d71c0c 100644 --- a/src/Appwrite/Models/ProjectList.php +++ b/src/Appwrite/Models/ProjectList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'projects' => [], ]; - if (!array_key_exists('projects', $data)) { - throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); - } - return new static( total: $data['total'], projects: is_array($data['projects']) diff --git a/src/Appwrite/Models/ProviderList.php b/src/Appwrite/Models/ProviderList.php index 68bbeb5d..bd6ba8ea 100644 --- a/src/Appwrite/Models/ProviderList.php +++ b/src/Appwrite/Models/ProviderList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'providers' => [], ]; - if (!array_key_exists('providers', $data)) { - throw new \InvalidArgumentException('Missing required field "providers" for ' . static::class . '.'); - } - return new static( total: $data['total'], providers: is_array($data['providers']) diff --git a/src/Appwrite/Models/ProxyRule.php b/src/Appwrite/Models/ProxyRule.php index cc9f7583..85fbbe10 100644 --- a/src/Appwrite/Models/ProxyRule.php +++ b/src/Appwrite/Models/ProxyRule.php @@ -6,6 +6,7 @@ use Appwrite\Enums\ProxyRuleDeploymentResourceType; use Appwrite\Enums\ProxyRuleStatus; +use Appwrite\Enums\ProxyRuleProtocol; /** * Rule @@ -33,7 +34,8 @@ * @param ProxyRuleStatus $status domain verification status. possible values are "unverified", "verifying", "verified" * @param string $logs logs from rule verification or certificate generation. certificate generation logs are prioritized if both are available. * @param string $renewAt certificate auto-renewal date in iso 8601 format. - * @param ProxyRuleDeploymentResourceType|null $deploymentResourceType type of deployment. possible values are "function", "site". used if rule's type is "deployment". + * @param ProxyRuleProtocol $protocol ingress protocol for the rule. + * @param ProxyRuleDeploymentResourceType|null $deploymentResourceType type of deployment resource: function, site, or dedicateddatabase. */ public function __construct( public string $id, @@ -50,6 +52,7 @@ public function __construct( public ProxyRuleStatus $status, public string $logs, public string $renewAt, + public ProxyRuleProtocol $protocol, public ?ProxyRuleDeploymentResourceType $deploymentResourceType = null ) { } @@ -73,6 +76,7 @@ public static function from(array $data): static 'deploymentVcsProviderBranch' => "", 'status' => "unverified", 'logs' => "", + 'protocol' => "http", ]; if (!array_key_exists('renewAt', $data)) { @@ -94,6 +98,7 @@ public static function from(array $data): static status: static::hydrateTypedValue(ProxyRuleStatus::class, $data['status']), logs: $data['logs'], renewAt: $data['renewAt'], + protocol: static::hydrateTypedValue(ProxyRuleProtocol::class, $data['protocol']), deploymentResourceType: array_key_exists('deploymentResourceType', $data) ? static::hydrateTypedValue(ProxyRuleDeploymentResourceType::class, $data['deploymentResourceType'], true) : null ); } @@ -118,7 +123,8 @@ public function toArray(): array 'deploymentVcsProviderBranch' => static::serializeValue($this->deploymentVcsProviderBranch), 'status' => static::serializeValue($this->status), 'logs' => static::serializeValue($this->logs), - 'renewAt' => static::serializeValue($this->renewAt) + 'renewAt' => static::serializeValue($this->renewAt), + 'protocol' => static::serializeValue($this->protocol) ]; } } diff --git a/src/Appwrite/Models/ProxyRuleList.php b/src/Appwrite/Models/ProxyRuleList.php index 413058a4..ac83cabf 100644 --- a/src/Appwrite/Models/ProxyRuleList.php +++ b/src/Appwrite/Models/ProxyRuleList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'rules' => [], ]; - if (!array_key_exists('rules', $data)) { - throw new \InvalidArgumentException('Missing required field "rules" for ' . static::class . '.'); - } - return new static( total: $data['total'], rules: is_array($data['rules']) diff --git a/src/Appwrite/Models/Report.php b/src/Appwrite/Models/Report.php index 8ecd43f9..e004db96 100644 --- a/src/Appwrite/Models/Report.php +++ b/src/Appwrite/Models/Report.php @@ -61,12 +61,9 @@ public static function from(array $data): static 'targetType' => "", 'target' => "", 'categories' => [], + 'insights' => [], ]; - if (!array_key_exists('insights', $data)) { - throw new \InvalidArgumentException('Missing required field "insights" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/ReportList.php b/src/Appwrite/Models/ReportList.php index ea32a528..5e129d3d 100644 --- a/src/Appwrite/Models/ReportList.php +++ b/src/Appwrite/Models/ReportList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'reports' => [], ]; - if (!array_key_exists('reports', $data)) { - throw new \InvalidArgumentException('Missing required field "reports" for ' . static::class . '.'); - } - return new static( total: $data['total'], reports: is_array($data['reports']) diff --git a/src/Appwrite/Models/ResourceTokenList.php b/src/Appwrite/Models/ResourceTokenList.php index 2b9b1885..c50b4801 100644 --- a/src/Appwrite/Models/ResourceTokenList.php +++ b/src/Appwrite/Models/ResourceTokenList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tokens' => [], ]; - if (!array_key_exists('tokens', $data)) { - throw new \InvalidArgumentException('Missing required field "tokens" for ' . static::class . '.'); - } - return new static( total: $data['total'], tokens: is_array($data['tokens']) diff --git a/src/Appwrite/Models/Row.php b/src/Appwrite/Models/Row.php index d37ab8ab..1e323515 100644 --- a/src/Appwrite/Models/Row.php +++ b/src/Appwrite/Models/Row.php @@ -49,12 +49,9 @@ public static function from(array $data): static '$databaseId' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - $additionalProperties = static::extractAdditionalPropertiesFromFields( $data, [ diff --git a/src/Appwrite/Models/RowList.php b/src/Appwrite/Models/RowList.php index f5194b86..9cf05c07 100644 --- a/src/Appwrite/Models/RowList.php +++ b/src/Appwrite/Models/RowList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'rows' => [], ]; - if (!array_key_exists('rows', $data)) { - throw new \InvalidArgumentException('Missing required field "rows" for ' . static::class . '.'); - } - return new static( total: $data['total'], rows: is_array($data['rows']) diff --git a/src/Appwrite/Models/Runtime.php b/src/Appwrite/Models/Runtime.php index 6b51ebed..84aa814d 100644 --- a/src/Appwrite/Models/Runtime.php +++ b/src/Appwrite/Models/Runtime.php @@ -50,12 +50,9 @@ public static function from(array $data): static 'base' => "", 'image' => "", 'logo' => "", + 'supports' => [], ]; - if (!array_key_exists('supports', $data)) { - throw new \InvalidArgumentException('Missing required field "supports" for ' . static::class . '.'); - } - return new static( id: $data['$id'], key: $data['key'], diff --git a/src/Appwrite/Models/RuntimeList.php b/src/Appwrite/Models/RuntimeList.php index 32baecf3..c13abbcf 100644 --- a/src/Appwrite/Models/RuntimeList.php +++ b/src/Appwrite/Models/RuntimeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'runtimes' => [], ]; - if (!array_key_exists('runtimes', $data)) { - throw new \InvalidArgumentException('Missing required field "runtimes" for ' . static::class . '.'); - } - return new static( total: $data['total'], runtimes: is_array($data['runtimes']) diff --git a/src/Appwrite/Models/SessionList.php b/src/Appwrite/Models/SessionList.php index 33e062cc..d834c970 100644 --- a/src/Appwrite/Models/SessionList.php +++ b/src/Appwrite/Models/SessionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'sessions' => [], ]; - if (!array_key_exists('sessions', $data)) { - throw new \InvalidArgumentException('Missing required field "sessions" for ' . static::class . '.'); - } - return new static( total: $data['total'], sessions: is_array($data['sessions']) diff --git a/src/Appwrite/Models/Site.php b/src/Appwrite/Models/Site.php index 671bb5d4..3b00ca02 100644 --- a/src/Appwrite/Models/Site.php +++ b/src/Appwrite/Models/Site.php @@ -114,6 +114,7 @@ public static function from(array $data): static 'latestDeploymentCreatedAt' => "", 'latestDeploymentStatus' => "", 'scopes' => [], + 'vars' => [], 'timeout' => 15, 'installCommand' => "", 'buildCommand' => "", @@ -131,9 +132,6 @@ public static function from(array $data): static 'buildRuntime' => "", ]; - if (!array_key_exists('vars', $data)) { - throw new \InvalidArgumentException('Missing required field "vars" for ' . static::class . '.'); - } if (!array_key_exists('adapter', $data)) { throw new \InvalidArgumentException('Missing required field "adapter" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/SiteList.php b/src/Appwrite/Models/SiteList.php index e3b32b48..2adcf105 100644 --- a/src/Appwrite/Models/SiteList.php +++ b/src/Appwrite/Models/SiteList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'sites' => [], ]; - if (!array_key_exists('sites', $data)) { - throw new \InvalidArgumentException('Missing required field "sites" for ' . static::class . '.'); - } - return new static( total: $data['total'], sites: is_array($data['sites']) diff --git a/src/Appwrite/Models/SpecificationList.php b/src/Appwrite/Models/SpecificationList.php index e48faded..117627c5 100644 --- a/src/Appwrite/Models/SpecificationList.php +++ b/src/Appwrite/Models/SpecificationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'specifications' => [], ]; - if (!array_key_exists('specifications', $data)) { - throw new \InvalidArgumentException('Missing required field "specifications" for ' . static::class . '.'); - } - return new static( total: $data['total'], specifications: is_array($data['specifications']) diff --git a/src/Appwrite/Models/SubscriberList.php b/src/Appwrite/Models/SubscriberList.php index 705cb0b5..cdd1819b 100644 --- a/src/Appwrite/Models/SubscriberList.php +++ b/src/Appwrite/Models/SubscriberList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'subscribers' => [], ]; - if (!array_key_exists('subscribers', $data)) { - throw new \InvalidArgumentException('Missing required field "subscribers" for ' . static::class . '.'); - } - return new static( total: $data['total'], subscribers: is_array($data['subscribers']) diff --git a/src/Appwrite/Models/Table.php b/src/Appwrite/Models/Table.php index 49869583..dc197d32 100644 --- a/src/Appwrite/Models/Table.php +++ b/src/Appwrite/Models/Table.php @@ -54,24 +54,17 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'rowSecurity' => false, + 'columns' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/TableList.php b/src/Appwrite/Models/TableList.php index c6352fb6..c3aa35fc 100644 --- a/src/Appwrite/Models/TableList.php +++ b/src/Appwrite/Models/TableList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tables' => [], ]; - if (!array_key_exists('tables', $data)) { - throw new \InvalidArgumentException('Missing required field "tables" for ' . static::class . '.'); - } - return new static( total: $data['total'], tables: is_array($data['tables']) diff --git a/src/Appwrite/Models/TargetList.php b/src/Appwrite/Models/TargetList.php index 8596f116..e68cdcf4 100644 --- a/src/Appwrite/Models/TargetList.php +++ b/src/Appwrite/Models/TargetList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'targets' => [], ]; - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } - return new static( total: $data['total'], targets: is_array($data['targets']) diff --git a/src/Appwrite/Models/TeamList.php b/src/Appwrite/Models/TeamList.php index 8c75339d..b9647882 100644 --- a/src/Appwrite/Models/TeamList.php +++ b/src/Appwrite/Models/TeamList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'teams' => [], ]; - if (!array_key_exists('teams', $data)) { - throw new \InvalidArgumentException('Missing required field "teams" for ' . static::class . '.'); - } - return new static( total: $data['total'], teams: is_array($data['teams']) diff --git a/src/Appwrite/Models/TokenSecret.php b/src/Appwrite/Models/TokenSecret.php index deedef6b..a9b879de 100644 --- a/src/Appwrite/Models/TokenSecret.php +++ b/src/Appwrite/Models/TokenSecret.php @@ -38,24 +38,14 @@ public function __construct( */ 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('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('phrase', $data)) { - throw new \InvalidArgumentException('Missing required field "phrase" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'userId' => "", + 'secret' => "", + 'expire' => "", + 'phrase' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Topic.php b/src/Appwrite/Models/Topic.php index 42f22386..4719c755 100644 --- a/src/Appwrite/Models/Topic.php +++ b/src/Appwrite/Models/Topic.php @@ -25,7 +25,7 @@ * @param int $pushTotal total count of push subscribers subscribed to the topic. * @param array $subscribe subscribe permissions. * @param int|null $qos mqtt qos for delivery on this topic. null lets the subscriber choose their level. - * @param int|null $expiry message retention in seconds for offline delivery. + * @param int|null $expiry message retention in seconds for offline delivery. null inherits the lowest expiry of the project's enabled appwrite providers, or the 7-day ledger window if none sets one. */ public function __construct( public string $id, diff --git a/src/Appwrite/Models/TopicList.php b/src/Appwrite/Models/TopicList.php index 4ba86969..48bbc421 100644 --- a/src/Appwrite/Models/TopicList.php +++ b/src/Appwrite/Models/TopicList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'topics' => [], ]; - if (!array_key_exists('topics', $data)) { - throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); - } - return new static( total: $data['total'], topics: is_array($data['topics']) diff --git a/src/Appwrite/Models/TransactionList.php b/src/Appwrite/Models/TransactionList.php index 7e17740d..92fd205d 100644 --- a/src/Appwrite/Models/TransactionList.php +++ b/src/Appwrite/Models/TransactionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'transactions' => [], ]; - if (!array_key_exists('transactions', $data)) { - throw new \InvalidArgumentException('Missing required field "transactions" for ' . static::class . '.'); - } - return new static( total: $data['total'], transactions: is_array($data['transactions']) diff --git a/src/Appwrite/Models/UsageBillingPlan.php b/src/Appwrite/Models/UsageBillingPlan.php index eb9cab99..1db3b763 100644 --- a/src/Appwrite/Models/UsageBillingPlan.php +++ b/src/Appwrite/Models/UsageBillingPlan.php @@ -16,29 +16,29 @@ /** * UsageBillingPlan constructor. * - * @param AdditionalResource $bandwidth bandwidth additional resources - * @param AdditionalResource $executions executions additional resources - * @param AdditionalResource $realtime realtime additional resources - * @param AdditionalResource $realtimeMessages realtime messages additional resources - * @param AdditionalResource $storage storage additional resources - * @param AdditionalResource $users user additional resources - * @param AdditionalResource $gBHours gbhour additional resources - * @param AdditionalResource $imageTransformations image transformation additional resources + * @param AdditionalResource|null $bandwidth bandwidth additional resources + * @param AdditionalResource|null $executions executions additional resources * @param AdditionalResource|null $member member additional resources + * @param AdditionalResource|null $realtime realtime additional resources + * @param AdditionalResource|null $realtimeMessages realtime messages additional resources * @param AdditionalResource|null $realtimeBandwidth realtime bandwidth additional resources + * @param AdditionalResource|null $storage storage additional resources + * @param AdditionalResource|null $users user additional resources + * @param AdditionalResource|null $gBHours gbhour additional resources + * @param AdditionalResource|null $imageTransformations image transformation additional resources * @param AdditionalResource|null $credits credits additional resources */ public function __construct( - public AdditionalResource $bandwidth, - public AdditionalResource $executions, - public AdditionalResource $realtime, - public AdditionalResource $realtimeMessages, - public AdditionalResource $storage, - public AdditionalResource $users, - public AdditionalResource $gBHours, - public AdditionalResource $imageTransformations, + public ?AdditionalResource $bandwidth = null, + public ?AdditionalResource $executions = null, public ?AdditionalResource $member = null, + public ?AdditionalResource $realtime = null, + public ?AdditionalResource $realtimeMessages = null, public ?AdditionalResource $realtimeBandwidth = null, + public ?AdditionalResource $storage = null, + public ?AdditionalResource $users = null, + public ?AdditionalResource $gBHours = null, + public ?AdditionalResource $imageTransformations = null, public ?AdditionalResource $credits = null ) { } @@ -48,42 +48,18 @@ public function __construct( */ 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('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('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 . '.'); - } return new static( - bandwidth: static::hydrateTypedValue(AdditionalResource::class, $data['bandwidth']), - executions: static::hydrateTypedValue(AdditionalResource::class, $data['executions']), - realtime: static::hydrateTypedValue(AdditionalResource::class, $data['realtime']), - realtimeMessages: static::hydrateTypedValue(AdditionalResource::class, $data['realtimeMessages']), - 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']), + bandwidth: array_key_exists('bandwidth', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['bandwidth'], true) : null, + executions: array_key_exists('executions', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['executions'], true) : null, member: array_key_exists('member', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['member'], true) : null, + realtime: array_key_exists('realtime', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtime'], true) : null, + realtimeMessages: array_key_exists('realtimeMessages', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtimeMessages'], true) : null, realtimeBandwidth: array_key_exists('realtimeBandwidth', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtimeBandwidth'], true) : null, + storage: array_key_exists('storage', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['storage'], true) : null, + users: array_key_exists('users', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['users'], true) : null, + gBHours: array_key_exists('GBHours', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['GBHours'], true) : null, + imageTransformations: array_key_exists('imageTransformations', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['imageTransformations'], true) : null, credits: array_key_exists('credits', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['credits'], true) : null ); } diff --git a/src/Appwrite/Models/User.php b/src/Appwrite/Models/User.php index 476c9802..57c6d397 100644 --- a/src/Appwrite/Models/User.php +++ b/src/Appwrite/Models/User.php @@ -94,15 +94,13 @@ public static function from(array $data): static 'emailVerification' => false, 'phoneVerification' => false, 'mfa' => false, + 'targets' => [], 'accessedAt' => "", ]; if (!array_key_exists('prefs', $data)) { throw new \InvalidArgumentException('Missing required field "prefs" for ' . static::class . '.'); } - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/UserList.php b/src/Appwrite/Models/UserList.php index 8c4d99d0..b3c9b38c 100644 --- a/src/Appwrite/Models/UserList.php +++ b/src/Appwrite/Models/UserList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'users' => [], ]; - if (!array_key_exists('users', $data)) { - throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); - } - return new static( total: $data['total'], users: is_array($data['users']) diff --git a/src/Appwrite/Models/VariableList.php b/src/Appwrite/Models/VariableList.php index 698af61c..9a8ae59b 100644 --- a/src/Appwrite/Models/VariableList.php +++ b/src/Appwrite/Models/VariableList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'variables' => [], ]; - if (!array_key_exists('variables', $data)) { - throw new \InvalidArgumentException('Missing required field "variables" for ' . static::class . '.'); - } - return new static( total: $data['total'], variables: is_array($data['variables']) diff --git a/src/Appwrite/Models/VectorsdbCollection.php b/src/Appwrite/Models/VectorsdbCollection.php index 38e5ec63..1ec525b7 100644 --- a/src/Appwrite/Models/VectorsdbCollection.php +++ b/src/Appwrite/Models/VectorsdbCollection.php @@ -56,25 +56,18 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'documentSecurity' => false, + 'attributes' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, 'dimension' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/VectorsdbCollectionList.php b/src/Appwrite/Models/VectorsdbCollectionList.php index e5c2c05c..8e414ae9 100644 --- a/src/Appwrite/Models/VectorsdbCollectionList.php +++ b/src/Appwrite/Models/VectorsdbCollectionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'collections' => [], ]; - if (!array_key_exists('collections', $data)) { - throw new \InvalidArgumentException('Missing required field "collections" for ' . static::class . '.'); - } - return new static( total: $data['total'], collections: is_array($data['collections']) diff --git a/src/Appwrite/Models/Webhook.php b/src/Appwrite/Models/Webhook.php index 9f1bef97..4df57b11 100644 --- a/src/Appwrite/Models/Webhook.php +++ b/src/Appwrite/Models/Webhook.php @@ -24,7 +24,7 @@ * @param array $events webhook trigger events. * @param bool $tls indicates if ssl / tls certificate verification is enabled. * @param string $authUsername http basic authentication username. - * @param string $authPassword http basic authentication password. + * @param string $authPassword http basic authentication password. write-only: always returned empty. * @param string $secret signature key which can be used to validate incoming webhook payloads. only returned on creation and secret rotation. * @param bool $enabled indicates if this webhook is enabled. * @param string $logs webhook error logs from the most recent failure. diff --git a/src/Appwrite/Models/WebhookList.php b/src/Appwrite/Models/WebhookList.php index dafb70d4..9ff66138 100644 --- a/src/Appwrite/Models/WebhookList.php +++ b/src/Appwrite/Models/WebhookList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'webhooks' => [], ]; - if (!array_key_exists('webhooks', $data)) { - throw new \InvalidArgumentException('Missing required field "webhooks" for ' . static::class . '.'); - } - return new static( total: $data['total'], webhooks: is_array($data['webhooks']) diff --git a/src/Appwrite/Query.php b/src/Appwrite/Query.php index 46ee87f2..1ef74498 100644 --- a/src/Appwrite/Query.php +++ b/src/Appwrite/Query.php @@ -4,13 +4,14 @@ namespace Appwrite; +use Appwrite\Query\Builder as QueryBuilder; + class Query implements \JsonSerializable, \Stringable { protected ?array $values; public function __construct(protected string $method, protected ?string $attribute = null, $values = null) { - if (is_null($values) || is_array($values)) { $this->values = $values; } else { @@ -34,7 +35,6 @@ public function jsonSerialize(): mixed /** * Equal - * */ public static function equal(string $attribute, mixed $value): string { @@ -43,7 +43,6 @@ public static function equal(string $attribute, mixed $value): string /** * Not Equal - * */ public static function notEqual(string $attribute, mixed $value): string { @@ -52,7 +51,6 @@ public static function notEqual(string $attribute, mixed $value): string /** * Less Than - * */ public static function lessThan(string $attribute, mixed $value): string { @@ -61,7 +59,6 @@ public static function lessThan(string $attribute, mixed $value): string /** * Less Than or Equal - * */ public static function lessThanEqual(string $attribute, mixed $value): string { @@ -70,7 +67,6 @@ public static function lessThanEqual(string $attribute, mixed $value): string /** * Greater Than - * */ public static function greaterThan(string $attribute, mixed $value): string { @@ -79,7 +75,6 @@ public static function greaterThan(string $attribute, mixed $value): string /** * Greater Than or Equal - * */ public static function greaterThanEqual(string $attribute, mixed $value): string { @@ -88,7 +83,6 @@ public static function greaterThanEqual(string $attribute, mixed $value): string /** * Search - * */ public static function search(string $attribute, string $value): string { @@ -97,7 +91,6 @@ public static function search(string $attribute, string $value): string /** * Is Null - * */ public static function isNull(string $attribute): string { @@ -106,7 +99,6 @@ public static function isNull(string $attribute): string /** * Is Not Null - * */ public static function isNotNull(string $attribute): string { @@ -115,7 +107,6 @@ public static function isNotNull(string $attribute): string /** * Between - * */ public static function between(string $attribute, mixed $start, mixed $end): string { @@ -124,7 +115,6 @@ public static function between(string $attribute, mixed $start, mixed $end): str /** * Starts With - * */ public static function startsWith(string $attribute, string $value): string { @@ -133,7 +123,6 @@ public static function startsWith(string $attribute, string $value): string /** * Ends With - * */ public static function endsWith(string $attribute, string $value): string { @@ -142,7 +131,6 @@ public static function endsWith(string $attribute, string $value): string /** * Select - * */ public static function select(array $attributes): string { @@ -151,7 +139,6 @@ public static function select(array $attributes): string /** * Cursor After - * */ public static function cursorAfter(string $documentId): string { @@ -160,7 +147,6 @@ public static function cursorAfter(string $documentId): string /** * Cursor Before - * */ public static function cursorBefore(string $documentId): string { @@ -169,7 +155,6 @@ public static function cursorBefore(string $documentId): string /** * Order Asc - * */ public static function orderAsc(string $attribute): string { @@ -178,7 +163,6 @@ public static function orderAsc(string $attribute): string /** * Order Desc - * */ public static function orderDesc(string $attribute): string { @@ -187,7 +171,6 @@ public static function orderDesc(string $attribute): string /** * Order Random - * */ public static function orderRandom(): string { @@ -196,7 +179,6 @@ public static function orderRandom(): string /** * Limit - * */ public static function limit(int $limit): string { @@ -205,7 +187,6 @@ public static function limit(int $limit): string /** * Offset - * */ public static function offset(int $offset): string { @@ -253,7 +234,6 @@ public static function containsAll(string $attribute, array $value): string /** * Not Contains - * */ public static function notContains(string $attribute, $value): string { @@ -262,7 +242,6 @@ public static function notContains(string $attribute, $value): string /** * Not Search - * */ public static function notSearch(string $attribute, string $value): string { @@ -271,7 +250,6 @@ public static function notSearch(string $attribute, string $value): string /** * Not Between - * */ public static function notBetween(string $attribute, mixed $start, mixed $end): string { @@ -280,7 +258,6 @@ public static function notBetween(string $attribute, mixed $start, mixed $end): /** * Not Starts With - * */ public static function notStartsWith(string $attribute, string $value): string { @@ -289,7 +266,6 @@ public static function notStartsWith(string $attribute, string $value): string /** * Not Ends With - * */ public static function notEndsWith(string $attribute, string $value): string { @@ -298,7 +274,6 @@ public static function notEndsWith(string $attribute, string $value): string /** * Filter resources where attribute matches a regular expression pattern. - * */ public static function regex(string $attribute, string $pattern): string { @@ -307,7 +282,6 @@ public static function regex(string $attribute, string $pattern): string /** * Filter resources where the specified attributes exist. - * */ public static function exists(array $attributes): string { @@ -316,7 +290,6 @@ public static function exists(array $attributes): string /** * Filter resources where the specified attributes do not exist. - * */ public static function notExists(array $attributes): string { @@ -325,7 +298,6 @@ public static function notExists(array $attributes): string /** * Created Before - * */ public static function createdBefore(string $value): string { @@ -334,7 +306,6 @@ public static function createdBefore(string $value): string /** * Created After - * */ public static function createdAfter(string $value): string { @@ -343,7 +314,6 @@ public static function createdAfter(string $value): string /** * Created Between - * */ public static function createdBetween(string $start, string $end): string { @@ -352,7 +322,6 @@ public static function createdBetween(string $start, string $end): string /** * Updated Before - * */ public static function updatedBefore(string $value): string { @@ -361,7 +330,6 @@ public static function updatedBefore(string $value): string /** * Updated After - * */ public static function updatedAfter(string $value): string { @@ -370,7 +338,6 @@ public static function updatedAfter(string $value): string /** * Updated Between - * */ public static function updatedBetween(string $start, string $end): string { @@ -379,7 +346,6 @@ public static function updatedBetween(string $start, string $end): string /** * Or - * */ public static function or(array $queries): string { @@ -391,7 +357,6 @@ public static function or(array $queries): string /** * And - * */ public static function and(array $queries): string { @@ -403,7 +368,6 @@ public static function and(array $queries): string /** * Filter array elements where at least one element matches all the specified queries. - * */ public static function elemMatch(string $attribute, array $queries): string { @@ -415,9 +379,21 @@ public static function elemMatch(string $attribute, array $queries): string } /** - * Distance Equal + * Constrain populated related documents on a relationship attribute. * */ + public static function relationship(string $attribute, array $queries): string + { + foreach ($queries as &$query) { + $query = \json_decode($query, true); + } + + return new Query('relationship', $attribute, $queries)->__toString(); + } + + /** + * Distance Equal + */ public static function distanceEqual(string $attribute, array $values, int|float $distance, bool $meters = true): string { return new Query('distanceEqual', $attribute, [[$values, $distance, $meters]])->__toString(); @@ -425,7 +401,6 @@ public static function distanceEqual(string $attribute, array $values, int|float /** * Distance Not Equal - * */ public static function distanceNotEqual(string $attribute, array $values, int|float $distance, bool $meters = true): string { @@ -434,7 +409,6 @@ public static function distanceNotEqual(string $attribute, array $values, int|fl /** * Distance Greater Than - * */ public static function distanceGreaterThan(string $attribute, array $values, int|float $distance, bool $meters = true): string { @@ -443,7 +417,6 @@ public static function distanceGreaterThan(string $attribute, array $values, int /** * Distance Less Than - * */ public static function distanceLessThan(string $attribute, array $values, int|float $distance, bool $meters = true): string { @@ -452,7 +425,6 @@ public static function distanceLessThan(string $attribute, array $values, int|fl /** * Vector Dot - * */ public static function vectorDot(string $attribute, array $vector): string { @@ -461,7 +433,6 @@ public static function vectorDot(string $attribute, array $vector): string /** * Vector Cosine - * */ public static function vectorCosine(string $attribute, array $vector): string { @@ -470,7 +441,6 @@ public static function vectorCosine(string $attribute, array $vector): string /** * Vector Euclidean - * */ public static function vectorEuclidean(string $attribute, array $vector): string { @@ -479,7 +449,6 @@ public static function vectorEuclidean(string $attribute, array $vector): string /** * Intersects - * */ public static function intersects(string $attribute, array $values): string { @@ -488,7 +457,6 @@ public static function intersects(string $attribute, array $values): string /** * Not Intersects - * */ public static function notIntersects(string $attribute, array $values): string { @@ -497,7 +465,6 @@ public static function notIntersects(string $attribute, array $values): string /** * Crosses - * */ public static function crosses(string $attribute, array $values): string { @@ -506,7 +473,6 @@ public static function crosses(string $attribute, array $values): string /** * Not Crosses - * */ public static function notCrosses(string $attribute, array $values): string { @@ -515,7 +481,6 @@ public static function notCrosses(string $attribute, array $values): string /** * Overlaps - * */ public static function overlaps(string $attribute, array $values): string { @@ -524,7 +489,6 @@ public static function overlaps(string $attribute, array $values): string /** * Not Overlaps - * */ public static function notOverlaps(string $attribute, array $values): string { @@ -533,7 +497,6 @@ public static function notOverlaps(string $attribute, array $values): string /** * Touches - * */ public static function touches(string $attribute, array $values): string { @@ -542,10 +505,308 @@ public static function touches(string $attribute, array $values): string /** * Not Touches - * */ public static function notTouches(string $attribute, array $values): string { return new Query('notTouches', $attribute, [$values])->__toString(); } + + /** + * Count rows of $attribute, optionally aliased. + */ + public static function count(string $attribute = '*', string $alias = ''): string + { + return new Query('count', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Count distinct values of $attribute, optionally aliased. + */ + public static function countDistinct(string $attribute, string $alias = ''): string + { + return new Query('countDistinct', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Sum values of $attribute, optionally aliased. + */ + public static function sum(string $attribute, string $alias = ''): string + { + return new Query('sum', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Average values of $attribute, optionally aliased. + */ + public static function avg(string $attribute, string $alias = ''): string + { + return new Query('avg', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Minimum value of $attribute, optionally aliased. + */ + public static function min(string $attribute, string $alias = ''): string + { + return new Query('min', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Maximum value of $attribute, optionally aliased. + */ + public static function max(string $attribute, string $alias = ''): string + { + return new Query('max', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Standard deviation of $attribute, optionally aliased. + */ + public static function stddev(string $attribute, string $alias = ''): string + { + return new Query('stddev', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Population standard deviation of $attribute, optionally aliased. + */ + public static function stddevPop(string $attribute, string $alias = ''): string + { + return new Query('stddevPop', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Sample standard deviation of $attribute, optionally aliased. + */ + public static function stddevSamp(string $attribute, string $alias = ''): string + { + return new Query('stddevSamp', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Variance of $attribute, optionally aliased. + */ + public static function variance(string $attribute, string $alias = ''): string + { + return new Query('variance', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Population variance of $attribute, optionally aliased. + */ + public static function varPop(string $attribute, string $alias = ''): string + { + return new Query('varPop', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Sample variance of $attribute, optionally aliased. + */ + public static function varSamp(string $attribute, string $alias = ''): string + { + return new Query('varSamp', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Bitwise AND of $attribute, optionally aliased. + */ + public static function bitAnd(string $attribute, string $alias = ''): string + { + return new Query('bitAnd', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Bitwise OR of $attribute, optionally aliased. + */ + public static function bitOr(string $attribute, string $alias = ''): string + { + return new Query('bitOr', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Bitwise XOR of $attribute, optionally aliased. + */ + public static function bitXor(string $attribute, string $alias = ''): string + { + return new Query('bitXor', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Group results by attributes. + */ + public static function groupBy(array $attributes): string + { + return new Query('groupBy', null, $attributes)->__toString(); + } + + /** + * Filter grouped results. $queries are nested like and/or. + * + * @param array $queries + */ + public static function having(array $queries): string + { + foreach ($queries as &$query) { + if ($query instanceof self) { + $query = $query->__toString(); + } + $query = \json_decode($query, true); + } + unset($query); + + return new Query('having', null, $queries)->__toString(); + } + + /** + * Select distinct rows. + */ + public static function distinct(): string + { + return new Query('distinct')->__toString(); + } + + /** + * Column-to-column join ON condition. + */ + public static function on(string $left, string $right, string $operator = '='): string + { + return new Query('on', null, [$left, $operator, $right])->__toString(); + } + + /** + * Inner join. $table is the joined collection/table ID. + */ + public static function join(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): string + { + return self::createJoin('join', $table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias); + } + + /** + * Left join. $table is the joined collection/table ID. + */ + public static function leftJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): string + { + return self::createJoin('leftJoin', $table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias); + } + + /** + * Right join. $table is the joined collection/table ID. + */ + public static function rightJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): string + { + return self::createJoin('rightJoin', $table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias); + } + + /** + * Full outer join. $table is the joined collection/table ID. + */ + public static function fullOuterJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): string + { + return self::createJoin('fullOuterJoin', $table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias); + } + + /** + * Cross join. $table is the joined collection/table ID. + */ + public static function crossJoin(string $table, string $alias = ''): string + { + return new Query('crossJoin', $table, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Filter resources where $attribute covers the given geometry. + */ + public static function covers(string $attribute, array $values): string + { + return new Query('covers', $attribute, [$values])->__toString(); + } + + /** + * Filter resources where $attribute does not cover the given geometry. + */ + public static function notCovers(string $attribute, array $values): string + { + return new Query('notCovers', $attribute, [$values])->__toString(); + } + + /** + * Filter resources where $attribute is spatially equal to the given geometry. + */ + public static function spatialEquals(string $attribute, array $values): string + { + return new Query('spatialEquals', $attribute, [$values])->__toString(); + } + + /** + * Filter resources where $attribute is not spatially equal to the given geometry. + */ + public static function notSpatialEquals(string $attribute, array $values): string + { + return new Query('notSpatialEquals', $attribute, [$values])->__toString(); + } + + /** + * Return limit and offset queries for 1-based page pagination. + */ + public static function page(int $page, int $perPage = 25): array + { + if ($page < 1) { + throw new \InvalidArgumentException('Page must be >= 1, got ' . $page); + } + if ($perPage < 1) { + throw new \InvalidArgumentException('Per page must be >= 1, got ' . $perPage); + } + + return [ + self::limit($perPage), + self::offset(($page - 1) * $perPage), + ]; + } + + /** + * Start a fluent query builder. + */ + public static function builder(): QueryBuilder + { + return new QueryBuilder(); + } + + /** + */ + private static function createJoin(string $method, string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn, string $operator, string $alias): string + { + if (\is_array($leftOrAliasOrOn)) { + return self::nestedJoin($method, $table, '', $leftOrAliasOrOn); + } + if (\is_array($rightOrOn)) { + return self::nestedJoin($method, $table, $leftOrAliasOrOn, $rightOrOn); + } + + return self::joinQuery($method, $table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias); + } + + /** + */ + private static function nestedJoin(string $method, string $table, string $alias, array $on): string + { + $values = []; + if ($alias !== '') { + $values[] = $alias; + } + foreach ($on as $query) { + $values[] = \json_decode($query, true); + } + + return new Query($method, $table, $values)->__toString(); + } + + private static function joinQuery(string $method, string $table, string $left, string $right, string $operator, string $alias): string + { + $values = [$left, $operator, $right]; + if ($alias !== '') { + $values[] = $alias; + } + + return new Query($method, $table, $values)->__toString(); + } } diff --git a/src/Appwrite/Query/Builder.php b/src/Appwrite/Query/Builder.php new file mode 100644 index 00000000..c9acb455 --- /dev/null +++ b/src/Appwrite/Query/Builder.php @@ -0,0 +1,558 @@ + + */ + private array $queries = []; + + /** + * @return list + */ + public function build(): array + { + return $this->queries; + } + + public function equal(string $attribute, mixed $value): self + { + return $this->push(Query::equal($attribute, $value)); + } + + public function notEqual(string $attribute, mixed $value): self + { + return $this->push(Query::notEqual($attribute, $value)); + } + + public function lessThan(string $attribute, mixed $value): self + { + return $this->push(Query::lessThan($attribute, $value)); + } + + public function lessThanEqual(string $attribute, mixed $value): self + { + return $this->push(Query::lessThanEqual($attribute, $value)); + } + + public function greaterThan(string $attribute, mixed $value): self + { + return $this->push(Query::greaterThan($attribute, $value)); + } + + public function greaterThanEqual(string $attribute, mixed $value): self + { + return $this->push(Query::greaterThanEqual($attribute, $value)); + } + + public function search(string $attribute, string $value): self + { + return $this->push(Query::search($attribute, $value)); + } + + public function isNull(string $attribute): self + { + return $this->push(Query::isNull($attribute)); + } + + public function isNotNull(string $attribute): self + { + return $this->push(Query::isNotNull($attribute)); + } + + public function between(string $attribute, mixed $start, mixed $end): self + { + return $this->push(Query::between($attribute, $start, $end)); + } + + public function startsWith(string $attribute, string $value): self + { + return $this->push(Query::startsWith($attribute, $value)); + } + + public function endsWith(string $attribute, string $value): self + { + return $this->push(Query::endsWith($attribute, $value)); + } + + /** + * @param array $attributes + */ + public function select(array $attributes): self + { + return $this->push(Query::select($attributes)); + } + + public function cursorAfter(string $documentId): self + { + return $this->push(Query::cursorAfter($documentId)); + } + + public function cursorBefore(string $documentId): self + { + return $this->push(Query::cursorBefore($documentId)); + } + + public function orderAsc(string $attribute): self + { + return $this->push(Query::orderAsc($attribute)); + } + + public function orderDesc(string $attribute): self + { + return $this->push(Query::orderDesc($attribute)); + } + + public function orderRandom(): self + { + return $this->push(Query::orderRandom()); + } + + public function limit(int $limit): self + { + return $this->push(Query::limit($limit)); + } + + public function offset(int $offset): self + { + return $this->push(Query::offset($offset)); + } + + public function contains(string $attribute, mixed $value): self + { + return $this->push(Query::contains($attribute, $value)); + } + + /** + * @param array $value + */ + public function containsAny(string $attribute, array $value): self + { + return $this->push(Query::containsAny($attribute, $value)); + } + + /** + * @param array $value + */ + public function containsAll(string $attribute, array $value): self + { + return $this->push(Query::containsAll($attribute, $value)); + } + + public function notContains(string $attribute, mixed $value): self + { + return $this->push(Query::notContains($attribute, $value)); + } + + public function notSearch(string $attribute, string $value): self + { + return $this->push(Query::notSearch($attribute, $value)); + } + + public function notBetween(string $attribute, mixed $start, mixed $end): self + { + return $this->push(Query::notBetween($attribute, $start, $end)); + } + + public function notStartsWith(string $attribute, string $value): self + { + return $this->push(Query::notStartsWith($attribute, $value)); + } + + public function notEndsWith(string $attribute, string $value): self + { + return $this->push(Query::notEndsWith($attribute, $value)); + } + + public function regex(string $attribute, string $pattern): self + { + return $this->push(Query::regex($attribute, $pattern)); + } + + /** + * @param array $attributes + */ + public function exists(array $attributes): self + { + return $this->push(Query::exists($attributes)); + } + + /** + * @param array $attributes + */ + public function notExists(array $attributes): self + { + return $this->push(Query::notExists($attributes)); + } + + public function createdBefore(string $value): self + { + return $this->push(Query::createdBefore($value)); + } + + public function createdAfter(string $value): self + { + return $this->push(Query::createdAfter($value)); + } + + public function createdBetween(string $start, string $end): self + { + return $this->push(Query::createdBetween($start, $end)); + } + + public function updatedBefore(string $value): self + { + return $this->push(Query::updatedBefore($value)); + } + + public function updatedAfter(string $value): self + { + return $this->push(Query::updatedAfter($value)); + } + + public function updatedBetween(string $start, string $end): self + { + return $this->push(Query::updatedBetween($start, $end)); + } + + /** + * @param array $queries + */ + public function or(array $queries): self + { + return $this->push(Query::or($queries)); + } + + /** + * @param array $queries + */ + public function and(array $queries): self + { + return $this->push(Query::and($queries)); + } + + /** + * @param array $queries + */ + public function elemMatch(string $attribute, array $queries): self + { + return $this->push(Query::elemMatch($attribute, $queries)); + } + + public function relationship(string $attribute, array $queries): self + { + return $this->push(Query::relationship($attribute, $queries)); + } + + /** + * @param array $values + */ + public function distanceEqual(string $attribute, array $values, int|float $distance, bool $meters = true): self + { + return $this->push(Query::distanceEqual($attribute, $values, $distance, $meters)); + } + + /** + * @param array $values + */ + public function distanceNotEqual(string $attribute, array $values, int|float $distance, bool $meters = true): self + { + return $this->push(Query::distanceNotEqual($attribute, $values, $distance, $meters)); + } + + /** + * @param array $values + */ + public function distanceGreaterThan(string $attribute, array $values, int|float $distance, bool $meters = true): self + { + return $this->push(Query::distanceGreaterThan($attribute, $values, $distance, $meters)); + } + + /** + * @param array $values + */ + public function distanceLessThan(string $attribute, array $values, int|float $distance, bool $meters = true): self + { + return $this->push(Query::distanceLessThan($attribute, $values, $distance, $meters)); + } + + /** + * @param array $values + */ + public function intersects(string $attribute, array $values): self + { + return $this->push(Query::intersects($attribute, $values)); + } + + /** + * @param array $values + */ + public function notIntersects(string $attribute, array $values): self + { + return $this->push(Query::notIntersects($attribute, $values)); + } + + /** + * @param array $values + */ + public function crosses(string $attribute, array $values): self + { + return $this->push(Query::crosses($attribute, $values)); + } + + /** + * @param array $values + */ + public function notCrosses(string $attribute, array $values): self + { + return $this->push(Query::notCrosses($attribute, $values)); + } + + /** + * @param array $values + */ + public function overlaps(string $attribute, array $values): self + { + return $this->push(Query::overlaps($attribute, $values)); + } + + /** + * @param array $values + */ + public function notOverlaps(string $attribute, array $values): self + { + return $this->push(Query::notOverlaps($attribute, $values)); + } + + /** + * @param array $values + */ + public function touches(string $attribute, array $values): self + { + return $this->push(Query::touches($attribute, $values)); + } + + /** + * @param array $values + */ + public function notTouches(string $attribute, array $values): self + { + return $this->push(Query::notTouches($attribute, $values)); + } + + public function count(string $attribute = '*', string $alias = ''): self + { + return $this->push(Query::count($attribute, $alias)); + } + + public function countDistinct(string $attribute, string $alias = ''): self + { + return $this->push(Query::countDistinct($attribute, $alias)); + } + + public function sum(string $attribute, string $alias = ''): self + { + return $this->push(Query::sum($attribute, $alias)); + } + + public function avg(string $attribute, string $alias = ''): self + { + return $this->push(Query::avg($attribute, $alias)); + } + + public function min(string $attribute, string $alias = ''): self + { + return $this->push(Query::min($attribute, $alias)); + } + + public function max(string $attribute, string $alias = ''): self + { + return $this->push(Query::max($attribute, $alias)); + } + + public function stddev(string $attribute, string $alias = ''): self + { + return $this->push(Query::stddev($attribute, $alias)); + } + + public function stddevPop(string $attribute, string $alias = ''): self + { + return $this->push(Query::stddevPop($attribute, $alias)); + } + + public function stddevSamp(string $attribute, string $alias = ''): self + { + return $this->push(Query::stddevSamp($attribute, $alias)); + } + + public function variance(string $attribute, string $alias = ''): self + { + return $this->push(Query::variance($attribute, $alias)); + } + + public function varPop(string $attribute, string $alias = ''): self + { + return $this->push(Query::varPop($attribute, $alias)); + } + + public function varSamp(string $attribute, string $alias = ''): self + { + return $this->push(Query::varSamp($attribute, $alias)); + } + + public function bitAnd(string $attribute, string $alias = ''): self + { + return $this->push(Query::bitAnd($attribute, $alias)); + } + + public function bitOr(string $attribute, string $alias = ''): self + { + return $this->push(Query::bitOr($attribute, $alias)); + } + + public function bitXor(string $attribute, string $alias = ''): self + { + return $this->push(Query::bitXor($attribute, $alias)); + } + + /** + * @param array $attributes + */ + public function groupBy(array $attributes): self + { + return $this->push(Query::groupBy($attributes)); + } + + /** + * @param array $queries + */ + public function having(array $queries): self + { + return $this->push(Query::having($queries)); + } + + public function distinct(): self + { + return $this->push(Query::distinct()); + } + + /** + * @param string|array $leftOrAliasOrOn + * @param string|array $rightOrOn + */ + public function join(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): self + { + return $this->push(Query::join($table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias)); + } + + /** + * @param string|array $leftOrAliasOrOn + * @param string|array $rightOrOn + */ + public function leftJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): self + { + return $this->push(Query::leftJoin($table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias)); + } + + /** + * @param string|array $leftOrAliasOrOn + * @param string|array $rightOrOn + */ + public function rightJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): self + { + return $this->push(Query::rightJoin($table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias)); + } + + /** + * @param string|array $leftOrAliasOrOn + * @param string|array $rightOrOn + */ + public function fullOuterJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): self + { + return $this->push(Query::fullOuterJoin($table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias)); + } + + public function crossJoin(string $table, string $alias = ''): self + { + return $this->push(Query::crossJoin($table, $alias)); + } + + /** + * @param array $vector + */ + public function vectorDot(string $attribute, array $vector): self + { + return $this->push(Query::vectorDot($attribute, $vector)); + } + + /** + * @param array $vector + */ + public function vectorCosine(string $attribute, array $vector): self + { + return $this->push(Query::vectorCosine($attribute, $vector)); + } + + /** + * @param array $vector + */ + public function vectorEuclidean(string $attribute, array $vector): self + { + return $this->push(Query::vectorEuclidean($attribute, $vector)); + } + + /** + * @param array $values + */ + public function covers(string $attribute, array $values): self + { + return $this->push(Query::covers($attribute, $values)); + } + + /** + * @param array $values + */ + public function notCovers(string $attribute, array $values): self + { + return $this->push(Query::notCovers($attribute, $values)); + } + + /** + * @param array $values + */ + public function spatialEquals(string $attribute, array $values): self + { + return $this->push(Query::spatialEquals($attribute, $values)); + } + + /** + * @param array $values + */ + public function notSpatialEquals(string $attribute, array $values): self + { + return $this->push(Query::notSpatialEquals($attribute, $values)); + } + + public function page(int $page, int $perPage = 25): self + { + return $this->push(Query::page($page, $perPage)); + } + + /** + * @param string|list $query + */ + private function push(string|array $query): self + { + if (\is_array($query)) { + array_push($this->queries, ...$query); + } else { + $this->queries[] = $query; + } + + return $this; + } +} diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 6caf55ff..74a1925d 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -144,6 +144,10 @@ public function listConsents(?array $queries = null, ?bool $total = null): \Appw */ public function getConsent(string $consentId): \Appwrite\Models\Oauth2Consent { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -180,6 +184,10 @@ public function getConsent(string $consentId): \Appwrite\Models\Oauth2Consent */ public function deleteConsent(string $consentId): string { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -211,6 +219,10 @@ public function deleteConsent(string $consentId): string */ public function listConsentTokens(string $consentId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\Oauth2ConsentTokenList { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -254,6 +266,14 @@ public function listConsentTokens(string $consentId, ?array $queries = null, ?bo */ public function getConsentToken(string $consentId, string $tokenId): \Appwrite\Models\Oauth2ConsentToken { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{consentId}', '{tokenId}'], [$consentId, $tokenId], @@ -291,6 +311,14 @@ public function getConsentToken(string $consentId, string $tokenId): \Appwrite\M */ public function deleteConsentToken(string $consentId, string $tokenId): string { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{consentId}', '{tokenId}'], [$consentId, $tokenId], @@ -404,6 +432,10 @@ public function listIdentities(?array $queries = null, ?bool $total = null): \Ap */ public function deleteIdentity(string $identityId): string { + if ($identityId === '') { + throw new AppwriteException('Missing required parameter: "identityId"'); + } + $apiPath = str_replace( ['{identityId}'], [$identityId], @@ -416,6 +448,7 @@ public function deleteIdentity(string $identityId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -425,48 +458,6 @@ public function deleteIdentity(string $identityId): string ); } - /** - * Get the list of latest security activity logs for the currently logged in - * user. Each log returns user IP address, location and date and time of log. - * - * @throws AppwriteException - */ - public function listLogs(?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - [], - [], - '/account/logs' - ); - - $apiParams = []; - - 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); - } - /** * Enable or disable MFA on an account. * @@ -597,6 +588,7 @@ public function deleteMFAAuthenticator(AuthenticatorType $type): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1484,7 +1476,8 @@ public function listSessions(?bool $total = null): \Appwrite\Models\SessionList /** * Delete all sessions from the user account and remove any sessions cookies - * from the end client. + * from the end client. Pass `current` as false to keep the session making the + * request and sign out of every other session. * * @throws AppwriteException */ @@ -1505,6 +1498,7 @@ public function deleteSessions(?bool $current = null): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1557,6 +1551,9 @@ public function createAnonymousSession(): \Appwrite\Models\Session /** * Allow the user to login into their account by providing a valid email and * password combination. This route will create a new session for the user. + * Use the optional `duration` parameter to create a shorter session, for + * example when the user doesn't choose "remember me". It must be at least 60 + * seconds and cannot exceed the project maximum session length. * * A user is limited to 10 active sessions at a time by default. [Learn more * about session @@ -1816,6 +1813,10 @@ public function createSession(string $userId, string $secret): \Appwrite\Models\ */ public function getSession(string $sessionId): \Appwrite\Models\Session { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1852,6 +1853,10 @@ public function getSession(string $sessionId): \Appwrite\Models\Session */ public function updateSession(string $sessionId): \Appwrite\Models\Session { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1891,6 +1896,10 @@ public function updateSession(string $sessionId): \Appwrite\Models\Session */ public function deleteSession(string $sessionId): string { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1903,6 +1912,7 @@ public function deleteSession(string $sessionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2068,6 +2078,10 @@ public function createMagicURLToken(string $userId, string $email, ?string $url * session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) * endpoint. * + * If there is already an active session, the OAuth2 identity is attached to + * the logged-in account and that session stays active until the token is + * exchanged for a new one. + * * A user is limited to 10 active sessions at a time by default. [Learn more * about session * limits](https://appwrite.io/docs/authentication-security#limits). diff --git a/src/Appwrite/Services/Activities.php b/src/Appwrite/Services/Activities.php index 4cb0ebb3..c5398cf0 100644 --- a/src/Appwrite/Services/Activities.php +++ b/src/Appwrite/Services/Activities.php @@ -54,6 +54,10 @@ public function listEvents(?array $queries = null): \Appwrite\Models\ActivityEve */ public function getEvent(string $eventId): \Appwrite\Models\ActivityEvent { + if ($eventId === '') { + throw new AppwriteException('Missing required parameter: "eventId"'); + } + $apiPath = str_replace( ['{eventId}'], [$eventId], diff --git a/src/Appwrite/Services/Advisor.php b/src/Appwrite/Services/Advisor.php index c09f9170..cc99a1ea 100644 --- a/src/Appwrite/Services/Advisor.php +++ b/src/Appwrite/Services/Advisor.php @@ -60,6 +60,10 @@ public function listReports(?array $queries = null, ?bool $total = null): \Appwr */ public function getReport(string $reportId): \Appwrite\Models\Report { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -95,6 +99,10 @@ public function getReport(string $reportId): \Appwrite\Models\Report */ public function deleteReport(string $reportId): string { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -107,6 +115,7 @@ public function deleteReport(string $reportId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -124,6 +133,10 @@ public function deleteReport(string $reportId): string */ public function listInsights(string $reportId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\InsightList { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -166,6 +179,14 @@ public function listInsights(string $reportId, ?array $queries = null, ?bool $to */ public function getInsight(string $reportId, string $insightId): \Appwrite\Models\Insight { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + + if ($insightId === '') { + throw new AppwriteException('Missing required parameter: "insightId"'); + } + $apiPath = str_replace( ['{reportId}', '{insightId}'], [$reportId, $insightId], diff --git a/src/Appwrite/Services/Apps.php b/src/Appwrite/Services/Apps.php index c66741f0..64162fa7 100644 --- a/src/Appwrite/Services/Apps.php +++ b/src/Appwrite/Services/Apps.php @@ -225,6 +225,10 @@ public function listOAuth2Scopes(): \Appwrite\Models\AppScopeList */ public function get(string $appId): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -259,6 +263,10 @@ public function get(string $appId): \Appwrite\Models\App */ public function update(string $appId, string $name, ?string $description = null, ?string $clientUri = null, ?string $logoUri = null, ?string $privacyPolicyUrl = null, ?string $termsUrl = null, ?array $contacts = null, ?string $tagline = null, ?array $tags = null, ?array $images = null, ?string $supportUrl = null, ?string $dataDeletionUrl = null, ?bool $enabled = null, ?array $redirectUris = null, ?array $postLogoutRedirectUris = null, ?string $type = null, ?bool $deviceFlow = null, ?array $installationScopes = null, ?string $installationRedirectUrl = null): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -367,6 +375,10 @@ public function update(string $appId, string $name, ?string $description = null, */ public function delete(string $appId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -398,6 +410,10 @@ public function delete(string $appId): string */ public function listInstallations(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppInstallationList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -442,6 +458,14 @@ public function listInstallations(string $appId, ?array $queries = null, ?bool $ */ public function getInstallation(string $appId, string $installationId): \Appwrite\Models\AppInstallation { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -479,6 +503,14 @@ public function getInstallation(string $appId, string $installationId): \Appwrit */ public function deleteInstallation(string $appId, string $installationId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -516,6 +548,14 @@ public function deleteInstallation(string $appId, string $installationId): strin */ public function createInstallationToken(string $appId, string $installationId): \Appwrite\Models\Oauth2Token { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -552,6 +592,10 @@ public function createInstallationToken(string $appId, string $installationId): */ public function listKeys(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppKeyList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -596,6 +640,10 @@ public function listKeys(string $appId, ?array $queries = null, ?bool $total = n */ public function createKey(string $appId): \Appwrite\Models\AppKey { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -631,6 +679,14 @@ public function createKey(string $appId): \Appwrite\Models\AppKey */ public function getKey(string $appId, string $keyId): \Appwrite\Models\AppKey { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{appId}', '{keyId}'], [$appId, $keyId], @@ -666,6 +722,14 @@ public function getKey(string $appId, string $keyId): \Appwrite\Models\AppKey */ public function deleteKey(string $appId, string $keyId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{appId}', '{keyId}'], [$appId, $keyId], @@ -698,6 +762,10 @@ public function deleteKey(string $appId, string $keyId): string */ public function updateLabels(string $appId, array $labels): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -734,6 +802,10 @@ public function updateLabels(string $appId, array $labels): \Appwrite\Models\App */ public function listSecrets(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppSecretList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -776,6 +848,10 @@ public function listSecrets(string $appId, ?array $queries = null, ?bool $total */ public function createSecret(string $appId): \Appwrite\Models\AppSecretPlaintext { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -811,6 +887,14 @@ public function createSecret(string $appId): \Appwrite\Models\AppSecretPlaintext */ public function getSecret(string $appId, string $secretId): \Appwrite\Models\AppSecret { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($secretId === '') { + throw new AppwriteException('Missing required parameter: "secretId"'); + } + $apiPath = str_replace( ['{appId}', '{secretId}'], [$appId, $secretId], @@ -846,6 +930,14 @@ public function getSecret(string $appId, string $secretId): \Appwrite\Models\App */ public function deleteSecret(string $appId, string $secretId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($secretId === '') { + throw new AppwriteException('Missing required parameter: "secretId"'); + } + $apiPath = str_replace( ['{appId}', '{secretId}'], [$appId, $secretId], @@ -876,6 +968,10 @@ public function deleteSecret(string $appId, string $secretId): string */ public function updateTeam(string $appId, string $teamId): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -912,6 +1008,10 @@ public function updateTeam(string $appId, string $teamId): \Appwrite\Models\App */ public function deleteTokens(string $appId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index ba8f5c11..eb5fa3a8 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -298,9 +298,9 @@ public function getInitials(?string $name = null, ?int $width = null, ?int $heig /** * Returns the best available profile photo for a user. The endpoint tries - * each source in priority order and returns the first successful result: - * OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in - * static fallback. + * each source in priority order and returns the first successful result: a + * custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, + * Gravatar, Libravatar, Appwrite Initials, built-in static fallback. * * Passing `userId` — `current()` for the authenticated user — resolves * the photo from everything known about that user: identity photos, email, diff --git a/src/Appwrite/Services/Backups.php b/src/Appwrite/Services/Backups.php index b67014b4..9b22277b 100644 --- a/src/Appwrite/Services/Backups.php +++ b/src/Appwrite/Services/Backups.php @@ -90,6 +90,10 @@ public function createArchive(array $services, ?string $resourceId = null): \App */ public function getArchive(string $archiveId): \Appwrite\Models\BackupArchive { + if ($archiveId === '') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + $apiPath = str_replace( ['{archiveId}'], [$archiveId], @@ -124,6 +128,10 @@ public function getArchive(string $archiveId): \Appwrite\Models\BackupArchive */ public function deleteArchive(string $archiveId): string { + if ($archiveId === '') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + $apiPath = str_replace( ['{archiveId}'], [$archiveId], @@ -237,6 +245,10 @@ public function createPolicy(string $policyId, array $services, int $retention, */ public function getPolicy(string $policyId): \Appwrite\Models\BackupPolicy { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -271,6 +283,10 @@ public function getPolicy(string $policyId): \Appwrite\Models\BackupPolicy */ public function updatePolicy(string $policyId, ?string $name = null, ?int $retention = null, ?string $schedule = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -313,6 +329,10 @@ public function updatePolicy(string $policyId, ?string $name = null, ?int $reten */ public function deletePolicy(string $policyId): string { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -453,6 +473,10 @@ public function listRestorations(?array $queries = null): \Appwrite\Models\Backu */ public function getRestoration(string $restorationId): \Appwrite\Models\BackupRestoration { + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{restorationId}'], [$restorationId], diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 6dd497fe..60caec64 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -200,6 +200,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -237,6 +241,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -283,6 +291,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -295,6 +307,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -314,6 +327,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -357,6 +374,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -394,6 +415,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, ?string $name = null, ?bool $enabled = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -441,6 +466,10 @@ public function update(string $databaseId, ?string $name = null, ?bool $enabled */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -453,6 +482,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -473,6 +503,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\CollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -525,6 +559,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?array $attributes = null, ?array $indexes = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -583,6 +621,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -621,6 +667,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, ?string $name = null, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -678,6 +732,14 @@ public function updateCollection(string $databaseId, string $collectionId, ?stri */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -691,6 +753,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -710,6 +773,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listAttributes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AttributeList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -757,6 +828,14 @@ public function listAttributes(string $databaseId, string $collectionId, ?array */ public function createBigIntAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -806,6 +885,18 @@ public function createBigIntAttribute(string $databaseId, string $collectionId, */ public function updateBigIntAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\AttributeBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -851,6 +942,14 @@ public function updateBigIntAttribute(string $databaseId, string $collectionId, */ public function createBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -898,6 +997,18 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, */ public function updateBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -941,6 +1052,14 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, */ public function createDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -988,6 +1107,18 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId */ public function updateDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1031,6 +1162,14 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId */ public function createEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1078,6 +1217,18 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s */ public function updateEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1122,6 +1273,14 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s */ public function createEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1170,6 +1329,18 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st */ public function updateEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1215,6 +1386,14 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st */ public function createFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1264,6 +1443,18 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s */ public function updateFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): \Appwrite\Models\AttributeFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1310,6 +1501,14 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s */ public function createIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1359,6 +1558,18 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, */ public function updateIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\AttributeInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1404,6 +1615,14 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, */ public function createIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1451,6 +1670,18 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri */ public function updateIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1494,6 +1725,14 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri */ public function createLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributeLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1537,6 +1776,18 @@ public function createLineAttribute(string $databaseId, string $collectionId, st */ public function updateLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributeLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1580,6 +1831,14 @@ public function updateLineAttribute(string $databaseId, string $collectionId, st */ public function createLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1631,6 +1890,18 @@ public function createLongtextAttribute(string $databaseId, string $collectionId */ public function updateLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1674,6 +1945,14 @@ public function updateLongtextAttribute(string $databaseId, string $collectionId */ public function createMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1725,6 +2004,18 @@ public function createMediumtextAttribute(string $databaseId, string $collection */ public function updateMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1768,6 +2059,14 @@ public function updateMediumtextAttribute(string $databaseId, string $collection */ public function createPointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributePoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1811,6 +2110,18 @@ public function createPointAttribute(string $databaseId, string $collectionId, s */ public function updatePointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributePoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1854,6 +2165,14 @@ public function updatePointAttribute(string $databaseId, string $collectionId, s */ public function createPolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributePolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1897,6 +2216,18 @@ public function createPolygonAttribute(string $databaseId, string $collectionId, */ public function updatePolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributePolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1941,6 +2272,14 @@ public function updatePolygonAttribute(string $databaseId, string $collectionId, */ public function createRelationshipAttribute(string $databaseId, string $collectionId, string $relatedCollectionId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): \Appwrite\Models\AttributeRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1993,6 +2332,18 @@ public function createRelationshipAttribute(string $databaseId, string $collecti */ public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\AttributeRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2038,6 +2389,14 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti */ public function createStringAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2090,6 +2449,18 @@ public function createStringAttribute(string $databaseId, string $collectionId, */ public function updateStringAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2134,6 +2505,14 @@ public function updateStringAttribute(string $databaseId, string $collectionId, */ public function createTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2185,6 +2564,18 @@ public function createTextAttribute(string $databaseId, string $collectionId, st */ public function updateTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2228,6 +2619,14 @@ public function updateTextAttribute(string $databaseId, string $collectionId, st */ public function createUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2275,6 +2674,18 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str */ public function updateUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2318,6 +2729,14 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str */ 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 { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2370,6 +2789,18 @@ public function createVarcharAttribute(string $databaseId, string $collectionId, */ public function updateVarcharAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\AttributeVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2412,8 +2843,20 @@ public function updateVarcharAttribute(string $databaseId, string $collectionId, * @deprecated This API has been deprecated since 1.8.0. Please use `getColumn` instead. * @see TablesDB::getColumn */ - public function getAttribute(string $databaseId, string $collectionId, string $key): \Appwrite\Models\AttributeBoolean|\Appwrite\Models\AttributeInteger|\Appwrite\Models\AttributeFloat|\Appwrite\Models\AttributeEmail|\Appwrite\Models\AttributeEnum|\Appwrite\Models\AttributeUrl|\Appwrite\Models\AttributeIp|\Appwrite\Models\AttributeDatetime|\Appwrite\Models\AttributeRelationship|\Appwrite\Models\AttributeString + public function getAttribute(string $databaseId, string $collectionId, string $key): \Appwrite\Models\AttributeBoolean|\Appwrite\Models\AttributeBigint|\Appwrite\Models\AttributeInteger|\Appwrite\Models\AttributeFloat|\Appwrite\Models\AttributeEmail|\Appwrite\Models\AttributeEnum|\Appwrite\Models\AttributeUrl|\Appwrite\Models\AttributeIp|\Appwrite\Models\AttributeDatetime|\Appwrite\Models\AttributeRelationship|\Appwrite\Models\AttributePoint|\Appwrite\Models\AttributeLine|\Appwrite\Models\AttributePolygon|\Appwrite\Models\AttributeVarchar|\Appwrite\Models\AttributeText|\Appwrite\Models\AttributeMediumtext|\Appwrite\Models\AttributeLongtext|\Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2460,6 +2903,10 @@ public function getAttribute(string $databaseId, string $collectionId, string $k return \Appwrite\Models\AttributeBoolean::from($response); } + if (($response['type'] ?? null) === 'bigint') { + return \Appwrite\Models\AttributeBigint::from($response); + } + if (($response['type'] ?? null) === 'integer') { return \Appwrite\Models\AttributeInteger::from($response); } @@ -2476,6 +2923,34 @@ public function getAttribute(string $databaseId, string $collectionId, string $k return \Appwrite\Models\AttributeRelationship::from($response); } + if (($response['type'] ?? null) === 'point') { + return \Appwrite\Models\AttributePoint::from($response); + } + + if (($response['type'] ?? null) === 'linestring') { + return \Appwrite\Models\AttributeLine::from($response); + } + + if (($response['type'] ?? null) === 'polygon') { + return \Appwrite\Models\AttributePolygon::from($response); + } + + if (($response['type'] ?? null) === 'varchar') { + return \Appwrite\Models\AttributeVarchar::from($response); + } + + if (($response['type'] ?? null) === 'text') { + return \Appwrite\Models\AttributeText::from($response); + } + + if (($response['type'] ?? null) === 'mediumtext') { + return \Appwrite\Models\AttributeMediumtext::from($response); + } + + if (($response['type'] ?? null) === 'longtext') { + return \Appwrite\Models\AttributeLongtext::from($response); + } + if (($response['type'] ?? null) === 'string') { return \Appwrite\Models\AttributeString::from($response); } @@ -2493,6 +2968,18 @@ public function getAttribute(string $databaseId, string $collectionId, string $k */ public function deleteAttribute(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2507,6 +2994,7 @@ public function deleteAttribute(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2527,6 +3015,14 @@ public function deleteAttribute(string $databaseId, string $collectionId, string */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2584,6 +3080,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2630,6 +3134,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2674,6 +3186,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2717,6 +3237,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2766,6 +3294,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2814,6 +3350,18 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2864,6 +3412,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2911,6 +3471,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2957,6 +3529,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2975,6 +3559,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2994,6 +3579,22 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -3041,6 +3642,22 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -3088,6 +3705,14 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -3127,7 +3752,9 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu /** * Creates an index on the attributes listed. Your index should include all * the attributes you will query in a single request. - * Attributes can be `key`, `fulltext`, and `unique`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + * `trigram` is only available on PostgreSQL and lets `contains`, + * `startsWith`, and `endsWith` queries on string attributes use an index. * * @throws AppwriteException * @@ -3136,6 +3763,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, DatabasesIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -3186,6 +3821,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -3225,6 +3872,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -3239,6 +3898,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/DocumentsDB.php b/src/Appwrite/Services/DocumentsDB.php index 4e0e734f..efaef6eb 100644 --- a/src/Appwrite/Services/DocumentsDB.php +++ b/src/Appwrite/Services/DocumentsDB.php @@ -104,8 +104,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -223,6 +223,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -257,6 +261,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -300,6 +308,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -312,6 +324,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -328,6 +341,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -368,6 +385,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -402,6 +423,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, string $name, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -446,6 +471,10 @@ public function update(string $databaseId, string $name, ?bool $enabled = null, */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -458,6 +487,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -475,6 +505,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\CollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -524,6 +558,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?array $attributes = null, ?array $indexes = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -579,6 +617,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -614,6 +660,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -668,6 +722,14 @@ public function updateCollection(string $databaseId, string $collectionId, strin */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -681,6 +743,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -698,6 +761,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -752,6 +823,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -801,6 +880,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -845,6 +932,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -888,6 +983,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -937,6 +1040,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -982,6 +1093,18 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1029,6 +1152,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1079,6 +1214,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1128,6 +1275,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1146,6 +1305,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1162,6 +1322,22 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -1212,6 +1388,22 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -1262,6 +1454,14 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1307,6 +1507,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, DocumentsDBIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1354,6 +1562,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1390,6 +1610,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1404,6 +1636,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1428,6 +1661,10 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1467,6 +1704,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1514,6 +1755,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1550,6 +1795,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index d1bb5dda..7ad73978 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -268,6 +268,10 @@ public function listSpecifications(?string $type = null, ?bool $total = null): \ */ public function get(string $functionId): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -300,8 +304,12 @@ public function get(string $functionId): \Appwrite\Models\FunctionModel * * @throws AppwriteException */ - public function update(string $functionId, string $name, ?Runtime $runtime = null, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?int $interval = null): \Appwrite\Models\FunctionModel + public function update(string $functionId, string $name, ?Runtime $runtime = null, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?int $interval = null, ?bool $emailEnabled = null): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -377,6 +385,7 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul $apiParams['deploymentRetention'] = $deploymentRetention; } $apiParams['interval'] = $interval; + $apiParams['emailEnabled'] = $emailEnabled; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -404,6 +413,10 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul */ public function delete(string $functionId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -416,6 +429,7 @@ public function delete(string $functionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -433,6 +447,10 @@ public function delete(string $functionId): string */ public function updateFunctionDeployment(string $functionId, string $deploymentId): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -470,6 +488,10 @@ public function updateFunctionDeployment(string $functionId, string $deploymentI */ public function listDeployments(string $functionId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\DeploymentList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -525,6 +547,10 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str */ public function createDeployment(string $functionId, InputFile $code, bool $activate, ?string $entrypoint = null, ?string $commands = null, ?callable $onProgress = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -548,9 +574,6 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($code->getPath() ?? null)) { $size = strlen($code->getData()); $mimeType = $code->getMimeType(); @@ -704,6 +727,10 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti */ public function createDuplicateDeployment(string $functionId, string $deploymentId, ?string $buildId = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -748,6 +775,10 @@ public function createDuplicateDeployment(string $functionId, string $deployment */ public function createTemplateDeployment(string $functionId, string $repository, string $owner, string $rootDirectory, TemplateReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -794,6 +825,10 @@ public function createTemplateDeployment(string $functionId, string $repository, */ public function createVcsDeployment(string $functionId, VCSReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -835,6 +870,14 @@ public function createVcsDeployment(string $functionId, VCSReferenceType $type, */ public function getDeployment(string $functionId, string $deploymentId): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -870,6 +913,14 @@ public function getDeployment(string $functionId, string $deploymentId): \Appwri */ public function deleteDeployment(string $functionId, string $deploymentId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -883,6 +934,7 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -901,6 +953,14 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri */ public function getDeploymentDownload(string $functionId, string $deploymentId, ?DeploymentDownloadType $type = null, ?string $token = null): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -942,6 +1002,14 @@ public function getDeploymentDownload(string $functionId, string $deploymentId, */ public function updateDeploymentStatus(string $functionId, string $deploymentId): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -979,6 +1047,10 @@ public function updateDeploymentStatus(string $functionId, string $deploymentId) */ public function listExecutions(string $functionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ExecutionList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1024,6 +1096,10 @@ public function listExecutions(string $functionId, ?array $queries = null, ?bool */ public function createExecution(string $functionId, ?string $body = null, ?bool $async = null, ?string $xpath = null, ?ExecutionMethod $method = null, ?array $headers = null, ?string $scheduledAt = null): \Appwrite\Models\Execution { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1080,6 +1156,14 @@ public function createExecution(string $functionId, ?string $body = null, ?bool */ public function getExecution(string $functionId, string $executionId): \Appwrite\Models\Execution { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($executionId === '') { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + $apiPath = str_replace( ['{functionId}', '{executionId}'], [$functionId, $executionId], @@ -1115,6 +1199,14 @@ public function getExecution(string $functionId, string $executionId): \Appwrite */ public function deleteExecution(string $functionId, string $executionId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($executionId === '') { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + $apiPath = str_replace( ['{functionId}', '{executionId}'], [$functionId, $executionId], @@ -1128,6 +1220,7 @@ public function deleteExecution(string $functionId, string $executionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1144,6 +1237,10 @@ public function deleteExecution(string $functionId, string $executionId): string */ public function listVariables(string $functionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\VariableList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1187,6 +1284,10 @@ public function listVariables(string $functionId, ?array $queries = null, ?bool */ public function createVariable(string $functionId, string $variableId, string $key, string $value, ?bool $secret = null): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1229,6 +1330,14 @@ public function createVariable(string $functionId, string $variableId, string $k */ public function getVariable(string $functionId, string $variableId): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1264,6 +1373,14 @@ public function getVariable(string $functionId, string $variableId): \Appwrite\M */ public function updateVariable(string $functionId, string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1303,6 +1420,14 @@ public function updateVariable(string $functionId, string $variableId, ?string $ */ public function deleteVariable(string $functionId, string $variableId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1316,6 +1441,7 @@ public function deleteVariable(string $functionId, string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Messaging.php b/src/Appwrite/Services/Messaging.php index 053d0e67..af0072de 100644 --- a/src/Appwrite/Services/Messaging.php +++ b/src/Appwrite/Services/Messaging.php @@ -94,10 +94,7 @@ public function createEmail(string $messageId, string $subject, string $content, if (!is_null($bcc)) { $apiParams['bcc'] = $bcc; } - - if (!is_null($attachments)) { - $apiParams['attachments'] = $attachments; - } + $apiParams['attachments'] = $attachments; if (!is_null($draft)) { $apiParams['draft'] = $draft; @@ -144,6 +141,10 @@ public function createEmail(string $messageId, string $subject, string $content, */ public function updateEmail(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $subject = null, ?string $content = null, ?bool $draft = null, ?bool $html = null, ?array $cc = null, ?array $bcc = null, ?string $scheduledAt = null, ?array $attachments = null, ?string $replyToEmail = null, ?string $replyToName = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -299,6 +300,10 @@ public function createPush(string $messageId, ?string $title = null, ?string $bo */ public function updatePush(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $title = null, ?string $body = null, ?array $data = null, ?string $action = null, ?string $image = null, ?string $icon = null, ?string $sound = null, ?string $color = null, ?string $tag = null, ?int $badge = null, ?bool $draft = null, ?string $scheduledAt = null, ?bool $contentAvailable = null, ?bool $critical = null, ?MessagePriority $priority = null, ?string $channelId = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -408,6 +413,10 @@ public function createSMS(string $messageId, string $content, ?array $topics = n */ public function updateSMS(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $content = null, ?bool $draft = null, ?string $scheduledAt = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -449,6 +458,10 @@ public function updateSMS(string $messageId, ?array $topics = null, ?array $user */ public function getMessage(string $messageId): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -484,6 +497,10 @@ public function getMessage(string $messageId): \Appwrite\Models\Message */ public function delete(string $messageId): string { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -496,6 +513,7 @@ public function delete(string $messageId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -512,6 +530,10 @@ public function delete(string $messageId): string */ public function listTargets(string $messageId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\TargetList { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -656,6 +678,10 @@ public function createAPNSProvider(string $providerId, string $name, ?string $au */ public function updateAPNSProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $authKey = null, ?string $authKeyId = null, ?string $teamId = null, ?string $bundleId = null, ?bool $sandbox = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -836,6 +862,10 @@ public function createFCMProvider(string $providerId, string $name, ?array $serv */ public function updateFCMProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?array $serviceAccountJSON = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -939,6 +969,10 @@ public function createMailgunProvider(string $providerId, string $name, ?string */ public function updateMailgunProvider(string $providerId, ?string $name = null, ?string $apiKey = null, ?string $domain = null, ?bool $isEuRegion = null, ?bool $enabled = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1053,6 +1087,10 @@ public function createMsg91Provider(string $providerId, string $name, ?string $t */ public function updateMsg91Provider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $templateId = null, ?string $senderId = null, ?string $authKey = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1162,6 +1200,10 @@ public function createResendProvider(string $providerId, string $name, ?string $ */ public function updateResendProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1279,6 +1321,10 @@ public function createSendgridProvider(string $providerId, string $name, ?string */ public function updateSendgridProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1404,6 +1450,10 @@ public function createSesProvider(string $providerId, string $name, ?string $acc */ public function updateSesProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $accessKey = null, ?string $secretKey = null, ?string $region = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1550,6 +1600,10 @@ public function createSMTPProvider(string $providerId, string $name, string $hos */ public function updateSMTPProvider(string $providerId, ?string $name = null, ?string $host = null, ?int $port = null, ?string $username = null, ?string $password = null, ?SmtpEncryption $encryption = null, ?bool $autoTLS = null, ?string $mailer = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null, ?bool $enabled = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1677,6 +1731,10 @@ public function createTelesignProvider(string $providerId, string $name, ?string */ public function updateTelesignProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $customerId = null, ?string $apiKey = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1778,6 +1836,10 @@ public function createTextmagicProvider(string $providerId, string $name, ?strin */ public function updateTextmagicProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $username = null, ?string $apiKey = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1879,6 +1941,10 @@ public function createTwilioProvider(string $providerId, string $name, ?string $ */ public function updateTwilioProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $accountSid = null, ?string $authToken = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1980,6 +2046,10 @@ public function createVonageProvider(string $providerId, string $name, ?string $ */ public function updateVonageProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $apiSecret = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2032,6 +2102,10 @@ public function updateVonageProvider(string $providerId, ?string $name = null, ? */ public function getProvider(string $providerId): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2066,6 +2140,10 @@ public function getProvider(string $providerId): \Appwrite\Models\Provider */ public function deleteProvider(string $providerId): string { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2078,6 +2156,7 @@ public function deleteProvider(string $providerId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2181,6 +2260,10 @@ public function createTopic(string $topicId, string $name, ?array $subscribe = n */ public function getTopic(string $topicId): \Appwrite\Models\Topic { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2215,6 +2298,10 @@ public function getTopic(string $topicId): \Appwrite\Models\Topic */ public function updateTopic(string $topicId, ?string $name = null, ?array $subscribe = null, ?int $qos = null, ?int $expiry = null): \Appwrite\Models\Topic { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2254,6 +2341,10 @@ public function updateTopic(string $topicId, ?string $name = null, ?array $subsc */ public function deleteTopic(string $topicId): string { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2266,6 +2357,7 @@ public function deleteTopic(string $topicId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2282,6 +2374,10 @@ public function deleteTopic(string $topicId): string */ public function listSubscribers(string $topicId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\SubscriberList { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2328,6 +2424,10 @@ public function listSubscribers(string $topicId, ?array $queries = null, ?string */ public function createSubscriber(string $topicId, string $subscriberId, string $targetId): \Appwrite\Models\Subscriber { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2365,6 +2465,14 @@ public function createSubscriber(string $topicId, string $subscriberId, string $ */ public function getSubscriber(string $topicId, string $subscriberId): \Appwrite\Models\Subscriber { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + if ($subscriberId === '') { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + $apiPath = str_replace( ['{topicId}', '{subscriberId}'], [$topicId, $subscriberId], @@ -2400,6 +2508,14 @@ public function getSubscriber(string $topicId, string $subscriberId): \Appwrite\ */ public function deleteSubscriber(string $topicId, string $subscriberId): string { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + if ($subscriberId === '') { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + $apiPath = str_replace( ['{topicId}', '{subscriberId}'], [$topicId, $subscriberId], @@ -2413,6 +2529,7 @@ public function deleteSubscriber(string $topicId, string $subscriberId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Mongo.php b/src/Appwrite/Services/Mongo.php index 21771ece..82e35d35 100644 --- a/src/Appwrite/Services/Mongo.php +++ b/src/Appwrite/Services/Mongo.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -849,6 +938,10 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -887,6 +980,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -927,6 +1024,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -967,6 +1068,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1014,6 +1119,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1049,6 +1158,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1084,6 +1197,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1133,10 +1250,25 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st * an ISO 8601 datetime. PITR requires the database to have PITR enabled and * is only available for enterprise databases. * + * By default the backup is replayed over the database it was taken from. Pass + * `restoreMode` as `clone` to recover it onto a second workload beside this + * database instead: this database keeps serving its own data while the clone + * is filled, and the switch happens as soon as the clone is ready, on the + * endpoint and credentials it already had. Pass `autoPromote` as false to + * hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + * to recover onto a separate database with its own endpoint, either one you + * name with `targetDatabaseId` or one provisioned as a copy of this + * database's engine, version, specification and replicas. Neither mode is + * available for a point-in-time recovery or an incremental backup. + * * @throws AppwriteException */ - public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration + public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null, ?string $restoreMode = null, ?string $targetName = null, ?bool $autoPromote = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1152,6 +1284,12 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str $apiParams['backupId'] = $backupId; $apiParams['targetDatabaseId'] = $targetDatabaseId; $apiParams['targetTime'] = $targetTime; + $apiParams['restoreMode'] = $restoreMode; + $apiParams['targetName'] = $targetName; + + if (!is_null($autoPromote)) { + $apiParams['autoPromote'] = $autoPromote; + } $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -1180,6 +1318,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1208,6 +1354,55 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw return \Appwrite\Models\DedicatedDatabaseRestoration::from($response); } + /** + * Switch the database over to the clone a restoration recovered. The database + * keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained + * briefly so + * the switch can be reversed. + * + * @throws AppwriteException + */ + public function promoteRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration + { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + + $apiPath = str_replace( + ['{databaseId}', '{restorationId}'], + [$databaseId, $restorationId], + '/mongo/{databaseId}/restorations/{restorationId}/promotions' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['restorationId'] = $restorationId; + + $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\DedicatedDatabaseRestoration::from($response); + } + /** * Get real-time health and status information for a dedicated database. * Returns health status, readiness, uptime, connection info, replica status, @@ -1217,6 +1412,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1252,6 +1451,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Mysql.php b/src/Appwrite/Services/Mysql.php index 95f4cd35..f3f089ee 100644 --- a/src/Appwrite/Services/Mysql.php +++ b/src/Appwrite/Services/Mysql.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -844,11 +933,19 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate * without a per-query cloud round-trip. The statement type must be on the * database's configured allow-list. Use bound parameters for any * user-supplied values — the API does not interpolate raw strings. + * Long-running statements (for example CREATE INDEX) can outlive the HTTP + * request: if the request ends before a result is returned, check the + * database before retrying, and prefer a direct connection for work that may + * take minutes. * * @throws AppwriteException */ public function createExecution(string $databaseId, string $sql, ?array $bindings = null, ?int $timeoutSeconds = null): \Appwrite\Models\DedicatedDatabaseExecution { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -895,6 +992,10 @@ public function createExecution(string $databaseId, string $sql, ?array $binding */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -933,6 +1034,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -973,6 +1078,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1013,6 +1122,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1060,6 +1173,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1095,6 +1212,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1130,6 +1251,10 @@ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabas */ public function updatePooler(string $databaseId, ?string $mode = null, ?int $maxConnections = null, ?int $defaultPoolSize = null, ?bool $readWriteSplitting = null, ?string $poolerCpuRequest = null, ?string $poolerCpuLimit = null, ?string $poolerMemoryRequest = null, ?string $poolerMemoryLimit = null): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1174,6 +1299,10 @@ public function updatePooler(string $databaseId, ?string $mode = null, ?int $max */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1209,6 +1338,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1258,10 +1391,25 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st * an ISO 8601 datetime. PITR requires the database to have PITR enabled and * is only available for enterprise databases. * + * By default the backup is replayed over the database it was taken from. Pass + * `restoreMode` as `clone` to recover it onto a second workload beside this + * database instead: this database keeps serving its own data while the clone + * is filled, and the switch happens as soon as the clone is ready, on the + * endpoint and credentials it already had. Pass `autoPromote` as false to + * hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + * to recover onto a separate database with its own endpoint, either one you + * name with `targetDatabaseId` or one provisioned as a copy of this + * database's engine, version, specification and replicas. Neither mode is + * available for a point-in-time recovery or an incremental backup. + * * @throws AppwriteException */ - public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration + public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null, ?string $restoreMode = null, ?string $targetName = null, ?bool $autoPromote = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1277,6 +1425,12 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str $apiParams['backupId'] = $backupId; $apiParams['targetDatabaseId'] = $targetDatabaseId; $apiParams['targetTime'] = $targetTime; + $apiParams['restoreMode'] = $restoreMode; + $apiParams['targetName'] = $targetName; + + if (!is_null($autoPromote)) { + $apiParams['autoPromote'] = $autoPromote; + } $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -1305,6 +1459,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1333,6 +1495,55 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw return \Appwrite\Models\DedicatedDatabaseRestoration::from($response); } + /** + * Switch the database over to the clone a restoration recovered. The database + * keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained + * briefly so + * the switch can be reversed. + * + * @throws AppwriteException + */ + public function promoteRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration + { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + + $apiPath = str_replace( + ['{databaseId}', '{restorationId}'], + [$databaseId, $restorationId], + '/mysql/{databaseId}/restorations/{restorationId}/promotions' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['restorationId'] = $restorationId; + + $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\DedicatedDatabaseRestoration::from($response); + } + /** * Get real-time health and status information for a dedicated database. * Returns health status, readiness, uptime, connection info, replica status, @@ -1342,6 +1553,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1377,6 +1592,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Oauth2.php b/src/Appwrite/Services/Oauth2.php index 45d4927a..e246e345 100644 --- a/src/Appwrite/Services/Oauth2.php +++ b/src/Appwrite/Services/Oauth2.php @@ -65,7 +65,7 @@ public function approve(string $grantId, ?string $authorizationDetails = null, ? * * @throws AppwriteException */ - public function authorize(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize + public function authorize(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize { $apiPath = str_replace( ['{project_id}'], @@ -157,7 +157,7 @@ public function authorize(?string $clientId = null, ?string $redirectUri = null, * * @throws AppwriteException */ - public function authorizePost(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize + public function authorizePost(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize { $apiPath = str_replace( ['{project_id}'], @@ -244,7 +244,7 @@ public function authorizePost(?string $clientId = null, ?string $redirectUri = n * * @throws AppwriteException */ - public function createDeviceAuthorization(?string $clientId = null, ?string $scope = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2DeviceAuthorization + public function createDeviceAuthorization(?string $clientId = null, ?string $scope = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2DeviceAuthorization { $apiPath = str_replace( ['{project_id}'], @@ -338,6 +338,10 @@ public function createGrant(string $userCode): \Appwrite\Models\Oauth2Grant */ public function getGrant(string $grantId): \Appwrite\Models\Oauth2Grant { + if ($grantId === '') { + throw new AppwriteException('Missing required parameter: "grantId"'); + } + $apiPath = str_replace( ['{project_id}', '{grant_id}'], [$this->client->getConfig('project'), $grantId], @@ -465,7 +469,7 @@ public function listOrganizations(?int $limit = null, ?int $offset = null, ?stri * * @throws AppwriteException */ - public function createPAR(string $clientId, string $redirectUri, string $responseType, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2PAR + public function createPAR(string $clientId, string $redirectUri, string $responseType, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2PAR { $apiPath = str_replace( ['{project_id}'], @@ -662,7 +666,7 @@ public function revoke(string $token, ?string $tokenTypeHint = null, ?string $cl * * @throws AppwriteException */ - public function createToken(string $grantType, ?string $code = null, ?string $refreshToken = null, ?string $deviceCode = null, ?string $clientId = null, ?string $clientSecret = null, ?string $codeVerifier = null, ?string $redirectUri = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2Token + public function createToken(string $grantType, ?string $code = null, ?string $refreshToken = null, ?string $deviceCode = null, ?string $clientId = null, ?string $clientSecret = null, ?string $codeVerifier = null, ?string $redirectUri = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2Token { $apiPath = str_replace( ['{project_id}'], diff --git a/src/Appwrite/Services/Organization.php b/src/Appwrite/Services/Organization.php index 3b572126..d8be8f07 100644 --- a/src/Appwrite/Services/Organization.php +++ b/src/Appwrite/Services/Organization.php @@ -98,6 +98,7 @@ public function delete(): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -198,6 +199,10 @@ public function createInstallation(string $appId, ?string $authorizationDetails */ public function getInstallation(string $installationId): \Appwrite\Models\AppInstallation { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -235,6 +240,10 @@ public function getInstallation(string $installationId): \Appwrite\Models\AppIns */ public function updateInstallation(string $installationId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -273,6 +282,10 @@ public function updateInstallation(string $installationId, ?string $authorizatio */ public function deleteInstallation(string $installationId): string { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -295,188 +308,6 @@ public function deleteInstallation(string $installationId): string ); } - /** - * Get a list of all API keys from the current organization. - * - * @throws AppwriteException - */ - public function listKeys(?array $queries = null, ?bool $total = null): \Appwrite\Models\KeyList - { - $apiPath = str_replace( - [], - [], - '/organization/keys' - ); - - $apiParams = []; - - 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\KeyList::from($response); - } - - /** - * Create a new organization API key. - * - * @throws AppwriteException - */ - public function createKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key - { - $apiPath = str_replace( - [], - [], - '/organization/keys' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - $apiParams['name'] = $name; - $apiParams['scopes'] = $scopes; - $apiParams['expire'] = $expire; - - $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\Key::from($response); - } - - /** - * Get a key by its unique ID. This endpoint returns details about a specific - * API key in your organization including its scopes. - * - * @throws AppwriteException - */ - public function getKey(string $keyId): \Appwrite\Models\Key - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - - $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\Key::from($response); - } - - /** - * Update a key by its unique ID. Use this endpoint to update the name, - * scopes, or expiration time of an API key. - * - * @throws AppwriteException - */ - public function updateKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - $apiParams['name'] = $name; - $apiParams['scopes'] = $scopes; - $apiParams['expire'] = $expire; - - $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\Key::from($response); - } - - /** - * Delete a key by its unique ID. Once deleted, the key can no longer be used - * to authenticate API calls. - * - * @throws AppwriteException - */ - public function deleteKey(string $keyId): string - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - /** * Get a list of all memberships from the current organization. * @@ -586,6 +417,10 @@ public function createMembership(array $roles, ?string $email = null, ?string $u */ public function getMembership(string $membershipId): \Appwrite\Models\Membership { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -620,6 +455,10 @@ public function getMembership(string $membershipId): \Appwrite\Models\Membership */ public function updateMembership(string $membershipId, array $roles): \Appwrite\Models\Membership { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -658,6 +497,10 @@ public function updateMembership(string $membershipId, array $roles): \Appwrite\ */ public function deleteMembership(string $membershipId): string { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -670,6 +513,7 @@ public function deleteMembership(string $membershipId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -772,6 +616,10 @@ public function createProject(string $projectId, string $name, ?Region $region = */ public function getProject(string $projectId): \Appwrite\Models\Project { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -783,6 +631,7 @@ public function getProject(string $projectId): \Appwrite\Models\Project $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; $response = $this->client->call( Client::METHOD_GET, @@ -805,6 +654,10 @@ public function getProject(string $projectId): \Appwrite\Models\Project */ public function updateProject(string $projectId, string $name): \Appwrite\Models\Project { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -841,6 +694,10 @@ public function updateProject(string $projectId, string $name): \Appwrite\Models */ public function deleteProject(string $projectId): string { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -853,6 +710,7 @@ public function deleteProject(string $projectId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Postgresql.php b/src/Appwrite/Services/Postgresql.php index 536e5730..dfc1c870 100644 --- a/src/Appwrite/Services/Postgresql.php +++ b/src/Appwrite/Services/Postgresql.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -844,11 +933,19 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate * without a per-query cloud round-trip. The statement type must be on the * database's configured allow-list. Use bound parameters for any * user-supplied values — the API does not interpolate raw strings. + * Long-running statements (for example CREATE INDEX) can outlive the HTTP + * request: if the request ends before a result is returned, check the + * database before retrying, and prefer a direct connection for work that may + * take minutes. * * @throws AppwriteException */ public function createExecution(string $databaseId, string $sql, ?array $bindings = null, ?int $timeoutSeconds = null): \Appwrite\Models\DedicatedDatabaseExecution { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -887,6 +984,10 @@ public function createExecution(string $databaseId, string $sql, ?array $binding */ public function listExtensions(string $databaseId): \Appwrite\Models\DedicatedDatabaseExtensions { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -922,6 +1023,10 @@ public function listExtensions(string $databaseId): \Appwrite\Models\DedicatedDa */ public function createExtension(string $databaseId, string $name): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -959,6 +1064,14 @@ public function createExtension(string $databaseId, string $name): \Appwrite\Mod */ public function deleteExtension(string $databaseId, string $extensionName): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($extensionName === '') { + throw new AppwriteException('Missing required parameter: "extensionName"'); + } + $apiPath = str_replace( ['{databaseId}', '{extensionName}'], [$databaseId, $extensionName], @@ -1003,6 +1116,10 @@ public function deleteExtension(string $databaseId, string $extensionName): \App */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1041,6 +1158,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1081,6 +1202,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1121,6 +1246,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1168,6 +1297,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1203,6 +1336,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1238,6 +1375,10 @@ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabas */ public function updatePooler(string $databaseId, ?string $mode = null, ?int $maxConnections = null, ?int $defaultPoolSize = null, ?bool $readWriteSplitting = null, ?string $poolerCpuRequest = null, ?string $poolerCpuLimit = null, ?string $poolerMemoryRequest = null, ?string $poolerMemoryLimit = null): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1282,6 +1423,10 @@ public function updatePooler(string $databaseId, ?string $mode = null, ?int $max */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1317,6 +1462,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1366,10 +1515,25 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st * an ISO 8601 datetime. PITR requires the database to have PITR enabled and * is only available for enterprise databases. * + * By default the backup is replayed over the database it was taken from. Pass + * `restoreMode` as `clone` to recover it onto a second workload beside this + * database instead: this database keeps serving its own data while the clone + * is filled, and the switch happens as soon as the clone is ready, on the + * endpoint and credentials it already had. Pass `autoPromote` as false to + * hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + * to recover onto a separate database with its own endpoint, either one you + * name with `targetDatabaseId` or one provisioned as a copy of this + * database's engine, version, specification and replicas. Neither mode is + * available for a point-in-time recovery or an incremental backup. + * * @throws AppwriteException */ - public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration + public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null, ?string $restoreMode = null, ?string $targetName = null, ?bool $autoPromote = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1385,6 +1549,12 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str $apiParams['backupId'] = $backupId; $apiParams['targetDatabaseId'] = $targetDatabaseId; $apiParams['targetTime'] = $targetTime; + $apiParams['restoreMode'] = $restoreMode; + $apiParams['targetName'] = $targetName; + + if (!is_null($autoPromote)) { + $apiParams['autoPromote'] = $autoPromote; + } $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -1413,6 +1583,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1441,6 +1619,55 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw return \Appwrite\Models\DedicatedDatabaseRestoration::from($response); } + /** + * Switch the database over to the clone a restoration recovered. The database + * keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained + * briefly so + * the switch can be reversed. + * + * @throws AppwriteException + */ + public function promoteRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration + { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + + $apiPath = str_replace( + ['{databaseId}', '{restorationId}'], + [$databaseId, $restorationId], + '/postgresql/{databaseId}/restorations/{restorationId}/promotions' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['restorationId'] = $restorationId; + + $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\DedicatedDatabaseRestoration::from($response); + } + /** * Get real-time health and status information for a dedicated database. * Returns health status, readiness, uptime, connection info, replica status, @@ -1450,6 +1677,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1485,6 +1716,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Presences.php b/src/Appwrite/Services/Presences.php index 80f429c9..5a04fc40 100644 --- a/src/Appwrite/Services/Presences.php +++ b/src/Appwrite/Services/Presences.php @@ -63,6 +63,10 @@ public function list(?array $queries = null, ?bool $total = null, ?int $ttl = nu */ public function get(string $presenceId): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -97,6 +101,10 @@ public function get(string $presenceId): \Appwrite\Models\Presence */ public function upsert(string $presenceId, string $userId, string $status, ?array $permissions = null, ?string $expiresAt = null, ?array $metadata = null): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -147,6 +155,10 @@ public function upsert(string $presenceId, string $userId, string $status, ?arra */ public function update(string $presenceId, string $userId, ?string $status = null, ?string $expiresAt = null, ?array $metadata = null, ?array $permissions = null, ?bool $purge = null): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -203,6 +215,10 @@ public function update(string $presenceId, string $userId, ?string $status = nul */ public function delete(string $presenceId): string { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -215,6 +231,7 @@ public function delete(string $presenceId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Project.php b/src/Appwrite/Services/Project.php index 05577731..223a6273 100644 --- a/src/Appwrite/Services/Project.php +++ b/src/Appwrite/Services/Project.php @@ -35,6 +35,7 @@ public function get(): \Appwrite\Models\Project $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; $response = $this->client->call( Client::METHOD_GET, @@ -68,6 +69,7 @@ public function delete(): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -393,6 +395,10 @@ public function createEphemeralKey(array $scopes, int $duration): \Appwrite\Mode */ public function getKey(string $keyId): \Appwrite\Models\Key { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -428,6 +434,10 @@ public function getKey(string $keyId): \Appwrite\Models\Key */ public function updateKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -467,6 +477,10 @@ public function updateKey(string $keyId, string $name, array $scopes, ?string $e */ public function deleteKey(string $keyId): string { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -479,6 +493,7 @@ public function deleteKey(string $keyId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -611,6 +626,10 @@ public function createMockPhone(string $number, string $otp): \Appwrite\Models\M */ public function getMockPhone(string $number): \Appwrite\Models\MockNumber { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -646,6 +665,10 @@ public function getMockPhone(string $number): \Appwrite\Models\MockNumber */ public function updateMockPhone(string $number, string $otp): \Appwrite\Models\MockNumber { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -683,6 +706,10 @@ public function updateMockPhone(string $number, string $otp): \Appwrite\Models\M */ public function deleteMockPhone(string $number): string { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -695,6 +722,7 @@ public function deleteMockPhone(string $number): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1648,7 +1676,7 @@ public function updateOAuth2HuggingFace(?string $clientId = null, ?string $clien * * @throws AppwriteException */ - public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecret = null, ?array $prompt = null, ?bool $enabled = null): \Appwrite\Models\OAuth2Kakao + public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecret = null, ?bool $enabled = null, ?array $prompt = null): \Appwrite\Models\OAuth2Kakao { $apiPath = str_replace( [], @@ -1659,8 +1687,8 @@ public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecre $apiParams = []; $apiParams['clientId'] = $clientId; $apiParams['clientSecret'] = $clientSecret; - $apiParams['prompt'] = $prompt; $apiParams['enabled'] = $enabled; + $apiParams['prompt'] = $prompt; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -2964,12 +2992,16 @@ public function createAndroidPlatform(string $platformId, string $name, string $ /** * Update an Android platform by its unique ID. Use this endpoint to update - * the platform's name or application ID. + * the platform's name, application ID or signing certificate fingerprints. * * @throws AppwriteException */ public function updateAndroidPlatform(string $platformId, string $name, string $applicationId, ?array $fingerprints = null): \Appwrite\Models\PlatformAndroid { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3048,6 +3080,10 @@ public function createApplePlatform(string $platformId, string $name, string $bu */ public function updateApplePlatform(string $platformId, string $name, string $bundleIdentifier): \Appwrite\Models\PlatformApple { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3125,6 +3161,10 @@ public function createLinuxPlatform(string $platformId, string $name, string $pa */ public function updateLinuxPlatform(string $platformId, string $name, string $packageName): \Appwrite\Models\PlatformLinux { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3202,6 +3242,10 @@ public function createWebPlatform(string $platformId, string $name, string $host */ public function updateWebPlatform(string $platformId, string $name, string $hostname): \Appwrite\Models\PlatformWeb { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3279,6 +3323,10 @@ public function createWindowsPlatform(string $platformId, string $name, string $ */ public function updateWindowsPlatform(string $platformId, string $name, string $packageIdentifierName): \Appwrite\Models\PlatformWindows { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3317,6 +3365,10 @@ public function updateWindowsPlatform(string $platformId, string $name, string $ */ public function getPlatform(string $platformId): \Appwrite\Models\PlatformWeb|\Appwrite\Models\PlatformApple|\Appwrite\Models\PlatformAndroid|\Appwrite\Models\PlatformWindows|\Appwrite\Models\PlatformLinux { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3372,6 +3424,10 @@ public function getPlatform(string $platformId): \Appwrite\Models\PlatformWeb|\A */ public function deletePlatform(string $platformId): string { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3384,6 +3440,7 @@ public function deletePlatform(string $platformId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -4432,6 +4489,7 @@ public function createSMTPTest(array $emails): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_POST, @@ -4660,6 +4718,10 @@ public function createVariable(string $variableId, string $key, string $value, ? */ public function getVariable(string $variableId): \Appwrite\Models\Variable { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4694,6 +4756,10 @@ public function getVariable(string $variableId): \Appwrite\Models\Variable */ public function updateVariable(string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4732,6 +4798,10 @@ public function updateVariable(string $variableId, ?string $key = null, ?string */ public function deleteVariable(string $variableId): string { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4744,6 +4814,7 @@ public function deleteVariable(string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Proxy.php b/src/Appwrite/Services/Proxy.php index 4b04c9e1..70d2d1b4 100644 --- a/src/Appwrite/Services/Proxy.php +++ b/src/Appwrite/Services/Proxy.php @@ -20,6 +20,8 @@ class Proxy extends Service * Depending on type, the invalidation purges a single cache tag, a single URL * path, or all cached content for the domain. * + * Domains that route to a function do not support cache invalidation. + * * @throws AppwriteException */ public function createInvalidation(string $domain, InvalidationType $type, ?string $reference = null): \Appwrite\Models\ProxyInvalidation @@ -266,6 +268,47 @@ public function createSiteRule(string $domain, string $siteId, ?string $branch = return \Appwrite\Models\ProxyRule::from($response); } + /** + * Create an SMTP ingress rule that asynchronously executes an Appwrite + * Function for incoming email. + * + * @throws AppwriteException + */ + public function createSMTPRule(string $domain, string $functionId, ?string $branch = null): \Appwrite\Models\ProxyRule + { + $apiPath = str_replace( + [], + [], + '/proxy/rules/smtp' + ); + + $apiParams = []; + $apiParams['domain'] = $domain; + $apiParams['functionId'] = $functionId; + + if (!is_null($branch)) { + $apiParams['branch'] = $branch; + } + + $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\ProxyRule::from($response); + } + /** * Get a proxy rule by its unique ID. * @@ -273,6 +316,10 @@ public function createSiteRule(string $domain, string $siteId, ?string $branch = */ public function getRule(string $ruleId): \Appwrite\Models\ProxyRule { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], @@ -307,6 +354,10 @@ public function getRule(string $ruleId): \Appwrite\Models\ProxyRule */ public function deleteRule(string $ruleId): string { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], @@ -319,6 +370,7 @@ public function deleteRule(string $ruleId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -338,6 +390,10 @@ public function deleteRule(string $ruleId): string */ public function updateRuleStatus(string $ruleId): \Appwrite\Models\ProxyRule { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], diff --git a/src/Appwrite/Services/Sites.php b/src/Appwrite/Services/Sites.php index 3aeb94d8..c585adaa 100644 --- a/src/Appwrite/Services/Sites.php +++ b/src/Appwrite/Services/Sites.php @@ -268,6 +268,10 @@ public function listSpecifications(?string $type = null, ?bool $total = null): \ */ public function get(string $siteId): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -302,6 +306,10 @@ public function get(string $siteId): \Appwrite\Models\Site */ public function update(string $siteId, string $name, Framework $framework, ?bool $enabled = null, ?bool $logging = null, ?int $timeout = null, ?string $installCommand = null, ?string $buildCommand = null, ?string $startCommand = null, ?string $outputDirectory = null, ?BuildRuntime $buildRuntime = null, ?Adapter $adapter = null, ?string $fallbackFile = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?array $scopes = null): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -356,10 +364,7 @@ public function update(string $siteId, string $name, Framework $framework, ?bool if (!is_null($installationId)) { $apiParams['installationId'] = $installationId; } - - if (!is_null($providerRepositoryId)) { - $apiParams['providerRepositoryId'] = $providerRepositoryId; - } + $apiParams['providerRepositoryId'] = $providerRepositoryId; if (!is_null($providerBranch)) { $apiParams['providerBranch'] = $providerBranch; @@ -411,6 +416,10 @@ public function update(string $siteId, string $name, Framework $framework, ?bool */ public function delete(string $siteId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -423,6 +432,7 @@ public function delete(string $siteId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -440,6 +450,10 @@ public function delete(string $siteId): string */ public function updateSiteDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -477,6 +491,10 @@ public function updateSiteDeployment(string $siteId, string $deploymentId): \App */ public function listDeployments(string $siteId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\DeploymentList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -525,6 +543,10 @@ public function listDeployments(string $siteId, ?array $queries = null, ?string */ public function createDeployment(string $siteId, InputFile $code, ?string $installCommand = null, ?string $buildCommand = null, ?string $outputDirectory = null, ?bool $activate = null, ?callable $onProgress = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -555,9 +577,6 @@ public function createDeployment(string $siteId, InputFile $code, ?string $insta $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($code->getPath() ?? null)) { $size = strlen($code->getData()); $mimeType = $code->getMimeType(); @@ -711,6 +730,10 @@ public function createDeployment(string $siteId, InputFile $code, ?string $insta */ public function createDuplicateDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -751,6 +774,10 @@ public function createDuplicateDeployment(string $siteId, string $deploymentId): */ public function createTemplateDeployment(string $siteId, string $repository, string $owner, string $rootDirectory, TemplateReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -797,6 +824,10 @@ public function createTemplateDeployment(string $siteId, string $repository, str */ public function createVcsDeployment(string $siteId, VCSReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -838,6 +869,14 @@ public function createVcsDeployment(string $siteId, VCSReferenceType $type, stri */ public function getDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -873,6 +912,14 @@ public function getDeployment(string $siteId, string $deploymentId): \Appwrite\M */ public function deleteDeployment(string $siteId, string $deploymentId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -886,6 +933,7 @@ public function deleteDeployment(string $siteId, string $deploymentId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -904,6 +952,14 @@ public function deleteDeployment(string $siteId, string $deploymentId): string */ public function getDeploymentDownload(string $siteId, string $deploymentId, ?DeploymentDownloadType $type = null, ?string $token = null): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -945,6 +1001,14 @@ public function getDeploymentDownload(string $siteId, string $deploymentId, ?Dep */ public function updateDeploymentStatus(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -982,6 +1046,10 @@ public function updateDeploymentStatus(string $siteId, string $deploymentId): \A */ public function listLogs(string $siteId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ExecutionList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1024,6 +1092,14 @@ public function listLogs(string $siteId, ?array $queries = null, ?bool $total = */ public function getLog(string $siteId, string $logId): \Appwrite\Models\Execution { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($logId === '') { + throw new AppwriteException('Missing required parameter: "logId"'); + } + $apiPath = str_replace( ['{siteId}', '{logId}'], [$siteId, $logId], @@ -1059,6 +1135,14 @@ public function getLog(string $siteId, string $logId): \Appwrite\Models\Executio */ public function deleteLog(string $siteId, string $logId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($logId === '') { + throw new AppwriteException('Missing required parameter: "logId"'); + } + $apiPath = str_replace( ['{siteId}', '{logId}'], [$siteId, $logId], @@ -1089,6 +1173,10 @@ public function deleteLog(string $siteId, string $logId): string */ public function listVariables(string $siteId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\VariableList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1132,6 +1220,10 @@ public function listVariables(string $siteId, ?array $queries = null, ?bool $tot */ public function createVariable(string $siteId, string $variableId, string $key, string $value, ?bool $secret = null): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1174,6 +1266,14 @@ public function createVariable(string $siteId, string $variableId, string $key, */ public function getVariable(string $siteId, string $variableId): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1209,6 +1309,14 @@ public function getVariable(string $siteId, string $variableId): \Appwrite\Model */ public function updateVariable(string $siteId, string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1248,6 +1356,14 @@ public function updateVariable(string $siteId, string $variableId, ?string $key */ public function deleteVariable(string $siteId, string $variableId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1261,6 +1377,7 @@ public function deleteVariable(string $siteId, string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index ed3a2e93..2382a1f4 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -138,6 +138,10 @@ public function createBucket(string $bucketId, string $name, ?array $permissions */ public function getBucket(string $bucketId): \Appwrite\Models\Bucket { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -172,6 +176,10 @@ public function getBucket(string $bucketId): \Appwrite\Models\Bucket */ public function updateBucket(string $bucketId, string $name, ?array $permissions = null, ?bool $fileSecurity = null, ?bool $enabled = null, ?int $maximumFileSize = null, ?array $allowedFileExtensions = null, ?Compression $compression = null, ?bool $encryption = null, ?bool $antivirus = null, ?bool $transformations = null): \Appwrite\Models\Bucket { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -190,22 +198,13 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - - if (!is_null($maximumFileSize)) { - $apiParams['maximumFileSize'] = $maximumFileSize; - } + $apiParams['maximumFileSize'] = $maximumFileSize; if (!is_null($allowedFileExtensions)) { $apiParams['allowedFileExtensions'] = $allowedFileExtensions; } - - if (!is_null($compression)) { - $apiParams['compression'] = $compression; - } - - if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; - } + $apiParams['compression'] = $compression; + $apiParams['encryption'] = $encryption; if (!is_null($antivirus)) { $apiParams['antivirus'] = $antivirus; @@ -241,6 +240,10 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions */ public function deleteBucket(string $bucketId): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -253,6 +256,7 @@ public function deleteBucket(string $bucketId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -270,6 +274,10 @@ public function deleteBucket(string $bucketId): string */ public function listFiles(string $bucketId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\FileList { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -332,6 +340,10 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea */ public function createFile(string $bucketId, string $fileId, InputFile $file, ?array $permissions = null, ?string $folder = null, ?callable $onProgress = null): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -355,9 +367,6 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($file->getPath() ?? null)) { $size = strlen($file->getData()); $mimeType = $file->getMimeType(); @@ -521,6 +530,14 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a */ public function getFile(string $bucketId, string $fileId): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -557,6 +574,14 @@ public function getFile(string $bucketId, string $fileId): \Appwrite\Models\File */ public function updateFile(string $bucketId, string $fileId, ?string $name = null, ?array $permissions = null): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -599,6 +624,14 @@ public function updateFile(string $bucketId, string $fileId, ?string $name = nul */ public function deleteFile(string $bucketId, string $fileId): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -612,6 +645,7 @@ public function deleteFile(string $bucketId, string $fileId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -630,6 +664,14 @@ public function deleteFile(string $bucketId, string $fileId): string */ public function getFileDownload(string $bucketId, string $fileId, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -667,6 +709,14 @@ public function getFileDownload(string $bucketId, string $fileId, ?string $token */ public function getFilePreview(string $bucketId, string $fileId, ?int $width = null, ?int $height = null, ?ImageGravity $gravity = null, ?int $quality = null, ?int $borderWidth = null, ?string $borderColor = null, ?int $borderRadius = null, ?float $opacity = null, ?int $rotation = null, ?string $background = null, ?ImageFormat $output = null, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -746,6 +796,14 @@ public function getFilePreview(string $bucketId, string $fileId, ?int $width = n */ public function getFileView(string $bucketId, string $fileId, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], diff --git a/src/Appwrite/Services/TablesDB.php b/src/Appwrite/Services/TablesDB.php index 4ec544bd..025cc01f 100644 --- a/src/Appwrite/Services/TablesDB.php +++ b/src/Appwrite/Services/TablesDB.php @@ -110,8 +110,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -229,6 +229,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -263,6 +267,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -306,6 +314,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -318,6 +330,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -334,6 +347,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -374,6 +391,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -408,6 +429,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, ?string $name = null, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -455,6 +480,10 @@ public function update(string $databaseId, ?string $name = null, ?bool $enabled */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -467,6 +496,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -491,6 +521,10 @@ public function delete(string $databaseId): string */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -528,6 +562,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listMigrations(string $databaseId): \Appwrite\Models\DatabaseMigrationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -557,13 +595,22 @@ public function listMigrations(string $databaseId): \Appwrite\Models\DatabaseMig /** * Start migrating a serverless TablesDB database onto a dedicated MySQL - * compute. Data is copied to the target while the source stays live, with a - * brief read-only window during cutover. + * compute. Data is copied to the target while the source stays live. Reads + * continue throughout. Row writes are held for up to a few seconds while + * routing switches to the dedicated compute; a write the switch has not + * absorbed within that hold is refused with `database_migration_cutover` and + * can be retried. Schema changes (tables, columns, indexes) are refused from + * creation until the cutover completes, and resume once the migration is + * `soaking`. * * @throws AppwriteException */ public function createMigration(string $databaseId, string $specification, ?bool $autoCutover = null): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -604,6 +651,14 @@ public function createMigration(string $databaseId, string $specification, ?bool */ public function getMigration(string $databaseId, string $migrationId): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -640,6 +695,14 @@ public function getMigration(string $databaseId, string $migrationId): \Appwrite */ public function deleteMigration(string $databaseId, string $migrationId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -667,14 +730,25 @@ public function deleteMigration(string $databaseId, string $migrationId): string * Cut a verified TablesDB migration over to its dedicated compute. Only * applies to a migration created with `autoCutover` disabled, which waits at * `ready_to_cutover` until this is called. The routing flip happens shortly - * after this returns, with a brief read-only window. One call buys one - * attempt: a cutover that fails a check returns the migration to `verifying` - * and parks it again, so call this once more to retry. + * after this returns. Reads are unaffected; row writes are held for up to a + * few seconds while it lands, and a write the flip has not absorbed within + * that hold is refused with `database_migration_cutover` and can be retried. + * One call buys one attempt: a cutover that fails a check returns the + * migration to `verifying` and parks it again, so call this once more to + * retry. * * @throws AppwriteException */ public function createCutover(string $databaseId, string $migrationId): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -714,6 +788,10 @@ public function createCutover(string $databaseId, string $migrationId): \Appwrit */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -761,6 +839,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -797,6 +879,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -832,6 +918,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function listTables(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\TableList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -881,6 +971,10 @@ public function listTables(string $databaseId, ?array $queries = null, ?string $ */ public function createTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null, ?array $columns = null, ?array $indexes = null): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -936,6 +1030,14 @@ public function createTable(string $databaseId, string $tableId, string $name, ? */ public function getTable(string $databaseId, string $tableId): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -971,6 +1073,14 @@ public function getTable(string $databaseId, string $tableId): \Appwrite\Models\ */ public function updateTable(string $databaseId, string $tableId, ?string $name = null, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1025,6 +1135,14 @@ public function updateTable(string $databaseId, string $tableId, ?string $name = */ public function deleteTable(string $databaseId, string $tableId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1038,6 +1156,7 @@ public function deleteTable(string $databaseId, string $tableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1054,6 +1173,14 @@ public function deleteTable(string $databaseId, string $tableId): string */ public function listColumns(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ColumnList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1098,6 +1225,14 @@ public function listColumns(string $databaseId, string $tableId, ?array $queries */ public function createBigIntColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1144,6 +1279,18 @@ public function createBigIntColumn(string $databaseId, string $tableId, string $ */ public function updateBigIntColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\ColumnBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1186,6 +1333,14 @@ public function updateBigIntColumn(string $databaseId, string $tableId, string $ */ public function createBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1230,6 +1385,18 @@ public function createBooleanColumn(string $databaseId, string $tableId, string */ public function updateBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1270,6 +1437,14 @@ public function updateBooleanColumn(string $databaseId, string $tableId, string */ public function createDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1314,6 +1489,18 @@ public function createDatetimeColumn(string $databaseId, string $tableId, string */ public function updateDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1354,6 +1541,14 @@ public function updateDatetimeColumn(string $databaseId, string $tableId, string */ public function createEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1398,6 +1593,18 @@ public function createEmailColumn(string $databaseId, string $tableId, string $k */ public function updateEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1439,6 +1646,14 @@ public function updateEmailColumn(string $databaseId, string $tableId, string $k */ public function createEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1484,6 +1699,18 @@ public function createEnumColumn(string $databaseId, string $tableId, string $ke */ public function updateEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1526,6 +1753,14 @@ public function updateEnumColumn(string $databaseId, string $tableId, string $ke */ public function createFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1572,6 +1807,18 @@ public function createFloatColumn(string $databaseId, string $tableId, string $k */ public function updateFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): \Appwrite\Models\ColumnFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1615,6 +1862,14 @@ public function updateFloatColumn(string $databaseId, string $tableId, string $k */ public function createIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1661,6 +1916,18 @@ public function createIntegerColumn(string $databaseId, string $tableId, string */ public function updateIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\ColumnInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1703,6 +1970,14 @@ public function updateIntegerColumn(string $databaseId, string $tableId, string */ public function createIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1747,6 +2022,18 @@ public function createIpColumn(string $databaseId, string $tableId, string $key, */ public function updateIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1787,6 +2074,14 @@ public function updateIpColumn(string $databaseId, string $tableId, string $key, */ public function createLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1827,6 +2122,18 @@ public function createLineColumn(string $databaseId, string $tableId, string $ke */ public function updateLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1867,6 +2174,14 @@ public function updateLineColumn(string $databaseId, string $tableId, string $ke */ public function createLongtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1915,6 +2230,18 @@ public function createLongtextColumn(string $databaseId, string $tableId, string */ public function updateLongtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1955,6 +2282,14 @@ public function updateLongtextColumn(string $databaseId, string $tableId, string */ public function createMediumtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2003,6 +2338,18 @@ public function createMediumtextColumn(string $databaseId, string $tableId, stri */ public function updateMediumtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2043,6 +2390,14 @@ public function updateMediumtextColumn(string $databaseId, string $tableId, stri */ public function createPointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnPoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2083,6 +2438,18 @@ public function createPointColumn(string $databaseId, string $tableId, string $k */ public function updatePointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnPoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2123,6 +2490,14 @@ public function updatePointColumn(string $databaseId, string $tableId, string $k */ public function createPolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnPolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2163,6 +2538,18 @@ public function createPolygonColumn(string $databaseId, string $tableId, string */ public function updatePolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnPolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2204,6 +2591,14 @@ public function updatePolygonColumn(string $databaseId, string $tableId, string */ public function createRelationshipColumn(string $databaseId, string $tableId, string $relatedTableId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): \Appwrite\Models\ColumnRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2245,6 +2640,58 @@ public function createRelationshipColumn(string $databaseId, string $tableId, st return \Appwrite\Models\ColumnRelationship::from($response); } + /** + * Update relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * @throws AppwriteException + */ + public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\ColumnRelationship + { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['onDelete'] = $onDelete; + $apiParams['newKey'] = $newKey; + + $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\ColumnRelationship::from($response); + } + /** * Create a string column. * @@ -2255,6 +2702,14 @@ public function createRelationshipColumn(string $databaseId, string $tableId, st */ public function createStringColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2307,6 +2762,18 @@ public function createStringColumn(string $databaseId, string $tableId, string $ */ public function updateStringColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2348,6 +2815,14 @@ public function updateStringColumn(string $databaseId, string $tableId, string $ */ public function createTextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2396,6 +2871,18 @@ public function createTextColumn(string $databaseId, string $tableId, string $ke */ public function updateTextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2436,6 +2923,14 @@ public function updateTextColumn(string $databaseId, string $tableId, string $ke */ public function createUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2480,6 +2975,18 @@ public function createUrlColumn(string $databaseId, string $tableId, string $key */ public function updateUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2520,6 +3027,14 @@ public function updateUrlColumn(string $databaseId, string $tableId, string $key */ public function createVarcharColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2569,6 +3084,18 @@ public function createVarcharColumn(string $databaseId, string $tableId, string */ public function updateVarcharColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\ColumnVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2608,8 +3135,20 @@ public function updateVarcharColumn(string $databaseId, string $tableId, string * * @throws AppwriteException */ - public function getColumn(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnBoolean|\Appwrite\Models\ColumnInteger|\Appwrite\Models\ColumnFloat|\Appwrite\Models\ColumnEmail|\Appwrite\Models\ColumnEnum|\Appwrite\Models\ColumnUrl|\Appwrite\Models\ColumnIp|\Appwrite\Models\ColumnDatetime|\Appwrite\Models\ColumnRelationship|\Appwrite\Models\ColumnString + public function getColumn(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnBoolean|\Appwrite\Models\ColumnBigint|\Appwrite\Models\ColumnInteger|\Appwrite\Models\ColumnFloat|\Appwrite\Models\ColumnEmail|\Appwrite\Models\ColumnEnum|\Appwrite\Models\ColumnUrl|\Appwrite\Models\ColumnIp|\Appwrite\Models\ColumnDatetime|\Appwrite\Models\ColumnRelationship|\Appwrite\Models\ColumnPoint|\Appwrite\Models\ColumnLine|\Appwrite\Models\ColumnPolygon|\Appwrite\Models\ColumnVarchar|\Appwrite\Models\ColumnText|\Appwrite\Models\ColumnMediumtext|\Appwrite\Models\ColumnLongtext|\Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2656,6 +3195,10 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap return \Appwrite\Models\ColumnBoolean::from($response); } + if (($response['type'] ?? null) === 'bigint') { + return \Appwrite\Models\ColumnBigint::from($response); + } + if (($response['type'] ?? null) === 'integer') { return \Appwrite\Models\ColumnInteger::from($response); } @@ -2672,6 +3215,34 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap return \Appwrite\Models\ColumnRelationship::from($response); } + if (($response['type'] ?? null) === 'point') { + return \Appwrite\Models\ColumnPoint::from($response); + } + + if (($response['type'] ?? null) === 'linestring') { + return \Appwrite\Models\ColumnLine::from($response); + } + + if (($response['type'] ?? null) === 'polygon') { + return \Appwrite\Models\ColumnPolygon::from($response); + } + + if (($response['type'] ?? null) === 'varchar') { + return \Appwrite\Models\ColumnVarchar::from($response); + } + + if (($response['type'] ?? null) === 'text') { + return \Appwrite\Models\ColumnText::from($response); + } + + if (($response['type'] ?? null) === 'mediumtext') { + return \Appwrite\Models\ColumnMediumtext::from($response); + } + + if (($response['type'] ?? null) === 'longtext') { + return \Appwrite\Models\ColumnLongtext::from($response); + } + if (($response['type'] ?? null) === 'string') { return \Appwrite\Models\ColumnString::from($response); } @@ -2686,67 +3257,40 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap */ public function deleteColumn(string $databaseId, string $tableId, string $key): string { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['content-type'] = 'application/json'; + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } - /** - * Update relationship column. [Learn more about relationship - * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * @throws AppwriteException - */ - public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\ColumnRelationship - { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' ); $apiParams = []; $apiParams['databaseId'] = $databaseId; $apiParams['tableId'] = $tableId; $apiParams['key'] = $key; - $apiParams['onDelete'] = $onDelete; - $apiParams['newKey'] = $newKey; $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, + return $this->client->call( + Client::METHOD_DELETE, $apiPath, $apiHeaders, $apiParams ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\ColumnRelationship::from($response); } /** @@ -2756,6 +3300,14 @@ public function updateRelationshipColumn(string $databaseId, string $tableId, st */ public function listIndexes(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ColumnIndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2795,12 +3347,22 @@ public function listIndexes(string $databaseId, string $tableId, ?array $queries /** * Creates an index on the columns listed. Your index should include all the * columns you will query in a single request. - * Type can be `key`, `fulltext`, or `unique`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + * is only available on PostgreSQL and lets `contains`, `startsWith`, and + * `endsWith` queries on string columns use an index. * * @throws AppwriteException */ public function createIndex(string $databaseId, string $tableId, string $key, TablesDBIndexType $type, array $columns, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\ColumnIndex { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2848,6 +3410,18 @@ public function createIndex(string $databaseId, string $tableId, string $key, Ta */ public function getIndex(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnIndex { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2884,6 +3458,18 @@ public function getIndex(string $databaseId, string $tableId, string $key): \App */ public function deleteIndex(string $databaseId, string $tableId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2898,6 +3484,7 @@ public function deleteIndex(string $databaseId, string $tableId, string $key): s $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2915,6 +3502,14 @@ public function deleteIndex(string $databaseId, string $tableId, string $key): s */ public function listRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2969,6 +3564,14 @@ public function listRows(string $databaseId, string $tableId, ?array $queries = */ public function createRow(string $databaseId, string $tableId, string $rowId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3012,6 +3615,14 @@ public function createRow(string $databaseId, string $tableId, string $rowId, ar */ public function createRows(string $databaseId, string $tableId, array $rows, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3053,6 +3664,14 @@ public function createRows(string $databaseId, string $tableId, array $rows, ?st */ public function upsertRows(string $databaseId, string $tableId, array $rows, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3092,6 +3711,14 @@ public function upsertRows(string $databaseId, string $tableId, array $rows, ?st */ public function updateRows(string $databaseId, string $tableId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3138,6 +3765,14 @@ public function updateRows(string $databaseId, string $tableId, ?array $data = n */ public function deleteRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3183,6 +3818,18 @@ public function deleteRows(string $databaseId, string $tableId, ?array $queries */ public function getRow(string $databaseId, string $tableId, string $rowId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3230,6 +3877,18 @@ public function getRow(string $databaseId, string $tableId, string $rowId, ?arra */ public function upsertRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3274,6 +3933,18 @@ public function upsertRow(string $databaseId, string $tableId, string $rowId, ?a */ public function updateRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3317,6 +3988,18 @@ public function updateRow(string $databaseId, string $tableId, string $rowId, ?a */ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3335,6 +4018,7 @@ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?s $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -3351,6 +4035,22 @@ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?s */ public function decrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if ($column === '') { + throw new AppwriteException('Missing required parameter: "column"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}', '{column}'], [$databaseId, $tableId, $rowId, $column], @@ -3395,6 +4095,22 @@ public function decrementRowColumn(string $databaseId, string $tableId, string $ */ public function incrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if ($column === '') { + throw new AppwriteException('Missing required parameter: "column"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}', '{column}'], [$databaseId, $tableId, $rowId, $column], diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index 3aad4091..e963c412 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -105,6 +105,10 @@ public function create(string $teamId, string $name, ?array $roles = null): \App */ public function get(string $teamId): \Appwrite\Models\Team { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -139,6 +143,10 @@ public function get(string $teamId): \Appwrite\Models\Team */ public function updateName(string $teamId, string $name): \Appwrite\Models\Team { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -176,6 +184,10 @@ public function updateName(string $teamId, string $name): \Appwrite\Models\Team */ public function delete(string $teamId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -188,6 +200,7 @@ public function delete(string $teamId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -204,6 +217,10 @@ public function delete(string $teamId): string */ public function listInstallations(string $teamId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppInstallationList { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -249,6 +266,10 @@ public function listInstallations(string $teamId, ?array $queries = null, ?bool */ public function createInstallation(string $teamId, string $appId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -290,6 +311,14 @@ public function createInstallation(string $teamId, string $appId, ?string $autho */ public function getInstallation(string $teamId, string $installationId): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -328,6 +357,14 @@ public function getInstallation(string $teamId, string $installationId): \Appwri */ public function updateInstallation(string $teamId, string $installationId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -367,6 +404,14 @@ public function updateInstallation(string $teamId, string $installationId, ?stri */ public function deleteInstallation(string $teamId, string $installationId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -399,6 +444,10 @@ public function deleteInstallation(string $teamId, string $installationId): stri */ public function listMemberships(string $teamId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\MembershipList { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -464,6 +513,10 @@ public function listMemberships(string $teamId, ?array $queries = null, ?string */ public function createMembership(string $teamId, array $roles, ?string $email = null, ?string $userId = null, ?string $phone = null, ?string $url = null, ?string $name = null, ?string $membershipId = null): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -526,6 +579,14 @@ public function createMembership(string $teamId, array $roles, ?string $email = */ public function getMembership(string $teamId, string $membershipId): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -563,6 +624,14 @@ public function getMembership(string $teamId, string $membershipId): \Appwrite\M */ public function updateMembership(string $teamId, string $membershipId, array $roles): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -602,6 +671,14 @@ public function updateMembership(string $teamId, string $membershipId, array $ro */ public function deleteMembership(string $teamId, string $membershipId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -615,6 +692,7 @@ public function deleteMembership(string $teamId, string $membershipId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -636,6 +714,14 @@ public function deleteMembership(string $teamId, string $membershipId): string */ public function updateMembershipStatus(string $teamId, string $membershipId, string $userId, string $secret): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -676,6 +762,10 @@ public function updateMembershipStatus(string $teamId, string $membershipId, str */ public function getPrefs(string $teamId): \Appwrite\Models\Preferences { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -712,6 +802,10 @@ public function getPrefs(string $teamId): \Appwrite\Models\Preferences */ public function updatePrefs(string $teamId, array $prefs): \Appwrite\Models\Preferences { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], diff --git a/src/Appwrite/Services/Tokens.php b/src/Appwrite/Services/Tokens.php index 1d2b5137..a5d3bc40 100644 --- a/src/Appwrite/Services/Tokens.php +++ b/src/Appwrite/Services/Tokens.php @@ -18,6 +18,14 @@ class Tokens extends Service */ public function list(string $bucketId, string $fileId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ResourceTokenList { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -62,6 +70,14 @@ public function list(string $bucketId, string $fileId, ?array $queries = null, ? */ public function createFileToken(string $bucketId, string $fileId, ?string $expire = null): \Appwrite\Models\ResourceToken { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -99,6 +115,10 @@ public function createFileToken(string $bucketId, string $fileId, ?string $expir */ public function get(string $tokenId): \Appwrite\Models\ResourceToken { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -134,6 +154,10 @@ public function get(string $tokenId): \Appwrite\Models\ResourceToken */ public function update(string $tokenId, ?string $expire = null): \Appwrite\Models\ResourceToken { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -170,6 +194,10 @@ public function update(string $tokenId, ?string $expire = null): \Appwrite\Model */ public function delete(string $tokenId): string { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -182,6 +210,7 @@ public function delete(string $tokenId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index b0333df3..cbd44020 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -76,10 +76,7 @@ public function create(string $userId, ?string $email = null, ?string $phone = n $apiParams['userId'] = $userId; $apiParams['email'] = $email; $apiParams['phone'] = $phone; - - if (!is_null($password)) { - $apiParams['password'] = $password; - } + $apiParams['password'] = $password; if (!is_null($name)) { $apiParams['name'] = $name; @@ -244,6 +241,10 @@ public function listIdentities(?array $queries = null, ?string $search = null, ? */ public function deleteIdentity(string $identityId): string { + if ($identityId === '') { + throw new AppwriteException('Missing required parameter: "identityId"'); + } + $apiPath = str_replace( ['{identityId}'], [$identityId], @@ -256,6 +257,7 @@ public function deleteIdentity(string $identityId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -505,6 +507,10 @@ public function createSHAUser(string $userId, string $email, string $password, ? */ public function get(string $userId): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -544,6 +550,10 @@ public function get(string $userId): \Appwrite\Models\User */ public function delete(string $userId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -556,6 +566,7 @@ public function delete(string $userId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -572,6 +583,10 @@ public function delete(string $userId): string */ public function updateEmail(string $userId, string $email): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -606,12 +621,19 @@ public function updateEmail(string $userId, string $email): \Appwrite\Models\Use * impersonation headers are used, the request runs as the target user for API * behavior, while internal audit logs still attribute the action to the * original impersonator and store the impersonated target details only in - * internal audit payload data. + * internal audit payload data. Account endpoints are read-only while + * impersonating: they report the target's account, and anything that would + * change it is refused, so an impersonator cannot alter the target's + * credentials or delete their account. * * @throws AppwriteException */ public function updateImpersonator(string $userId, bool $impersonator): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -650,6 +672,10 @@ public function updateImpersonator(string $userId, bool $impersonator): \Appwrit */ public function createJWT(string $userId, ?string $sessionId = null, ?int $duration = null): \Appwrite\Models\Jwt { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -698,6 +724,10 @@ public function createJWT(string $userId, ?string $sessionId = null, ?int $durat */ public function updateLabels(string $userId, array $labels): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -727,48 +757,6 @@ public function updateLabels(string $userId, array $labels): \Appwrite\Models\Us return \Appwrite\Models\User::from($response); } - /** - * Get the user activity logs list by its unique ID. - * - * @throws AppwriteException - */ - public function listLogs(string $userId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - ['{userId}'], - [$userId], - '/users/{userId}/logs' - ); - - $apiParams = []; - $apiParams['userId'] = $userId; - - 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 user membership list by its unique ID. * @@ -776,6 +764,10 @@ public function listLogs(string $userId, ?array $queries = null, ?bool $total = */ public function listMemberships(string $userId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\MembershipList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -822,6 +814,10 @@ public function listMemberships(string $userId, ?array $queries = null, ?string */ public function updateMFA(string $userId, bool $mfa): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -858,6 +854,10 @@ public function updateMFA(string $userId, bool $mfa): \Appwrite\Models\User */ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}', '{type}'], [$userId, (string) $type], @@ -871,6 +871,7 @@ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -888,6 +889,14 @@ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): */ public function getMFAChallenge(string $userId, string $challengeId): \Appwrite\Models\MfaChallengeSecret { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($challengeId === '') { + throw new AppwriteException('Missing required parameter: "challengeId"'); + } + $apiPath = str_replace( ['{userId}', '{challengeId}'], [$userId, $challengeId], @@ -923,6 +932,10 @@ public function getMFAChallenge(string $userId, string $challengeId): \Appwrite\ */ public function listMFAFactors(string $userId): \Appwrite\Models\MfaFactors { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -960,6 +973,10 @@ public function listMFAFactors(string $userId): \Appwrite\Models\MfaFactors */ public function getMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -997,6 +1014,10 @@ public function getMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecover */ public function updateMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1035,6 +1056,10 @@ public function updateMFARecoveryCodes(string $userId): \Appwrite\Models\MfaReco */ public function createMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1070,6 +1095,10 @@ public function createMFARecoveryCodes(string $userId): \Appwrite\Models\MfaReco */ public function updateName(string $userId, string $name): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1279,6 +1308,10 @@ public function deletePasskey(string $userId, string $passkeyId): string */ public function updatePassword(string $userId, string $password): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1315,6 +1348,10 @@ public function updatePassword(string $userId, string $password): \Appwrite\Mode */ public function updatePhone(string $userId, string $number): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1351,6 +1388,10 @@ public function updatePhone(string $userId, string $number): \Appwrite\Models\Us */ public function getPrefs(string $userId): \Appwrite\Models\Preferences { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1387,6 +1428,10 @@ public function getPrefs(string $userId): \Appwrite\Models\Preferences */ public function updatePrefs(string $userId, array $prefs): \Appwrite\Models\Preferences { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1423,6 +1468,10 @@ public function updatePrefs(string $userId, array $prefs): \Appwrite\Models\Pref */ public function listSessions(string $userId, ?bool $total = null): \Appwrite\Models\SessionList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1466,6 +1515,10 @@ public function listSessions(string $userId, ?bool $total = null): \Appwrite\Mod */ public function createSession(string $userId): \Appwrite\Models\Session { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1501,6 +1554,10 @@ public function createSession(string $userId): \Appwrite\Models\Session */ public function deleteSessions(string $userId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1513,6 +1570,7 @@ public function deleteSessions(string $userId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1529,6 +1587,14 @@ public function deleteSessions(string $userId): string */ public function deleteSession(string $userId, string $sessionId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{userId}', '{sessionId}'], [$userId, $sessionId], @@ -1542,6 +1608,7 @@ public function deleteSession(string $userId, string $sessionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1559,6 +1626,10 @@ public function deleteSession(string $userId, string $sessionId): string */ public function updateStatus(string $userId, bool $status): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1595,6 +1666,10 @@ public function updateStatus(string $userId, bool $status): \Appwrite\Models\Use */ public function listTargets(string $userId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\TargetList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1637,6 +1712,10 @@ public function listTargets(string $userId, ?array $queries = null, ?bool $total */ public function createTarget(string $userId, string $targetId, MessagingProviderType $providerType, string $identifier, ?string $providerId = null, ?string $name = null): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1683,6 +1762,14 @@ public function createTarget(string $userId, string $targetId, MessagingProvider */ public function getTarget(string $userId, string $targetId): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1718,6 +1805,14 @@ public function getTarget(string $userId, string $targetId): \Appwrite\Models\Ta */ public function updateTarget(string $userId, string $targetId, ?string $identifier = null, ?string $providerId = null, ?string $name = null): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1766,6 +1861,14 @@ public function updateTarget(string $userId, string $targetId, ?string $identifi */ public function deleteTarget(string $userId, string $targetId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1779,6 +1882,7 @@ public function deleteTarget(string $userId, string $targetId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1798,6 +1902,10 @@ public function deleteTarget(string $userId, string $targetId): string */ public function createToken(string $userId, ?int $length = null, ?int $expire = null): \Appwrite\Models\Token { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1841,6 +1949,10 @@ public function createToken(string $userId, ?int $length = null, ?int $expire = */ public function updateEmailVerification(string $userId, bool $emailVerification): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1877,6 +1989,10 @@ public function updateEmailVerification(string $userId, bool $emailVerification) */ public function updatePhoneVerification(string $userId, bool $phoneVerification): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], diff --git a/src/Appwrite/Services/VectorsDB.php b/src/Appwrite/Services/VectorsDB.php index c2a5c12a..053efccb 100644 --- a/src/Appwrite/Services/VectorsDB.php +++ b/src/Appwrite/Services/VectorsDB.php @@ -104,8 +104,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -223,6 +223,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -257,6 +261,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -300,6 +308,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -312,6 +324,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -328,6 +341,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -368,6 +385,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -402,6 +423,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, string $name, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -446,6 +471,10 @@ public function update(string $databaseId, string $name, ?bool $enabled = null, */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -458,6 +487,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -475,6 +505,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\VectorsdbCollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -524,6 +558,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, int $dimension, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -575,6 +613,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -610,6 +656,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?int $dimension = null, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -632,10 +686,7 @@ public function updateCollection(string $databaseId, string $collectionId, strin if (!is_null($documentSecurity)) { $apiParams['documentSecurity'] = $documentSecurity; } - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } + $apiParams['enabled'] = $enabled; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -664,6 +715,14 @@ public function updateCollection(string $databaseId, string $collectionId, strin */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -677,6 +736,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -694,6 +754,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -748,6 +816,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -797,6 +873,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -841,6 +925,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -884,6 +976,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -933,6 +1033,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -980,6 +1088,14 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function createQuery(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1033,6 +1149,18 @@ public function createQuery(string $databaseId, string $collectionId, ?array $qu */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1080,6 +1208,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1130,6 +1270,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1179,6 +1331,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1197,6 +1361,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1213,6 +1378,14 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1258,6 +1431,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, VectorsDBIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1305,6 +1486,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1341,6 +1534,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1355,6 +1560,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1379,6 +1585,10 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1418,6 +1628,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1465,6 +1679,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1501,6 +1719,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Webhooks.php b/src/Appwrite/Services/Webhooks.php index 2694980a..7563d2ff 100644 --- a/src/Appwrite/Services/Webhooks.php +++ b/src/Appwrite/Services/Webhooks.php @@ -116,6 +116,10 @@ public function create(string $webhookId, string $url, string $name, array $even */ public function get(string $webhookId): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -151,6 +155,10 @@ public function get(string $webhookId): \Appwrite\Models\Webhook */ public function update(string $webhookId, string $name, string $url, array $events, ?bool $enabled = null, ?bool $tls = null, ?string $authUsername = null, ?string $authPassword = null): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -174,10 +182,7 @@ public function update(string $webhookId, string $name, string $url, array $even if (!is_null($authUsername)) { $apiParams['authUsername'] = $authUsername; } - - if (!is_null($authPassword)) { - $apiParams['authPassword'] = $authPassword; - } + $apiParams['authPassword'] = $authPassword; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -206,6 +211,10 @@ public function update(string $webhookId, string $name, string $url, array $even */ public function delete(string $webhookId): string { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -218,6 +227,7 @@ public function delete(string $webhookId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -236,6 +246,10 @@ public function delete(string $webhookId): string */ public function updateSecret(string $webhookId, ?string $secret = null): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], diff --git a/src/Appwrite/Topic.php b/src/Appwrite/Topic.php new file mode 100644 index 00000000..2ca43660 --- /dev/null +++ b/src/Appwrite/Topic.php @@ -0,0 +1,115 @@ +path(['logs']); // "org/42/logs" + * + * The same name starts a topic (`Topic::path()`) and extends one (`$topic->path()`); both are + * routed through `__callStatic()` and `__call()` to the protected implementation below. + * + * @method static Topic path(array $levels) Start a topic with the given levels, or append them. + */ +final readonly class Topic implements \Stringable +{ + /** + * @param list $levels + */ + private function __construct(private array $levels) + { + } + + /** + * @param array $arguments + */ + public static function __callStatic(string $name, array $arguments): self + { + return new self([])->dispatch($name, $arguments); + } + + /** + * @param array $arguments + */ + public function __call(string $name, array $arguments): self + { + return $this->dispatch($name, $arguments); + } + + /** + * Append the given levels. + */ + protected function appendPath(mixed $levels): self + { + return new self([...$this->levels, ...$this->levelsOf($levels)]); + } + + public function __toString(): string + { + return \implode('/', $this->levels); + } + + /** + * @param array $arguments + */ + private function dispatch(string $name, array $arguments): self + { + return match ($name) { + 'path' => $this->appendPath($arguments[0] ?? null), + default => throw new \BadMethodCallException('Call to undefined method ' . self::class . '::' . $name . '()'), + }; + } + + /** + * Validate the levels passed to `path()`: a non-empty array of non-empty strings, none holding + * the level separator `/` or the MQTT wildcards `+` and `#`. + * + * @return list + */ + private function levelsOf(mixed $levels): array + { + if (!\is_array($levels)) { + throw new \InvalidArgumentException("path() expects an array, e.g. path(['user'])"); + } + + if ($levels === []) { + throw new \InvalidArgumentException('path() needs at least one level'); + } + + $result = []; + foreach (\array_values($levels) as $index => $level) { + if (!\is_string($level)) { + $type = $level === null ? 'null' : \get_debug_type($level); + throw new \InvalidArgumentException(\sprintf('level at index %d must be a string, got %s', $index, $type)); + } + + if ($level === '') { + throw new \InvalidArgumentException(\sprintf('empty level at index %d', $index)); + } + + if (\str_contains($level, '/')) { + $parts = \implode(', ', \array_map(static fn (string $part): string => "'" . $part . "'", \explode('/', $level))); + throw new \InvalidArgumentException(\sprintf('"%s" contains "/", split it: path([%s])', $level, $parts)); + } + + if (\str_contains($level, '+')) { + throw new \InvalidArgumentException(\sprintf('"%s" contains "+", not allowed in a topic', $level)); + } + + if (\str_contains($level, '#')) { + throw new \InvalidArgumentException(\sprintf('"%s" contains "#", not allowed in a topic', $level)); + } + if (\str_contains($level, "\0")) { + throw new \InvalidArgumentException(\sprintf('level at index %d contains a NUL character', $index)); + } + + $result[] = $level; + } + + return $result; + } +} diff --git a/tests/Appwrite/ClientTest.php b/tests/Appwrite/ClientTest.php index 46678475..c25ac462 100644 --- a/tests/Appwrite/ClientTest.php +++ b/tests/Appwrite/ClientTest.php @@ -5,9 +5,14 @@ namespace Appwrite; use PHPUnit\Framework\TestCase; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; use ReflectionMethod; use ReflectionProperty; use Utopia\Client\Client as HttpClient; +use Utopia\Psr7\Response; +use Utopia\Psr7\Stream; final class ClientTest extends TestCase { @@ -61,6 +66,49 @@ public function testAddHeaderReturnsClient(): void $this->assertSame($client, $result); } + public function testFlattenSpreadsWrappedBuilder(): void + { + $this->assertSame( + [Query::limit(1)], + array_values((array) Client::flatten([Query::builder()->limit(1)])) + ); + } + + public function testFlattenKeepsNestedNumericArrays(): void + { + $geometry = [[1, 2], [3, 4]]; + $this->assertSame($geometry, Client::flatten($geometry)); + } + + public function testFlattenKeepsQueryStringList(): void + { + $this->assertSame( + [Query::limit(1)], + array_values((array) Client::flatten([Query::limit(1)])) + ); + } + + public function testFlattenKeepsNestedStringArrays(): void + { + $this->assertSame([['a', 'b']], Client::flatten([['a', 'b']])); + } + + public function testFlattenBuilderParamBecomesQueryStrings(): void + { + $this->assertSame( + [Query::equal('status', ['active']), Query::limit(1)], + Client::flatten(Query::builder()->equal('status', ['active'])->limit(1)) + ); + } + + public function testFlattenSplicesBuildersBesideNestedStringArrays(): void + { + $this->assertSame( + [Query::limit(1), Query::offset(2), ['a', 'b']], + Client::flatten([Query::builder()->limit(1)->offset(2), ['a', 'b']]) + ); + } + public function testSetProjectReturnsClient(): void { $client = new Client(); @@ -117,13 +165,6 @@ public function testSetForwardedUserAgentReturnsClient(): void $this->assertSame($client, $result); } - public function testSetDevKeyReturnsClient(): void - { - $client = new Client(); - $result = $client->setDevKey('test-value'); - $this->assertSame($client, $result); - } - public function testSetCookieReturnsClient(): void { $client = new Client(); @@ -185,7 +226,109 @@ public function testSelfSignedAndConnectTimeoutResetHttpClient(): void $this->assertNotSame($afterSelfSigned, $this->httpClient($client, true)); } - private function httpClient(Client $client, bool $followRedirects): HttpClient + public function testInjectedTransportReceivesEncodedRequests(): void + { + $received = []; + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->once())->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request) use (&$received): ResponseInterface { + $received[] = $request; + + return new Response(body: new Stream('{"received":true}')) + ->withHeader('content-type', 'application/json'); + }); + + $client = new Client($transport) + ->setEndpoint('https://example.com/v1') + ->addHeader('x-test', 'injected'); + + $this->assertSame(['received' => true], $client->call(Client::METHOD_POST, '/items', ['content-type' => 'application/json'], ['name' => 'item'])); + $this->assertCount(1, $received); + $this->assertSame('POST', $received[0]->getMethod()); + $this->assertSame('https://example.com/v1/items', (string) $received[0]->getUri()); + $this->assertSame(['name' => 'item'], json_decode((string) $received[0]->getBody(), true)); + $this->assertSame('injected', $received[0]->getHeaderLine('x-test')); + } + + public function testInjectedTransportReceivesFlattenedParams(): void + { + $received = []; + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->exactly(2))->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request) use (&$received): ResponseInterface { + $received[] = $request; + + return new Response(body: new Stream('{}')) + ->withHeader('content-type', 'application/json'); + }); + + $client = new Client($transport)->setEndpoint('https://example.com/v1'); + $params = [ + 'queries' => Query::builder()->limit(1)->offset(2), + 'tags' => [['a', 'b']], + ]; + + $client->call(Client::METHOD_POST, '/items', ['content-type' => 'application/json'], $params); + $client->call(Client::METHOD_GET, '/items', [], $params); + + $this->assertCount(2, $received); + $this->assertSame( + ['queries' => [Query::limit(1), Query::offset(2)], 'tags' => [['a', 'b']]], + json_decode((string) $received[0]->getBody(), true) + ); + parse_str($received[1]->getUri()->getQuery(), $query); + $this->assertSame( + ['queries' => [Query::limit(1), Query::offset(2)], 'tags' => [['a', 'b']]], + $query + ); + } + + public function testInjectedTransportSurvivesFailureAndConfigurationChanges(): void + { + $received = []; + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->exactly(2))->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request) use (&$received): ResponseInterface { + $received[] = (string) $request->getUri(); + + return count($received) === 1 + ? new Response(503, body: new Stream('{"message":"Unavailable","type":"unavailable"}'))->withHeader('content-type', 'application/json') + : new Response(body: new Stream('null'))->withHeader('content-type', 'application/json'); + }); + $client = new Client($transport)->setEndpoint('https://first.example'); + + $failure = null; + try { + $client->call(Client::METHOD_GET, '/fail'); + } catch (AppwriteException $error) { + $failure = $error; + } + + $client->setEndpoint('https://second.example')->setTimeout(5)->setConnectTimeout(2)->setSelfSigned(true); + $this->assertNull($client->call(Client::METHOD_GET, '/next', params: ['project' => 'project-1'])); + $this->assertInstanceOf(AppwriteException::class, $failure); + $this->assertSame(503, $failure->getCode()); + $this->assertSame(['https://first.example/fail', 'https://second.example/next?project=project-1'], $received); + $this->assertSame($transport, $this->httpClient($client, true)); + $this->assertSame($transport, $this->httpClient($client, false)); + } + + public function testLocationResponseUsesInjectedTransport(): void + { + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->once())->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request): ResponseInterface { + $this->assertSame('GET', $request->getMethod()); + $this->assertSame('https://example.com/redirect', (string) $request->getUri()); + + return new Response(302)->withHeader('location', 'https://storage.example/file'); + }); + + $client = new Client($transport)->setEndpoint('https://example.com'); + $this->assertSame('https://storage.example/file', $client->call(Client::METHOD_GET, '/redirect', responseType: 'location')); + } + + private function httpClient(Client $client, bool $followRedirects): ClientInterface { $method = new ReflectionMethod(Client::class, 'getHttpClient'); diff --git a/tests/Appwrite/QueryTest.php b/tests/Appwrite/QueryTest.php index d25e1910..cf4f85ad 100644 --- a/tests/Appwrite/QueryTest.php +++ b/tests/Appwrite/QueryTest.php @@ -8,11 +8,8 @@ final class BasicFilterQueryTest { - public function __construct( - public string $description, - public mixed $value, - public string $expectedValues, - ) { + public function __construct(public string $description, public mixed $value, public string $expectedValues) + { } } @@ -314,6 +311,25 @@ public function testElemMatch(): void $this->assertSame([18], $query['values'][1]['values']); } + public function testRelationship(): void + { + $inner1 = Query::equal('approved', true); + $inner2 = Query::limit(2); + + $query = json_decode(Query::relationship('comments', [$inner1, $inner2]), true); + + $this->assertSame('comments', $query['attribute']); + $this->assertSame('relationship', $query['method']); + $this->assertCount(2, $query['values']); + + $this->assertSame('equal', $query['values'][0]['method']); + $this->assertSame('approved', $query['values'][0]['attribute']); + $this->assertSame([true], $query['values'][0]['values']); + + $this->assertSame('limit', $query['values'][1]['method']); + $this->assertSame([2], $query['values'][1]['values']); + } + public function testCreatedBefore(): void { $query = json_decode(Query::createdBefore('2023-01-01'), true); @@ -361,4 +377,263 @@ public function testUpdatedBetween(): void $this->assertSame(['2023-01-01', '2023-12-31'], $query['values']); $this->assertSame('between', $query['method']); } + + public function testCountWithAlias(): void + { + $query = json_decode(Query::count('*', 'total'), true); + $this->assertSame('count', $query['method']); + $this->assertSame('*', $query['attribute']); + $this->assertSame(['total'], $query['values']); + } + + public function testCountWithoutAlias(): void + { + $query = json_decode(Query::count(), true); + $this->assertSame('count', $query['method']); + $this->assertSame('*', $query['attribute']); + $this->assertArrayNotHasKey('values', $query); + } + + public function testCountDistinct(): void + { + $query = json_decode(Query::countDistinct('year', 'uniqueYears'), true); + $this->assertSame('countDistinct', $query['method']); + $this->assertSame('year', $query['attribute']); + $this->assertSame(['uniqueYears'], $query['values']); + } + + public function testSumAvgMinMax(): void + { + $this->assertSame('sum', json_decode(Query::sum('price', 'total'), true)['method']); + $this->assertSame('avg', json_decode(Query::avg('price', 'avgPrice'), true)['method']); + $this->assertSame('min', json_decode(Query::min('price', 'lowest'), true)['method']); + $this->assertSame('max', json_decode(Query::max('price', 'highest'), true)['method']); + } + + public function testStddev(): void + { + $this->assertSame('stddev', json_decode(Query::stddev('price', 'sd'), true)['method']); + } + + public function testStddevPop(): void + { + $this->assertSame('stddevPop', json_decode(Query::stddevPop('price', 'sdp'), true)['method']); + } + + public function testStddevSamp(): void + { + $this->assertSame('stddevSamp', json_decode(Query::stddevSamp('price', 'sds'), true)['method']); + } + + public function testVariance(): void + { + $this->assertSame('variance', json_decode(Query::variance('price', 'var'), true)['method']); + } + + public function testVarPop(): void + { + $this->assertSame('varPop', json_decode(Query::varPop('price', 'vp'), true)['method']); + } + + public function testVarSamp(): void + { + $this->assertSame('varSamp', json_decode(Query::varSamp('price', 'vs'), true)['method']); + } + + public function testBitAnd(): void + { + $this->assertSame('bitAnd', json_decode(Query::bitAnd('flags', 'band'), true)['method']); + } + + public function testBitOr(): void + { + $this->assertSame('bitOr', json_decode(Query::bitOr('flags', 'bor'), true)['method']); + } + + public function testBitXor(): void + { + $this->assertSame('bitXor', json_decode(Query::bitXor('flags', 'bxor'), true)['method']); + } + + public function testGroupBy(): void + { + $query = json_decode(Query::groupBy(['status', 'year']), true); + $this->assertSame('groupBy', $query['method']); + $this->assertSame(['status', 'year'], $query['values']); + $this->assertArrayNotHasKey('attribute', $query); + } + + public function testHaving(): void + { + $query = json_decode(Query::having([Query::greaterThan('total', 1)]), true); + $this->assertSame('having', $query['method']); + $this->assertSame('greaterThan', $query['values'][0]['method']); + $this->assertSame('total', $query['values'][0]['attribute']); + $this->assertSame([1], $query['values'][0]['values']); + } + + public function testDistinct(): void + { + $query = json_decode(Query::distinct(), true); + $this->assertSame('distinct', $query['method']); + $this->assertArrayNotHasKey('attribute', $query); + $this->assertArrayNotHasKey('values', $query); + } + + public function testJoin(): void + { + $query = json_decode(Query::join('orders', '$id', 'customerId'), true); + $this->assertSame('join', $query['method']); + $this->assertSame('orders', $query['attribute']); + $this->assertSame(['$id', '=', 'customerId'], $query['values']); + } + + public function testJoinWithAlias(): void + { + $query = json_decode(Query::leftJoin('orders', '$id', 'customerId', '=', 'ord'), true); + $this->assertSame('leftJoin', $query['method']); + $this->assertSame('orders', $query['attribute']); + $this->assertSame(['$id', '=', 'customerId', 'ord'], $query['values']); + } + + public function testOn(): void + { + $query = json_decode(Query::on('$id', 'customerId'), true); + $this->assertSame('on', $query['method']); + $this->assertSame(['$id', '=', 'customerId'], $query['values']); + } + + public function testNestedLeftJoin(): void + { + $query = json_decode(Query::leftJoin('orders', 'ord', [ + Query::on('$id', 'customerId'), + Query::equal('ord.status', 'paid'), + ]), true); + $this->assertSame('leftJoin', $query['method']); + $this->assertSame('orders', $query['attribute']); + $this->assertSame('ord', $query['values'][0]); + $this->assertSame('on', $query['values'][1]['method']); + $this->assertSame(['$id', '=', 'customerId'], $query['values'][1]['values']); + $this->assertSame('equal', $query['values'][2]['method']); + $this->assertSame('ord.status', $query['values'][2]['attribute']); + } + + public function testRightJoin(): void + { + $query = json_decode(Query::rightJoin('orders', '$id', 'customerId'), true); + $this->assertSame('rightJoin', $query['method']); + $this->assertSame(['$id', '=', 'customerId'], $query['values']); + } + + public function testFullOuterJoin(): void + { + $query = json_decode(Query::fullOuterJoin('orders', '$id', 'customerId'), true); + $this->assertSame('fullOuterJoin', $query['method']); + $this->assertSame(['$id', '=', 'customerId'], $query['values']); + } + + public function testCrossJoin(): void + { + $query = json_decode(Query::crossJoin('orders', 'ord'), true); + $this->assertSame('crossJoin', $query['method']); + $this->assertSame('orders', $query['attribute']); + $this->assertSame(['ord'], $query['values']); + } + + public function testNotCovers(): void + { + $query = json_decode(Query::notCovers('location', [1, 2]), true); + $this->assertSame('notCovers', $query['method']); + $this->assertSame([[1, 2]], $query['values']); + } + + public function testSpatialEquals(): void + { + $query = json_decode(Query::spatialEquals('location', [1, 2]), true); + $this->assertSame('spatialEquals', $query['method']); + $this->assertSame([[1, 2]], $query['values']); + } + + public function testNotSpatialEquals(): void + { + $query = json_decode(Query::notSpatialEquals('location', [1, 2]), true); + $this->assertSame('notSpatialEquals', $query['method']); + $this->assertSame([[1, 2]], $query['values']); + } + + public function testVectorDot(): void + { + $query = json_decode(Query::vectorDot('embedding', [0.1, 0.2]), true); + $this->assertSame('vectorDot', $query['method']); + $this->assertSame('embedding', $query['attribute']); + $this->assertSame([[0.1, 0.2]], $query['values']); + } + + public function testCovers(): void + { + $query = json_decode(Query::covers('location', [0, 0]), true); + $this->assertSame('covers', $query['method']); + $this->assertSame([[0, 0]], $query['values']); + } + + public function testPage(): void + { + $queries = Query::page(2, 10); + $this->assertCount(2, $queries); + $limit = json_decode($queries[0], true); + $offset = json_decode($queries[1], true); + $this->assertSame('limit', $limit['method']); + $this->assertSame([10], $limit['values']); + $this->assertSame('offset', $offset['method']); + $this->assertSame([10], $offset['values']); + } + + public function testPageRejectsInvalid(): void + { + $this->expectException(\InvalidArgumentException::class); + Query::page(0, 10); + } + + public function testBuilderBuild(): void + { + $expected = [ + Query::equal('status', 'published'), + Query::leftJoin('orders', '$id', 'customerId', '=', 'ord'), + Query::count('*', 'total'), + Query::groupBy(['status']), + Query::limit(25), + ]; + + $built = Query::builder() + ->equal('status', 'published') + ->leftJoin('orders', '$id', 'customerId', '=', 'ord') + ->count('*', 'total') + ->groupBy(['status']) + ->limit(25) + ->build(); + + $this->assertSame($expected, $built); + } + + public function testFlattenSpreadsWrappedBuilder(): void + { + $this->assertSame( + [Query::limit(1)], + array_values((array) Client::flatten([Query::builder()->limit(1)])) + ); + } + + public function testFlattenKeepsNestedNumericArrays(): void + { + $geometry = [[1, 2], [3, 4]]; + $this->assertSame($geometry, Client::flatten($geometry)); + } + + public function testFlattenKeepsQueryStringList(): void + { + $this->assertSame( + [Query::limit(1)], + array_values((array) Client::flatten([Query::limit(1)])) + ); + } } diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php index c4a20ad2..eed55b62 100644 --- a/tests/Appwrite/Services/AccountTest.php +++ b/tests/Appwrite/Services/AccountTest.php @@ -333,7 +333,8 @@ public function testMethodListIdentities(): void "providerEmail" => "user@example.com", "providerAccessToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", "providerAccessTokenExpiry" => "2020-10-15T06:38:00.000+00:00", - "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3" + "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerIdToken" => "eyJhbGciOiJSUzI1NiIsImtpZCI6IjBhYzNmMWQwNWExYjhlN2YifQ.eyJzdWIiOiIxMTAxNjk0ODQ0NzQzODYyNzYzMzQifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ] ] ]; @@ -366,49 +367,6 @@ public function testMethodDeleteIdentity(): void $this->assertSame($data, $response); } - public function testMethodListLogs(): void - { - $data = [ - "total" => 5, - "logs" => [ - [ - "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->account->listLogs(); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } public function testMethodUpdateMFA(): void { $data = [ diff --git a/tests/Appwrite/Services/BackupsTest.php b/tests/Appwrite/Services/BackupsTest.php index 353bd0d7..11782077 100644 --- a/tests/Appwrite/Services/BackupsTest.php +++ b/tests/Appwrite/Services/BackupsTest.php @@ -31,9 +31,7 @@ public function testMethodListArchives(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -59,9 +57,7 @@ public function testMethodCreateArchive(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -87,9 +83,7 @@ public function testMethodGetArchive(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -182,7 +176,7 @@ public function testMethodCreatePolicy(): void "", [BackupServices::DATABASES()], 1, - "" + "schedule" ); $this->assertInstanceOf(\Appwrite\Models\BackupPolicy::class, $response); @@ -269,11 +263,10 @@ public function testMethodCreateRestoration(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ]; $this->client @@ -302,11 +295,10 @@ public function testMethodListRestorations(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ] ] ]; @@ -331,11 +323,10 @@ public function testMethodGetRestoration(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ]; $this->client diff --git a/tests/Appwrite/Services/DocumentsDBTest.php b/tests/Appwrite/Services/DocumentsDBTest.php index 183fdefc..9f51a063 100644 --- a/tests/Appwrite/Services/DocumentsDBTest.php +++ b/tests/Appwrite/Services/DocumentsDBTest.php @@ -81,6 +81,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -89,13 +93,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -970,16 +968,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -989,6 +983,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1002,7 +998,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1096,10 +1092,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, diff --git a/tests/Appwrite/Services/FunctionsTest.php b/tests/Appwrite/Services/FunctionsTest.php index 0e950d3a..dc681800 100644 --- a/tests/Appwrite/Services/FunctionsTest.php +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -808,7 +808,7 @@ public function testMethodListExecutions(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ] ] ]; @@ -856,7 +856,7 @@ public function testMethodCreateExecution(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client @@ -902,7 +902,7 @@ public function testMethodGetExecution(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client diff --git a/tests/Appwrite/Services/MongoTest.php b/tests/Appwrite/Services/MongoTest.php index aaa2b0ea..3c162eca 100644 --- a/tests/Appwrite/Services/MongoTest.php +++ b/tests/Appwrite/Services/MongoTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -819,16 +804,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -838,6 +819,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -851,7 +834,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -884,16 +867,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -903,6 +882,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -916,7 +897,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -951,16 +932,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -970,6 +947,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -983,7 +962,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1099,14 +1078,10 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1131,14 +1106,10 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1161,14 +1132,10 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1186,6 +1153,33 @@ public function testMethodGetRestoration(): void $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); } + public function testMethodPromoteRestoration(): void + { + $data = [ + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "databaseId" => "5e5ea5c16897e", + "projectId" => "5e5ea5c16897e", + "type" => "backup", + "restoreMode" => "clone", + "status" => "completed", + "error" => "[ERROR]" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->mongo->promoteRestoration( + "", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); + } public function testMethodGetStatus(): void { $data = [ @@ -1194,10 +1188,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1240,16 +1230,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1259,6 +1245,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1272,7 +1260,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/MysqlTest.php b/tests/Appwrite/Services/MysqlTest.php index 85f067a6..9bfd1c2d 100644 --- a/tests/Appwrite/Services/MysqlTest.php +++ b/tests/Appwrite/Services/MysqlTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -849,16 +834,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -868,6 +849,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -881,7 +864,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -914,16 +897,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -933,6 +912,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -946,7 +927,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -981,16 +962,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1000,6 +977,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1013,7 +992,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1185,14 +1164,10 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1217,14 +1192,10 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1247,14 +1218,10 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1272,6 +1239,33 @@ public function testMethodGetRestoration(): void $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); } + public function testMethodPromoteRestoration(): void + { + $data = [ + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "databaseId" => "5e5ea5c16897e", + "projectId" => "5e5ea5c16897e", + "type" => "backup", + "restoreMode" => "clone", + "status" => "completed", + "error" => "[ERROR]" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->mysql->promoteRestoration( + "", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); + } public function testMethodGetStatus(): void { $data = [ @@ -1280,10 +1274,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1326,16 +1316,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1345,6 +1331,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1358,7 +1346,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/Oauth2Test.php b/tests/Appwrite/Services/Oauth2Test.php index 3196d5e8..ed0c9360 100644 --- a/tests/Appwrite/Services/Oauth2Test.php +++ b/tests/Appwrite/Services/Oauth2Test.php @@ -80,8 +80,8 @@ public function testMethodCreateDeviceAuthorization(): void $data = [ "device_code" => "5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a", "user_code" => "ABCD-EFGH", - "verification_uri" => "https://cloud.appwrite.io/console/oauth2/device", - "verification_uri_complete" => "https://cloud.appwrite.io/console/oauth2/device?user_code=ABCD-EFGH", + "verification_uri" => "https://appwrite.io/oauth2/device", + "verification_uri_complete" => "https://appwrite.io/oauth2/device?user_code=ABCD-EFGH", "expires_in" => 900, "interval" => 5 ]; diff --git a/tests/Appwrite/Services/OrganizationTest.php b/tests/Appwrite/Services/OrganizationTest.php index 1132dac0..7fa0c08a 100644 --- a/tests/Appwrite/Services/OrganizationTest.php +++ b/tests/Appwrite/Services/OrganizationTest.php @@ -8,7 +8,6 @@ use Mockery; use Mockery\MockInterface; use PHPUnit\Framework\TestCase; -use Appwrite\Enums\OrganizationKeyScopes; use Appwrite\Enums\ProjectKeyScopes; final class OrganizationTest extends TestCase @@ -47,6 +46,7 @@ public function testMethodGet(): void "screenshotsGenerated" => 50, "webhooks" => 25, "wafRules" => 2, + "environments" => 5, "projects" => 2, "platforms" => 3, "users" => 25, @@ -71,72 +71,6 @@ public function testMethodGet(): void "usageLogs" => 30, "projectInactivityDays" => 7, "alertLimit" => 80, - "usage" => [ - "bandwidth" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "executions" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtime" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtimeMessages" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "storage" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "users" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "GBHours" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "imageTransformations" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ] - ], "addons" => [], "budgetCapEnabled" => true, "customSmtp" => true, @@ -166,17 +100,10 @@ public function testMethodGet(): void "buildSize" => 2000, "functionsIntervalMinimum" => 60, "databasesAllowEncrypt" => true, - "group" => "starter", + "group" => "free", "databaseComputeCredit" => 10 ], "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", - "billingTrialDays" => 14, - "billingAggregationId" => "adbc3de4rddfsd", - "billingInvoiceId" => "adbc3de4rddfsd", - "paymentMethodId" => "adbc3de4rddfsd", "status" => "active", "markedForDeletion" => true, "platform" => "imagine", @@ -219,6 +146,7 @@ public function testMethodUpdate(): void "screenshotsGenerated" => 50, "webhooks" => 25, "wafRules" => 2, + "environments" => 5, "projects" => 2, "platforms" => 3, "users" => 25, @@ -243,72 +171,6 @@ public function testMethodUpdate(): void "usageLogs" => 30, "projectInactivityDays" => 7, "alertLimit" => 80, - "usage" => [ - "bandwidth" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "executions" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtime" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtimeMessages" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "storage" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "users" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "GBHours" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "imageTransformations" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ] - ], "addons" => [], "budgetCapEnabled" => true, "customSmtp" => true, @@ -338,17 +200,10 @@ public function testMethodUpdate(): void "buildSize" => 2000, "functionsIntervalMinimum" => 60, "databasesAllowEncrypt" => true, - "group" => "starter", + "group" => "free", "databaseComputeCredit" => 10 ], "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", - "billingTrialDays" => 14, - "billingAggregationId" => "adbc3de4rddfsd", - "billingInvoiceId" => "adbc3de4rddfsd", - "paymentMethodId" => "adbc3de4rddfsd", "status" => "active", "markedForDeletion" => true, "platform" => "imagine", @@ -511,138 +366,6 @@ public function testMethodDeleteInstallation(): void $this->assertSame($data, $response); } - public function testMethodListKeys(): void - { - $data = [ - "total" => 5, - "keys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->listKeys(); - - $this->assertInstanceOf(\Appwrite\Models\KeyList::class, $response); - } - public function testMethodCreateKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->createKey( - "", - "", - [OrganizationKeyScopes::PROJECTSREAD()] - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodGetKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->getKey( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodUpdateKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->updateKey( - "", - "", - [OrganizationKeyScopes::PROJECTSREAD()] - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodDeleteKey(): 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->deleteKey( - "" - ); - - $this->assertSame($data, $response); - } public function testMethodListMemberships(): void { $data = [ @@ -808,18 +531,6 @@ public function testMethodListProjects(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -858,12 +569,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -891,18 +597,6 @@ public function testMethodCreateProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -941,12 +635,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -975,18 +664,6 @@ public function testMethodGetProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -1025,12 +702,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -1058,18 +730,6 @@ public function testMethodUpdateProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -1108,12 +768,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" diff --git a/tests/Appwrite/Services/PostgresqlTest.php b/tests/Appwrite/Services/PostgresqlTest.php index f4204910..c09437c8 100644 --- a/tests/Appwrite/Services/PostgresqlTest.php +++ b/tests/Appwrite/Services/PostgresqlTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -877,16 +862,12 @@ public function testMethodCreateExtension(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -896,6 +877,8 @@ public function testMethodCreateExtension(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -909,7 +892,7 @@ public function testMethodCreateExtension(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -943,16 +926,12 @@ public function testMethodDeleteExtension(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -962,6 +941,8 @@ public function testMethodDeleteExtension(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -975,7 +956,7 @@ public function testMethodDeleteExtension(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1009,16 +990,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1028,6 +1005,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1041,7 +1020,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1074,16 +1053,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1093,6 +1068,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1106,7 +1083,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1141,16 +1118,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1160,6 +1133,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1173,7 +1148,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1345,14 +1320,10 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1377,14 +1348,10 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1407,14 +1374,10 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1432,6 +1395,33 @@ public function testMethodGetRestoration(): void $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); } + public function testMethodPromoteRestoration(): void + { + $data = [ + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "databaseId" => "5e5ea5c16897e", + "projectId" => "5e5ea5c16897e", + "type" => "backup", + "restoreMode" => "clone", + "status" => "completed", + "error" => "[ERROR]" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->postgresql->promoteRestoration( + "", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); + } public function testMethodGetStatus(): void { $data = [ @@ -1440,10 +1430,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1486,16 +1472,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1505,6 +1487,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1518,7 +1502,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/ProjectTest.php b/tests/Appwrite/Services/ProjectTest.php index ca05b4f6..5d9b3983 100644 --- a/tests/Appwrite/Services/ProjectTest.php +++ b/tests/Appwrite/Services/ProjectTest.php @@ -36,18 +36,6 @@ public function testMethodGet(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -86,12 +74,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -132,18 +115,6 @@ public function testMethodUpdateAuthMethod(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -182,12 +153,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -219,7 +185,6 @@ public function testMethodListEnvironments(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -258,12 +223,7 @@ public function testMethodListEnvironments(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -291,7 +251,6 @@ public function testMethodCreateEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -330,12 +289,7 @@ public function testMethodCreateEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -364,7 +318,6 @@ public function testMethodGetEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -403,12 +356,7 @@ public function testMethodGetEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -436,7 +384,6 @@ public function testMethodUpdateEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -475,12 +422,7 @@ public function testMethodUpdateEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -657,18 +599,6 @@ public function testMethodUpdateLabels(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -707,12 +637,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -868,18 +793,6 @@ public function testMethodUpdateOAuth2Server(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -918,12 +831,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -971,7 +879,9 @@ public function testMethodUpdateOAuth2Apple(): void "serviceId" => "ip.appwrite.app.web", "keyId" => "P4000000N8", "teamId" => "D4000000R6", - "p8File" => "-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----" + "p8File" => "-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----", + "nativeEnabled" => true, + "nativeClientIds" => [] ]; $this->client @@ -1012,6 +922,7 @@ public function testMethodUpdateOAuth2Auth0(): void "enabled" => true, "clientId" => "OaOkIA000000000000000000005KLSYq", "clientSecret" => "zXz0000-00000000000000000000000000000-00000000000000000000PJafnF", + "prompt" => ["none"], "endpoint" => "example.us.auth0.com" ]; @@ -1173,7 +1084,8 @@ public function testMethodUpdateOAuth2Discord(): void "\$id" => "github", "enabled" => true, "clientId" => "950722000000343754", - "clientSecret" => "YmPXnM000000000000000000002zFg5D" + "clientSecret" => "YmPXnM000000000000000000002zFg5D", + "prompt" => ["none"] ]; $this->client @@ -1314,7 +1226,8 @@ public function testMethodUpdateOAuth2GitHub(): void "\$id" => "github", "enabled" => true, "clientId" => "e4d87900000000540733", - "clientSecret" => "5e07c00000000000000000000000000000198bcc" + "clientSecret" => "5e07c00000000000000000000000000000198bcc", + "prompt" => ["select_account"] ]; $this->client @@ -1356,7 +1269,9 @@ public function testMethodUpdateOAuth2Google(): void "enabled" => true, "clientId" => "120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com", "clientSecret" => "GOCSPX-2k8gsR0000000000000000VNahJj", - "prompt" => ["none"] + "prompt" => ["none"], + "nativeEnabled" => true, + "nativeClientIds" => [] ]; $this->client @@ -1480,6 +1395,7 @@ public function testMethodUpdateOAuth2Microsoft(): void "enabled" => true, "applicationId" => "00001111-aaaa-2222-bbbb-3333cccc4444", "applicationSecret" => "A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u", + "prompt" => ["none"], "tenant" => "common" ]; @@ -1521,11 +1437,11 @@ public function testMethodUpdateOAuth2Oidc(): void "enabled" => true, "clientId" => "qibI2x0000000000000000000000000006L2YFoG", "clientSecret" => "Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV", + "prompt" => ["none"], "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", - "prompt" => ["none"] + "userInfoURL" => "https://myoauth.com/oauth2/userinfo" ]; $this->client @@ -1546,6 +1462,7 @@ public function testMethodUpdateOAuth2Okta(): void "enabled" => true, "clientId" => "0oa00000000000000698", "clientSecret" => "Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV", + "prompt" => ["none"], "domain" => "trial-6400025.okta.com", "authorizationServerId" => "aus000000000000000h7z" ]; @@ -1647,7 +1564,8 @@ public function testMethodUpdateOAuth2Salesforce(): void "\$id" => "github", "enabled" => true, "customerKey" => "3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq", - "customerSecret" => "3w000000000000e2" + "customerSecret" => "3w000000000000e2", + "prompt" => ["login"] ]; $this->client @@ -1907,7 +1825,8 @@ public function testMethodUpdateOAuth2Zoho(): void "\$id" => "github", "enabled" => true, "clientId" => "1000.83C178000000000000000000RPNX0B", - "clientSecret" => "fb5cac000000000000000000000000000000a68f6e" + "clientSecret" => "fb5cac000000000000000000000000000000a68f6e", + "prompt" => ["consent"] ]; $this->client @@ -1995,7 +1914,8 @@ public function testMethodCreateAndroidPlatform(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "My Web App", "type" => "windows", - "applicationId" => "com.company.appname" + "applicationId" => "com.company.appname", + "fingerprints" => [] ]; $this->client @@ -2021,7 +1941,8 @@ public function testMethodUpdateAndroidPlatform(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "My Web App", "type" => "windows", - "applicationId" => "com.company.appname" + "applicationId" => "com.company.appname", + "fingerprints" => [] ]; $this->client @@ -2320,18 +2241,6 @@ public function testMethodUpdateDenyAliasedEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2370,12 +2279,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2403,18 +2307,6 @@ public function testMethodUpdateDenyCorporateEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2453,12 +2345,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2486,18 +2373,6 @@ public function testMethodUpdateDenyDisposableEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2536,12 +2411,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2569,18 +2439,6 @@ public function testMethodUpdateDenyFreeEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2619,12 +2477,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2652,18 +2505,6 @@ public function testMethodUpdateMembershipPrivacyPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2702,12 +2543,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2733,18 +2569,6 @@ public function testMethodUpdateMFAFactorsPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2783,12 +2607,7 @@ public function testMethodUpdateMFAFactorsPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2814,18 +2633,6 @@ public function testMethodUpdatePasskeyPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2864,12 +2671,7 @@ public function testMethodUpdatePasskeyPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2897,18 +2699,6 @@ public function testMethodUpdatePasswordDictionaryPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2947,12 +2737,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2980,18 +2765,6 @@ public function testMethodUpdatePasswordHistoryPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3030,12 +2803,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3063,18 +2831,6 @@ public function testMethodUpdatePasswordPersonalDataPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3113,12 +2869,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3146,7 +2897,6 @@ public function testMethodUpdatePasswordPwnedPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3185,12 +2935,7 @@ public function testMethodUpdatePasswordPwnedPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3216,7 +2961,6 @@ public function testMethodUpdatePasswordRotationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3255,12 +2999,7 @@ public function testMethodUpdatePasswordRotationPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3308,18 +3047,6 @@ public function testMethodUpdateSessionAlertPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3358,12 +3085,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3391,18 +3113,6 @@ public function testMethodUpdateSessionDurationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3441,12 +3151,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3474,18 +3179,6 @@ public function testMethodUpdateSessionInvalidationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3524,12 +3217,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3557,18 +3245,6 @@ public function testMethodUpdateSessionLimitPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3607,12 +3283,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3640,18 +3311,6 @@ public function testMethodUpdateUserLimitPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3690,12 +3349,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3749,18 +3403,6 @@ public function testMethodUpdateProtocol(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3799,12 +3441,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3833,18 +3470,6 @@ public function testMethodUpdateService(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3883,12 +3508,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3917,18 +3537,6 @@ public function testMethodUpdateSMTP(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3967,12 +3575,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" diff --git a/tests/Appwrite/Services/ProxyTest.php b/tests/Appwrite/Services/ProxyTest.php index df5e0217..209b4f20 100644 --- a/tests/Appwrite/Services/ProxyTest.php +++ b/tests/Appwrite/Services/ProxyTest.php @@ -65,7 +65,8 @@ public function testMethodListRules(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ] ] ]; @@ -97,7 +98,8 @@ public function testMethodCreateAPIRule(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client @@ -129,7 +131,8 @@ public function testMethodCreateFunctionRule(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client @@ -162,7 +165,8 @@ public function testMethodCreateRedirectRule(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client @@ -198,7 +202,8 @@ public function testMethodCreateSiteRule(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client @@ -215,6 +220,40 @@ public function testMethodCreateSiteRule(): void $this->assertInstanceOf(\Appwrite\Models\ProxyRule::class, $response); } + public function testMethodCreateSMTPRule(): void + { + $data = [ + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "domain" => "appwrite.company.com", + "type" => "deployment", + "trigger" => "manual", + "redirectUrl" => "https://appwrite.io/docs", + "redirectStatusCode" => 301, + "deploymentId" => "n3u9feiwmf", + "deploymentResourceId" => "n3u9feiwmf", + "deploymentVcsProviderBranch" => "main", + "status" => "unverified", + "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", + "renewAt" => "datetime", + "protocol" => "http" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->proxy->createSMTPRule( + "example.com", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\ProxyRule::class, $response); + } public function testMethodGetRule(): void { $data = [ @@ -231,7 +270,8 @@ public function testMethodGetRule(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client @@ -280,7 +320,8 @@ public function testMethodUpdateRuleStatus(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client diff --git a/tests/Appwrite/Services/SitesTest.php b/tests/Appwrite/Services/SitesTest.php index 1dd5e5aa..0b0f8581 100644 --- a/tests/Appwrite/Services/SitesTest.php +++ b/tests/Appwrite/Services/SitesTest.php @@ -829,7 +829,7 @@ public function testMethodListLogs(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ] ] ]; @@ -877,7 +877,7 @@ public function testMethodGetLog(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client diff --git a/tests/Appwrite/Services/TablesDBTest.php b/tests/Appwrite/Services/TablesDBTest.php index 51b883a9..5ef55c32 100644 --- a/tests/Appwrite/Services/TablesDBTest.php +++ b/tests/Appwrite/Services/TablesDBTest.php @@ -82,6 +82,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -90,13 +94,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -321,16 +319,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -340,6 +334,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -353,7 +349,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -613,10 +609,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1651,6 +1643,39 @@ public function testMethodCreateRelationshipColumn(): void $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); } + public function testMethodUpdateRelationshipColumn(): void + { + $data = [ + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "relatedTable" => "table", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->tablesDB->updateRelationshipColumn( + "", + "", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); + } public function testMethodCreateStringColumn(): void { $data = [ @@ -1939,39 +1964,6 @@ public function testMethodDeleteColumn(): void $this->assertSame($data, $response); } - public function testMethodUpdateRelationshipColumn(): void - { - $data = [ - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "relatedTable" => "table", - "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", - "twoWay" => true, - "twoWayKey" => "string", - "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child" - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->tablesDB->updateRelationshipColumn( - "", - "", - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); - } public function testMethodListIndexes(): void { $data = [ diff --git a/tests/Appwrite/Services/UsersTest.php b/tests/Appwrite/Services/UsersTest.php index 4179bae7..34677d39 100644 --- a/tests/Appwrite/Services/UsersTest.php +++ b/tests/Appwrite/Services/UsersTest.php @@ -224,7 +224,8 @@ public function testMethodListIdentities(): void "providerEmail" => "user@example.com", "providerAccessToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", "providerAccessTokenExpiry" => "2020-10-15T06:38:00.000+00:00", - "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3" + "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerIdToken" => "eyJhbGciOiJSUzI1NiIsImtpZCI6IjBhYzNmMWQwNWExYjhlN2YifQ.eyJzdWIiOiIxMTAxNjk0ODQ0NzQzODYyNzYzMzQifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ] ] ]; @@ -719,51 +720,6 @@ public function testMethodUpdateLabels(): void $this->assertInstanceOf(\Appwrite\Models\User::class, $response); } - public function testMethodListLogs(): void - { - $data = [ - "total" => 5, - "logs" => [ - [ - "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->users->listLogs( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } public function testMethodListMemberships(): void { $data = [ diff --git a/tests/Appwrite/Services/VectorsDBTest.php b/tests/Appwrite/Services/VectorsDBTest.php index fdb22e76..70fb88c4 100644 --- a/tests/Appwrite/Services/VectorsDBTest.php +++ b/tests/Appwrite/Services/VectorsDBTest.php @@ -81,6 +81,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -89,13 +93,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -950,16 +948,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -969,6 +963,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -982,7 +978,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1076,10 +1072,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, diff --git a/tests/Appwrite/TopicTest.php b/tests/Appwrite/TopicTest.php new file mode 100644 index 00000000..c86f8d30 --- /dev/null +++ b/tests/Appwrite/TopicTest.php @@ -0,0 +1,50 @@ +assertSame('user', (string) Topic::path(['user'])); + $this->assertSame('user/notification', (string) Topic::path(['user', 'notification'])); + $this->assertSame('user/notification', (string) Topic::path(['user'])->path(['notification'])); + $this->assertSame('org/42/logs', (string) Topic::path(['org', '42'])->path(['logs'])); + } + + /** + * @return \Iterator + */ + public static function invalidLevels(): \Iterator + { + yield 'not an array' => ['user']; + yield 'empty path' => [[]]; + yield 'not a string' => [['user', 42]]; + yield 'null' => [['user', null]]; + yield 'empty level' => [['user', '']]; + yield 'slash' => [['user/123']]; + yield 'plus' => [['user', '+']]; + yield 'contains plus' => [['user', 'a+b']]; + yield 'hash' => [['user', '#']]; + yield 'contains hash' => [['user', 'a#b']]; + } + + #[DataProvider('invalidLevels')] + public function testInvalidLevels(mixed $levels): void + { + $this->expectException(\InvalidArgumentException::class); + Topic::path($levels); + } + + #[DataProvider('invalidLevels')] + public function testInvalidLevelsWhenAppending(mixed $levels): void + { + $this->expectException(\InvalidArgumentException::class); + Topic::path(['user'])->path($levels); + } +} From b9a4169a9852ebd6b990660a65e93cf3ebb5a0af Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 15 Oct 2026 12:51:26 +0100 Subject: [PATCH 4/4] feat: SDK update for the 2.5.x majors --- .gitignore | 1 + CHANGELOG.md | 22 + README.md | 33 +- composer.json | 1 + docs/account.md | 22 +- docs/apps.md | 2 +- docs/avatars.md | 4 +- docs/databases.md | 4 +- docs/documentsdb.md | 2 +- docs/examples/account/list-logs.md | 18 - docs/examples/avatars/get-screenshot.md | 3 +- docs/examples/databases/create-document.md | 2 +- docs/examples/databases/create-documents.md | 11 +- .../databases/create-enum-attribute.md | 5 +- docs/examples/databases/create-index.md | 4 +- .../databases/create-line-attribute.md | 15 +- docs/examples/databases/create-operations.md | 20 +- .../databases/create-point-attribute.md | 5 +- .../databases/create-polygon-attribute.md | 21 +- docs/examples/databases/delete-documents.md | 4 +- docs/examples/databases/update-document.md | 2 +- docs/examples/databases/update-documents.md | 2 +- .../databases/update-enum-attribute.md | 5 +- .../databases/update-line-attribute.md | 15 +- .../databases/update-point-attribute.md | 5 +- .../databases/update-polygon-attribute.md | 21 +- docs/examples/databases/upsert-document.md | 2 +- docs/examples/databases/upsert-documents.md | 11 +- docs/examples/documentsdb/create-document.md | 2 +- docs/examples/documentsdb/create-documents.md | 11 +- docs/examples/documentsdb/create-index.md | 4 +- .../examples/documentsdb/create-operations.md | 20 +- docs/examples/documentsdb/delete-documents.md | 4 +- docs/examples/documentsdb/upsert-documents.md | 11 +- .../embeddings/create-text-embeddings.md | 5 +- docs/examples/functions/create.md | 4 +- docs/examples/functions/update.md | 7 +- docs/examples/graphql/mutation.md | 4 +- docs/examples/graphql/query.md | 4 +- docs/examples/messaging/create-topic.md | 4 +- .../messaging/create-twilio-provider.md | 2 +- docs/examples/messaging/update-topic.md | 4 +- docs/examples/mongo/create-restoration.md | 5 +- .../promote-restoration.md} | 9 +- docs/examples/mysql/create-restoration.md | 5 +- .../promote-restoration.md} | 9 +- docs/examples/oauth2/approve.md | 4 +- docs/examples/oauth2/authorize-post.md | 6 +- docs/examples/oauth2/authorize.md | 6 +- .../oauth2/create-device-authorization.md | 6 +- docs/examples/oauth2/create-grant.md | 4 +- docs/examples/oauth2/create-par.md | 6 +- docs/examples/oauth2/create-token.md | 6 +- docs/examples/oauth2/get-grant.md | 4 +- docs/examples/oauth2/list-organizations.md | 4 +- docs/examples/oauth2/list-projects.md | 4 +- docs/examples/oauth2/reject.md | 4 +- docs/examples/oauth2/revoke.md | 4 +- docs/examples/organization/create-key.md | 21 - docs/examples/organization/update-key.md | 21 - .../examples/postgresql/create-restoration.md | 5 +- .../promote-restoration.md} | 11 +- docs/examples/project/create-ephemeral-key.md | 2 +- docs/examples/project/create-smtp-test.md | 4 +- docs/examples/project/update-key.md | 2 +- docs/examples/project/update-labels.md | 4 +- .../examples/project/update-o-auth-2-kakao.md | 4 +- .../create-smtp-rule.md} | 11 +- docs/examples/tablesdb/create-enum-column.md | 5 +- docs/examples/tablesdb/create-index.md | 4 +- docs/examples/tablesdb/create-line-column.md | 15 +- docs/examples/tablesdb/create-operations.md | 20 +- docs/examples/tablesdb/create-point-column.md | 5 +- .../tablesdb/create-polygon-column.md | 21 +- docs/examples/tablesdb/create-row.md | 2 +- docs/examples/tablesdb/create-rows.md | 11 +- docs/examples/tablesdb/delete-rows.md | 4 +- docs/examples/tablesdb/update-enum-column.md | 5 +- docs/examples/tablesdb/update-line-column.md | 15 +- docs/examples/tablesdb/update-point-column.md | 5 +- .../tablesdb/update-polygon-column.md | 21 +- docs/examples/tablesdb/update-row.md | 2 +- docs/examples/tablesdb/update-rows.md | 2 +- docs/examples/tablesdb/upsert-row.md | 2 +- docs/examples/tablesdb/upsert-rows.md | 11 +- docs/examples/teams/create-membership.md | 4 +- docs/examples/teams/update-membership.md | 4 +- docs/examples/users/update-labels.md | 4 +- docs/examples/vectorsdb/create-collection.md | 2 +- docs/examples/vectorsdb/create-document.md | 8 +- docs/examples/vectorsdb/create-documents.md | 15 +- docs/examples/vectorsdb/create-index.md | 4 +- docs/examples/vectorsdb/create-operations.md | 28 +- docs/examples/vectorsdb/delete-documents.md | 4 +- docs/examples/vectorsdb/update-collection.md | 2 +- docs/examples/vectorsdb/upsert-documents.md | 15 +- docs/examples/webhooks/create.md | 4 +- docs/examples/webhooks/update.md | 4 +- docs/functions.md | 1 + docs/messaging.md | 14 +- docs/mongo.md | 32 +- docs/mysql.md | 38 +- docs/oauth2.md | 10 +- docs/organization.md | 74 +- docs/postgresql.md | 38 +- docs/project.md | 12 +- docs/proxy.md | 21 +- docs/storage.md | 2 +- docs/tablesdb.md | 46 +- docs/teams.md | 2 +- docs/users.md | 19 +- docs/vectorsdb.md | 2 +- docs/webhooks.md | 8 +- src/Appwrite/Client.php | 75 +- src/Appwrite/Enums/BillingPlanGroup.php | 8 - src/Appwrite/Enums/ExecutionTrigger.php | 8 + src/Appwrite/Enums/OrganizationKeyScopes.php | 162 ---- src/Appwrite/Enums/ProxyRuleProtocol.php | 50 ++ src/Appwrite/Models/ActivityEventList.php | 5 +- src/Appwrite/Models/App.php | 5 +- src/Appwrite/Models/AppInstallationList.php | 5 +- src/Appwrite/Models/AppKeyList.php | 5 +- src/Appwrite/Models/AppScopeList.php | 5 +- src/Appwrite/Models/AppSecretList.php | 5 +- src/Appwrite/Models/AppsList.php | 5 +- src/Appwrite/Models/AttributeEnum.php | 4 +- src/Appwrite/Models/AttributeList.php | 5 +- src/Appwrite/Models/BackupArchive.php | 27 +- src/Appwrite/Models/BackupArchiveList.php | 5 +- src/Appwrite/Models/BackupPolicy.php | 9 +- src/Appwrite/Models/BackupPolicyList.php | 5 +- src/Appwrite/Models/BackupRestoration.php | 24 +- src/Appwrite/Models/BackupRestorationList.php | 5 +- src/Appwrite/Models/BillingPlan.php | 16 +- src/Appwrite/Models/Block.php | 42 +- src/Appwrite/Models/BucketList.php | 5 +- src/Appwrite/Models/Collection.php | 13 +- src/Appwrite/Models/CollectionList.php | 5 +- src/Appwrite/Models/ColumnEnum.php | 4 +- src/Appwrite/Models/ColumnIndexList.php | 5 +- src/Appwrite/Models/ColumnList.php | 5 +- src/Appwrite/Models/ContinentList.php | 5 +- src/Appwrite/Models/CountryList.php | 5 +- src/Appwrite/Models/CurrencyList.php | 5 +- src/Appwrite/Models/Database.php | 2 +- src/Appwrite/Models/DatabaseList.php | 5 +- src/Appwrite/Models/DatabaseMigrationList.php | 5 +- src/Appwrite/Models/DatabaseStatus.php | 18 +- src/Appwrite/Models/DedicatedDatabase.php | 55 +- .../Models/DedicatedDatabaseBackupList.php | 5 +- .../Models/DedicatedDatabaseBranch.php | 14 +- .../Models/DedicatedDatabaseBranchList.php | 5 +- .../Models/DedicatedDatabaseExecution.php | 5 +- .../Models/DedicatedDatabaseExtensions.php | 5 +- src/Appwrite/Models/DedicatedDatabaseList.php | 5 +- .../Models/DedicatedDatabaseOperationList.php | 5 +- .../Models/DedicatedDatabaseReplicas.php | 5 +- .../Models/DedicatedDatabaseRestoration.php | 55 +- .../DedicatedDatabaseRestorationList.php | 5 +- .../Models/DedicatedDatabaseSpecification.php | 32 +- .../DedicatedDatabaseSpecificationList.php | 18 +- .../DedicatedDatabaseSpecificationPricing.php | 70 -- src/Appwrite/Models/DeploymentList.php | 5 +- src/Appwrite/Models/DevKey.php | 98 --- src/Appwrite/Models/Document.php | 5 +- src/Appwrite/Models/DocumentList.php | 5 +- src/Appwrite/Models/EmailTemplateList.php | 5 +- src/Appwrite/Models/EmbeddingList.php | 5 +- src/Appwrite/Models/EphemeralKey.php | 5 +- src/Appwrite/Models/Execution.php | 16 +- src/Appwrite/Models/ExecutionList.php | 5 +- src/Appwrite/Models/FileList.php | 5 +- src/Appwrite/Models/Framework.php | 9 +- src/Appwrite/Models/FrameworkList.php | 5 +- src/Appwrite/Models/FunctionList.php | 5 +- src/Appwrite/Models/FunctionModel.php | 12 +- src/Appwrite/Models/Identity.php | 7 +- src/Appwrite/Models/IdentityList.php | 5 +- src/Appwrite/Models/IndexList.php | 5 +- src/Appwrite/Models/Insight.php | 5 +- src/Appwrite/Models/InsightList.php | 5 +- src/Appwrite/Models/Key.php | 5 +- src/Appwrite/Models/KeyList.php | 5 +- src/Appwrite/Models/LanguageList.php | 5 +- src/Appwrite/Models/LocaleCodeList.php | 5 +- src/Appwrite/Models/Log.php | 196 ----- src/Appwrite/Models/LogList.php | 61 -- src/Appwrite/Models/MembershipList.php | 5 +- src/Appwrite/Models/Message.php | 13 +- src/Appwrite/Models/MessageList.php | 5 +- src/Appwrite/Models/MockNumberList.php | 5 +- src/Appwrite/Models/OAuth2Apple.php | 14 +- src/Appwrite/Models/OAuth2Auth0.php | 23 +- src/Appwrite/Models/OAuth2Discord.php | 19 +- src/Appwrite/Models/OAuth2Github.php | 19 +- src/Appwrite/Models/OAuth2Google.php | 16 +- src/Appwrite/Models/OAuth2Kakao.php | 2 +- src/Appwrite/Models/OAuth2Microsoft.php | 23 +- src/Appwrite/Models/OAuth2Oidc.php | 18 +- src/Appwrite/Models/OAuth2Okta.php | 25 +- src/Appwrite/Models/OAuth2ProviderList.php | 5 +- src/Appwrite/Models/OAuth2Salesforce.php | 19 +- src/Appwrite/Models/OAuth2Zoho.php | 19 +- src/Appwrite/Models/Oauth2ConsentList.php | 5 +- .../Models/Oauth2ConsentTokenList.php | 5 +- .../Models/Oauth2OrganizationList.php | 5 +- src/Appwrite/Models/Oauth2ProjectList.php | 5 +- src/Appwrite/Models/Organization.php | 63 +- src/Appwrite/Models/Passkey.php | 22 +- src/Appwrite/Models/PasskeyChallenge.php | 22 +- src/Appwrite/Models/PasskeyList.php | 10 +- src/Appwrite/Models/PhoneList.php | 5 +- src/Appwrite/Models/PlatformAndroid.php | 7 +- src/Appwrite/Models/PlatformList.php | 5 +- src/Appwrite/Models/PolicyList.php | 5 +- src/Appwrite/Models/PolicyPasskey.php | 14 +- src/Appwrite/Models/Presence.php | 5 +- src/Appwrite/Models/PresenceList.php | 5 +- src/Appwrite/Models/Project.php | 29 +- src/Appwrite/Models/ProjectList.php | 5 +- src/Appwrite/Models/ProviderList.php | 5 +- src/Appwrite/Models/ProxyRule.php | 10 +- src/Appwrite/Models/ProxyRuleList.php | 5 +- src/Appwrite/Models/Report.php | 5 +- src/Appwrite/Models/ReportList.php | 5 +- src/Appwrite/Models/ResourceTokenList.php | 5 +- src/Appwrite/Models/Row.php | 5 +- src/Appwrite/Models/RowList.php | 5 +- src/Appwrite/Models/Runtime.php | 5 +- src/Appwrite/Models/RuntimeList.php | 5 +- src/Appwrite/Models/SessionList.php | 5 +- src/Appwrite/Models/Site.php | 4 +- src/Appwrite/Models/SiteList.php | 5 +- src/Appwrite/Models/SpecificationList.php | 5 +- src/Appwrite/Models/SubscriberList.php | 5 +- src/Appwrite/Models/Table.php | 13 +- src/Appwrite/Models/TableList.php | 5 +- src/Appwrite/Models/TargetList.php | 5 +- src/Appwrite/Models/TeamList.php | 5 +- src/Appwrite/Models/TokenSecret.php | 26 +- src/Appwrite/Models/Topic.php | 2 +- src/Appwrite/Models/TopicList.php | 5 +- src/Appwrite/Models/TransactionList.php | 5 +- src/Appwrite/Models/UsageBillingPlan.php | 72 +- src/Appwrite/Models/User.php | 4 +- src/Appwrite/Models/UserList.php | 5 +- src/Appwrite/Models/VariableList.php | 5 +- src/Appwrite/Models/VectorsdbCollection.php | 13 +- .../Models/VectorsdbCollectionList.php | 5 +- src/Appwrite/Models/Webhook.php | 2 +- src/Appwrite/Models/WebhookList.php | 5 +- src/Appwrite/Query.php | 367 ++++++-- src/Appwrite/Query/Builder.php | 558 ++++++++++++ src/Appwrite/Services/Account.php | 100 ++- src/Appwrite/Services/Activities.php | 4 + src/Appwrite/Services/Advisor.php | 21 + src/Appwrite/Services/Apps.php | 100 +++ src/Appwrite/Services/Avatars.php | 6 +- src/Appwrite/Services/Backups.php | 24 + src/Appwrite/Services/Databases.php | 664 +++++++++++++- src/Appwrite/Services/DocumentsDB.php | 253 +++++- src/Appwrite/Services/Functions.php | 134 ++- src/Appwrite/Services/Messaging.php | 125 ++- src/Appwrite/Services/Mongo.php | 217 ++++- src/Appwrite/Services/Mysql.php | 233 ++++- src/Appwrite/Services/Oauth2.php | 14 +- src/Appwrite/Services/Organization.php | 222 +---- src/Appwrite/Services/Postgresql.php | 249 +++++- src/Appwrite/Services/Presences.php | 17 + src/Appwrite/Services/Project.php | 77 +- src/Appwrite/Services/Proxy.php | 56 ++ src/Appwrite/Services/Sites.php | 131 ++- src/Appwrite/Services/Storage.php | 88 +- src/Appwrite/Services/TablesDB.php | 812 ++++++++++++++++-- src/Appwrite/Services/Teams.php | 94 ++ src/Appwrite/Services/Tokens.php | 29 + src/Appwrite/Services/Users.php | 210 ++++- src/Appwrite/Services/VectorsDB.php | 234 ++++- src/Appwrite/Services/Webhooks.php | 22 +- src/Appwrite/Topic.php | 115 +++ tests/Appwrite/ClientTest.php | 159 +++- tests/Appwrite/QueryTest.php | 285 +++++- tests/Appwrite/Services/AccountTest.php | 46 +- tests/Appwrite/Services/BackupsTest.php | 17 +- tests/Appwrite/Services/DocumentsDBTest.php | 24 +- tests/Appwrite/Services/FunctionsTest.php | 21 +- tests/Appwrite/Services/MongoTest.php | 144 ++-- tests/Appwrite/Services/MysqlTest.php | 144 ++-- tests/Appwrite/Services/Oauth2Test.php | 4 +- tests/Appwrite/Services/OrganizationTest.php | 361 +------- tests/Appwrite/Services/PostgresqlTest.php | 160 ++-- tests/Appwrite/Services/ProjectTest.php | 499 ++--------- tests/Appwrite/Services/ProxyTest.php | 55 +- tests/Appwrite/Services/SitesTest.php | 4 +- tests/Appwrite/Services/TablesDBTest.php | 90 +- tests/Appwrite/Services/UsersTest.php | 48 +- tests/Appwrite/Services/VectorsDBTest.php | 24 +- tests/Appwrite/TopicTest.php | 51 ++ 298 files changed, 6793 insertions(+), 3643 deletions(-) delete mode 100644 docs/examples/account/list-logs.md rename docs/examples/{organization/delete-key.md => mongo/promote-restoration.md} (61%) rename docs/examples/{organization/get-key.md => mysql/promote-restoration.md} (61%) delete mode 100644 docs/examples/organization/create-key.md delete mode 100644 docs/examples/organization/update-key.md rename docs/examples/{users/list-logs.md => postgresql/promote-restoration.md} (58%) rename docs/examples/{organization/list-keys.md => proxy/create-smtp-rule.md} (58%) delete mode 100644 src/Appwrite/Enums/OrganizationKeyScopes.php create mode 100644 src/Appwrite/Enums/ProxyRuleProtocol.php delete mode 100644 src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php delete mode 100644 src/Appwrite/Models/DevKey.php delete mode 100644 src/Appwrite/Models/Log.php delete mode 100644 src/Appwrite/Models/LogList.php create mode 100644 src/Appwrite/Query/Builder.php create mode 100644 src/Appwrite/Topic.php create mode 100644 tests/Appwrite/TopicTest.php diff --git a/.gitignore b/.gitignore index d1502b08..d0757eb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor/ composer.lock +.phpunit.cache/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 7353dbb9..89bd3f0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Change Log +## 31.0.0 + +* Breaking: requests send `X-Appwrite-Response-Format: 2.5.0`; responses follow the 2.5 shapes +* Breaking: removed `Account::listLogs`, `Users::listLogs` and the `Log`/`LogList` models +* Breaking: removed `Organization::createKey`, `getKey`, `listKeys`, `updateKey` and `deleteKey`, and `OrganizationKeyScopes`; use `Organization::listProjectKeys`, `getProjectKey`, `updateProjectKey` and `deleteProjectKey` instead +* Breaking: removed `Client::setDevKey`, the `DevKey` model and `Project::$devKeys` +* Breaking: removed `BillingPlanGroup::STARTER()`; use `BillingPlanGroup::FREE()` +* Breaking: `listSpecifications` returns each specification's prices and overage rates on the row itself. Removed the list-level `$pricing` field and the `DedicatedDatabaseSpecificationPricing` model +* Breaking: removed `Block` fields `reason`, `projectName`, `region`, `organizationName`, `organizationId` and `billingPlan` +* Breaking: OAuth2 `resource` params now take `?array` +* Breaking: `Project::updateOAuth2Kakao` takes `$enabled` before `$prompt` +* Breaking: `BackupRestoration::$options` is now an array +* Breaking: some response fields became nullable, such as `BillingPlan::$usage` and `DedicatedDatabase::$engine` +* Breaking: the protected `Client::flatten` is renamed `flattenForm`; subclasses that override it must rename it +* Added: `Topic` helper to build MQTT topics for push messages +* Added: `Mongo`, `Mysql` and `Postgresql` `promoteRestoration`, `$restoreMode`, `$targetName` and `$autoPromote` on `createRestoration`, and `DedicatedDatabaseRestoration::$restoreMode` +* Added: `Proxy::createSMTPRule`, the `ProxyRuleProtocol` enum and `ProxyRule::$protocol` +* Added: `$emailEnabled` on `Functions::update` and `FunctionModel`, and `ExecutionTrigger::EMAIL()` +* Added: `Query` aggregates (`count`, `countDistinct`, `sum`, `avg`, `min`, `max` and more), `groupBy`, `having`, `distinct`, joins, `relationship`, `covers`, `spatialEquals` and `page` +* Added: `Query::builder()` to chain queries; `build()` returns the query list +* Fixed: OAuth2 models wrap a single `prompt` value in a list + ## 30.4.0 * Added: `domains` service to manage domains, DNS records, email presets, prices, transfer status and zones diff --git a/README.md b/README.md index bd76997b..abc2f231 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-2.0.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-2.5.0-blue.svg?style=flat-square&v=1) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK targets Appwrite server version 1.9.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-php/releases) when APIs differ. +**This SDK targets Appwrite server version 2.5.x as shipped on Appwrite Cloud.** Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from [previous releases](https://github.com/appwrite/sdk-for-php/releases) when APIs differ. Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) @@ -22,6 +22,33 @@ composer require appwrite/appwrite Requires PHP 8.5 or later. +### Custom HTTP transport + +For applications that configure their own HTTP transport, pass any PSR-18 client to the constructor. Hosts that run SDK calls concurrently, such as Swoole coroutines, should pass a pooled client so no cURL handle is shared between coroutines: + +```php +use Appwrite\Client; +use Utopia\Client\Adapter\SwooleCoroutine\Client as SwooleAdapter; +use Utopia\Client\Client as HttpClient; +use Utopia\Client\Pool as PooledClient; +use Utopia\Pools\Adapter\Swoole as SwoolePool; +use Utopia\Pools\Pool; + +$client = new Client(new PooledClient(new Pool( + new SwoolePool(), + 'appwrite', + 128, + fn (): HttpClient => new HttpClient(new SwooleAdapter()) + ->withConnectionReuse() + ->withTimeout(5) + ->withConnectTimeout(2), + timeout: 3.0, +))); +$client->setEndpoint('https://cloud.appwrite.io/v1'); +``` + +Configure timeouts, TLS, redirects, and connection reuse on the injected transport. The SDK's `setTimeout()`, `setConnectTimeout()`, and `setSelfSigned()` methods only configure the default cURL transport. Endpoint, authentication, headers, request encoding, and response handling remain the SDK's responsibility. A transport used with `responseType: 'location'` must have redirect following disabled. + ## Getting Started @@ -76,7 +103,7 @@ $users = new Users($client); try { $user = $users->create(ID::unique(), "email@example.com", "+123456789", "password", "Walter O'Brien"); } catch(AppwriteException $error) { - echo $error->message; + echo $error->getMessage(); } ``` diff --git a/composer.json b/composer.json index 21faff5f..135f6928 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "php": ">=8.5", "ext-curl": "*", "ext-json": "*", + "psr/http-client": "^1.0", "utopia-php/client": "^0.6", "adhocore/jwt": "^1.1" }, diff --git a/docs/account.md b/docs/account.md index 80e592a5..efbee573 100644 --- a/docs/account.md +++ b/docs/account.md @@ -150,20 +150,6 @@ DELETE https://cloud.appwrite.io/v1/account/identities/{identityId} | identityId | string | **Required** Identity ID. | | -```http request -GET https://cloud.appwrite.io/v1/account/logs -``` - -** Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log. ** - -### 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). 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 PATCH https://cloud.appwrite.io/v1/account/mfa ``` @@ -591,7 +577,7 @@ GET https://cloud.appwrite.io/v1/account/sessions DELETE https://cloud.appwrite.io/v1/account/sessions ``` -** Delete all sessions from the user account and remove any sessions cookies from the end client. ** +** Delete all sessions from the user account and remove any sessions cookies from the end client. Pass `current` as false to keep the session making the request and sign out of every other session. ** ### Parameters @@ -611,7 +597,7 @@ POST https://cloud.appwrite.io/v1/account/sessions/anonymous POST https://cloud.appwrite.io/v1/account/sessions/email ``` -** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. +** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user. Use the optional `duration` parameter to create a shorter session, for example when the user doesn't choose "remember me". It must be at least 60 seconds and cannot exceed the project maximum session length. A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). ** @@ -786,13 +772,15 @@ GET https://cloud.appwrite.io/v1/account/tokens/oauth2/{provider} If authentication succeeds, `userId` and `secret` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint. +If there is already an active session, the OAuth2 identity is attached to the logged-in account and that session stays active until the token is exchanged for a new one. + A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). ** ### Parameters | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| provider | string | **Required** OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, 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, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, 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/apps.md b/docs/apps.md index fde01429..60c5d7f5 100644 --- a/docs/apps.md +++ b/docs/apps.md @@ -242,7 +242,7 @@ PUT https://cloud.appwrite.io/v1/apps/{appId}/labels | Field Name | Type | Description | Default | | --- | --- | --- | --- | | appId | string | **Required** Application unique ID. | | -| labels | array | Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | | +| labels | array | Array of application labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. Reserved labels are rejected. | | ```http request diff --git a/docs/avatars.md b/docs/avatars.md index 7b9377d2..d5713014 100644 --- a/docs/avatars.md +++ b/docs/avatars.md @@ -116,7 +116,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre GET https://cloud.appwrite.io/v1/avatars/photo ``` -** Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. +** Returns the best available profile photo for a user. The endpoint tries each source in priority order and returns the first successful result: a custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in static fallback. Passing `userId` — `current()` for the authenticated user — resolves the photo from everything known about that user: identity photos, email, and name. An explicit `emailHash` or `name` then overrides just that value, and the user's remaining sources stay in the chain. Without `userId`, passing `emailHash` and/or `name` resolves the avatar from those values alone: the hash is looked up on Gravatar and Libravatar, the name is rendered as initials, and the session user stays out of the chain so their own photo never shadows the avatar being asked for. When nothing is passed, the photo resolves for the currently authenticated user. Emails are only ever accepted pre-hashed, so no address ends up in a URL. ** @@ -186,7 +186,7 @@ When width and height are specified, the image is resized accordingly. If both d | Field Name | Type | Description | Default | | --- | --- | --- | --- | | url | string | **Required** Website URL which you want to capture. | | -| headers | object | HTTP headers to send with the browser request. Defaults to empty. | {} | +| headers | object | HTTP headers to send with the browser request. Only Accept and Accept-Language are allowed. Defaults to empty. | {} | | viewportWidth | integer | Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280. | 1280 | | viewportHeight | integer | Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720. | 720 | | scale | number | Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1. | 1 | diff --git a/docs/databases.md b/docs/databases.md index 1b1f7bf6..042e19e4 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -188,7 +188,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections | documentSecurity | boolean | Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. | 1 | | attributes | array | Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. | [] | -| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | +| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | ```http request @@ -1210,7 +1210,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection ``` ** Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. -Attributes can be `key`, `fulltext`, and `unique`. ** +Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string attributes use an index. ** ### Parameters diff --git a/docs/documentsdb.md b/docs/documentsdb.md index 4f650b12..24756cc1 100644 --- a/docs/documentsdb.md +++ b/docs/documentsdb.md @@ -38,7 +38,7 @@ POST https://cloud.appwrite.io/v1/documentsdb GET https://cloud.appwrite.io/v1/documentsdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/examples/account/list-logs.md b/docs/examples/account/list-logs.md deleted file mode 100644 index 17e51352..00000000 --- a/docs/examples/account/list-logs.md +++ /dev/null @@ -1,18 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with - -$account = new Account($client); - -$result = $account->listLogs( - queries: [], // optional - total: false // optional -); -``` diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 59fbd663..a5eb5e99 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -18,8 +18,7 @@ $avatars = new Avatars($client); $result = $avatars->getScreenshot( url: 'https://example.com', headers: [ - 'Authorization' => 'Bearer token123', - 'X-Custom-Header' => 'value' + 'Accept-Language' => 'en-US,en;q=0.9' ], // optional viewportWidth: 1920, // optional viewportHeight: 1080, // optional diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index efd3083f..bcd3575f 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -20,7 +20,7 @@ $result = $databases->createDocument( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 30, 'isAdmin' => false ], diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 1f64387b..e858ed67 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -14,7 +14,16 @@ $databases = new Databases($client); $result = $databases->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/databases/create-enum-attribute.md b/docs/examples/databases/create-enum-attribute.md index 962b5a79..79d22785 100644 --- a/docs/examples/databases/create-enum-attribute.md +++ b/docs/examples/databases/create-enum-attribute.md @@ -15,7 +15,10 @@ $result = $databases->createEnumAttribute( databaseId: '', collectionId: '', key: '', - elements: ["active", "inactive"], + elements: [ + 'active', + 'inactive' + ], required: false, default: 'active', // optional array: false // optional diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 1005239e..43e6f00c 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -18,7 +18,9 @@ $result = $databases->createIndex( collectionId: '', key: '', type: DatabasesIndexType::KEY(), - attributes: [], + attributes: [ + 'username' + ], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index c892610a..218cb9aa 100644 --- a/docs/examples/databases/create-line-attribute.md +++ b/docs/examples/databases/create-line-attribute.md @@ -16,6 +16,19 @@ $result = $databases->createLineAttribute( collectionId: '', key: '', required: false, - default: [[1, 2], [3, 4], [5, 6]] // optional + default: [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ] // optional ); ``` diff --git a/docs/examples/databases/create-operations.md b/docs/examples/databases/create-operations.md index 82172a3f..f3b86d27 100644 --- a/docs/examples/databases/create-operations.md +++ b/docs/examples/databases/create-operations.md @@ -14,15 +14,15 @@ $databases = new Databases($client); $result = $databases->createOperations( transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + [ + 'action' => 'create', + 'databaseId' => '', + 'collectionId' => '', + 'documentId' => '', + 'data' => [ + 'name' => 'Walter O\'Brien' + ] + ] + ] // optional ); ``` diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md index 38541545..8512000a 100644 --- a/docs/examples/databases/create-point-attribute.md +++ b/docs/examples/databases/create-point-attribute.md @@ -16,6 +16,9 @@ $result = $databases->createPointAttribute( collectionId: '', key: '', required: false, - default: [1, 2] // optional + default: [ + 1, + 2 + ] // optional ); ``` diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md index 5a37c353..a2d99b17 100644 --- a/docs/examples/databases/create-polygon-attribute.md +++ b/docs/examples/databases/create-polygon-attribute.md @@ -16,6 +16,25 @@ $result = $databases->createPolygonAttribute( collectionId: '', key: '', required: false, - default: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional + default: [ + [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ] + ] // optional ); ``` diff --git a/docs/examples/databases/delete-documents.md b/docs/examples/databases/delete-documents.md index f39cbfe0..5e8a0f94 100644 --- a/docs/examples/databases/delete-documents.md +++ b/docs/examples/databases/delete-documents.md @@ -14,7 +14,9 @@ $databases = new Databases($client); $result = $databases->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}' + ], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 1f3b6359..9eecd2e6 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -20,7 +20,7 @@ $result = $databases->updateDocument( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 33, 'isAdmin' => false ], // optional diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 68c12217..aeaa43e2 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -17,7 +17,7 @@ $result = $databases->updateDocuments( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 33, 'isAdmin' => false ], // optional diff --git a/docs/examples/databases/update-enum-attribute.md b/docs/examples/databases/update-enum-attribute.md index 8a736beb..7b66ddf4 100644 --- a/docs/examples/databases/update-enum-attribute.md +++ b/docs/examples/databases/update-enum-attribute.md @@ -15,7 +15,10 @@ $result = $databases->updateEnumAttribute( databaseId: '', collectionId: '', key: '', - elements: ["active", "inactive"], + elements: [ + 'active', + 'inactive' + ], required: false, default: 'active', newKey: '' // optional diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md index a18dbb71..c8e30f7a 100644 --- a/docs/examples/databases/update-line-attribute.md +++ b/docs/examples/databases/update-line-attribute.md @@ -16,7 +16,20 @@ $result = $databases->updateLineAttribute( collectionId: '', key: '', required: false, - default: [[1, 2], [3, 4], [5, 6]], // optional + default: [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md index 54577171..febd27d9 100644 --- a/docs/examples/databases/update-point-attribute.md +++ b/docs/examples/databases/update-point-attribute.md @@ -16,7 +16,10 @@ $result = $databases->updatePointAttribute( collectionId: '', key: '', required: false, - default: [1, 2], // optional + default: [ + 1, + 2 + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md index 448b4ef9..2dd7dbe4 100644 --- a/docs/examples/databases/update-polygon-attribute.md +++ b/docs/examples/databases/update-polygon-attribute.md @@ -16,7 +16,26 @@ $result = $databases->updatePolygonAttribute( collectionId: '', key: '', required: false, - default: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional + default: [ + [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ] + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 94aad582..96da643f 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -20,7 +20,7 @@ $result = $databases->upsertDocument( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 30, 'isAdmin' => false ], // optional diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 0049fdc6..22bb46b0 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -14,7 +14,16 @@ $databases = new Databases($client); $result = $databases->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/create-document.md b/docs/examples/documentsdb/create-document.md index 4b894f41..66de5839 100644 --- a/docs/examples/documentsdb/create-document.md +++ b/docs/examples/documentsdb/create-document.md @@ -20,7 +20,7 @@ $result = $documentsDB->createDocument( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 30, 'isAdmin' => false ], diff --git a/docs/examples/documentsdb/create-documents.md b/docs/examples/documentsdb/create-documents.md index ec6a4355..76ba2d3d 100644 --- a/docs/examples/documentsdb/create-documents.md +++ b/docs/examples/documentsdb/create-documents.md @@ -14,7 +14,16 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/create-index.md b/docs/examples/documentsdb/create-index.md index b64d1f8a..a84d75cf 100644 --- a/docs/examples/documentsdb/create-index.md +++ b/docs/examples/documentsdb/create-index.md @@ -18,7 +18,9 @@ $result = $documentsDB->createIndex( collectionId: '', key: '', type: DocumentsDBIndexType::KEY(), - attributes: [], + attributes: [ + 'username' + ], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/documentsdb/create-operations.md b/docs/examples/documentsdb/create-operations.md index 83d3bab2..e4038701 100644 --- a/docs/examples/documentsdb/create-operations.md +++ b/docs/examples/documentsdb/create-operations.md @@ -14,15 +14,15 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->createOperations( transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + [ + 'action' => 'create', + 'databaseId' => '', + 'collectionId' => '', + 'documentId' => '', + 'data' => [ + 'name' => 'Walter O\'Brien' + ] + ] + ] // optional ); ``` diff --git a/docs/examples/documentsdb/delete-documents.md b/docs/examples/documentsdb/delete-documents.md index b77b3756..1932e627 100644 --- a/docs/examples/documentsdb/delete-documents.md +++ b/docs/examples/documentsdb/delete-documents.md @@ -14,7 +14,9 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}' + ], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/documentsdb/upsert-documents.md b/docs/examples/documentsdb/upsert-documents.md index 09021e0a..43dcf351 100644 --- a/docs/examples/documentsdb/upsert-documents.md +++ b/docs/examples/documentsdb/upsert-documents.md @@ -14,7 +14,16 @@ $documentsDB = new DocumentsDB($client); $result = $documentsDB->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md index 70f0f7e1..f1c289bf 100644 --- a/docs/examples/embeddings/create-text-embeddings.md +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -13,7 +13,10 @@ $client = (new Client()) $embeddings = new Embeddings($client); $result = $embeddings->createTextEmbeddings( - texts: [], + texts: [ + 'Appwrite helps developers build applications.', + 'Find documents with semantic search.' + ], model: EmbeddingModel::NOMICEMBEDTEXT() // optional ); ``` diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index 1f09b2fb..593af4a0 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -17,7 +17,9 @@ $result = $functions->create( functionId: '', name: '', runtime: Runtime::NODE145(), - execute: ["any"], // optional + execute: [ + 'any' + ], // optional events: [], // optional schedule: '0 0 * * *', // optional timeout: 1, // optional diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index d4863701..723692eb 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -17,7 +17,9 @@ $result = $functions->update( functionId: '', name: '', runtime: Runtime::NODE145(), // optional - execute: ["any"], // optional + execute: [ + 'any' + ], // optional events: [], // optional schedule: '0 0 * * *', // optional timeout: 1, // optional @@ -36,6 +38,7 @@ $result = $functions->update( buildSpecification: 's-1vcpu-512mb', // optional runtimeSpecification: 's-1vcpu-512mb', // optional deploymentRetention: 0, // optional - interval: 0 // optional + interval: 0, // optional + emailEnabled: false // optional ); ``` diff --git a/docs/examples/graphql/mutation.md b/docs/examples/graphql/mutation.md index c2f1b989..26792681 100644 --- a/docs/examples/graphql/mutation.md +++ b/docs/examples/graphql/mutation.md @@ -12,6 +12,8 @@ $client = (new Client()) $graphql = new Graphql($client); $result = $graphql->mutation( - query: [] + query: [ + 'query' => 'mutation { accountUpdateName(name: "Walter") { name } }' + ] ); ``` diff --git a/docs/examples/graphql/query.md b/docs/examples/graphql/query.md index 9731e998..f5e562c1 100644 --- a/docs/examples/graphql/query.md +++ b/docs/examples/graphql/query.md @@ -12,6 +12,8 @@ $client = (new Client()) $graphql = new Graphql($client); $result = $graphql->query( - query: [] + query: [ + 'query' => 'query { localeGet { ip } }' + ] ); ``` diff --git a/docs/examples/messaging/create-topic.md b/docs/examples/messaging/create-topic.md index ffb578bb..4fc8933d 100644 --- a/docs/examples/messaging/create-topic.md +++ b/docs/examples/messaging/create-topic.md @@ -14,7 +14,9 @@ $messaging = new Messaging($client); $result = $messaging->createTopic( topicId: '', name: '', - subscribe: ["any"], // optional + subscribe: [ + 'any' + ], // optional qos: 0, // optional expiry: 0 // optional ); diff --git a/docs/examples/messaging/create-twilio-provider.md b/docs/examples/messaging/create-twilio-provider.md index 568d28d9..4f96e8ac 100644 --- a/docs/examples/messaging/create-twilio-provider.md +++ b/docs/examples/messaging/create-twilio-provider.md @@ -14,7 +14,7 @@ $messaging = new Messaging($client); $result = $messaging->createTwilioProvider( providerId: '', name: '', - from: '+12065550100', // optional + from: '', // optional accountSid: '', // optional authToken: '', // optional enabled: false // optional diff --git a/docs/examples/messaging/update-topic.md b/docs/examples/messaging/update-topic.md index 6016049c..607785c3 100644 --- a/docs/examples/messaging/update-topic.md +++ b/docs/examples/messaging/update-topic.md @@ -14,7 +14,9 @@ $messaging = new Messaging($client); $result = $messaging->updateTopic( topicId: '', name: '', // optional - subscribe: ["any"], // optional + subscribe: [ + 'any' + ], // optional qos: 0, // optional expiry: 0 // optional ); diff --git a/docs/examples/mongo/create-restoration.md b/docs/examples/mongo/create-restoration.md index e16d2e31..ababb372 100644 --- a/docs/examples/mongo/create-restoration.md +++ b/docs/examples/mongo/create-restoration.md @@ -16,6 +16,9 @@ $result = $mongo->createRestoration( type: 'backup', // optional backupId: '', // optional targetDatabaseId: '', // optional - targetTime: '2020-10-15T06:38:00.000+00:00' // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '', // optional + autoPromote: false // optional ); ``` diff --git a/docs/examples/organization/delete-key.md b/docs/examples/mongo/promote-restoration.md similarity index 61% rename from docs/examples/organization/delete-key.md rename to docs/examples/mongo/promote-restoration.md index ca72f3dd..6532c647 100644 --- a/docs/examples/organization/delete-key.md +++ b/docs/examples/mongo/promote-restoration.md @@ -2,16 +2,17 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$organization = new Organization($client); +$mongo = new Mongo($client); -$result = $organization->deleteKey( - keyId: '' +$result = $mongo->promoteRestoration( + databaseId: '', + restorationId: '' ); ``` diff --git a/docs/examples/mysql/create-restoration.md b/docs/examples/mysql/create-restoration.md index b906838c..21c59a8b 100644 --- a/docs/examples/mysql/create-restoration.md +++ b/docs/examples/mysql/create-restoration.md @@ -16,6 +16,9 @@ $result = $mysql->createRestoration( type: 'backup', // optional backupId: '', // optional targetDatabaseId: '', // optional - targetTime: '2020-10-15T06:38:00.000+00:00' // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '', // optional + autoPromote: false // optional ); ``` diff --git a/docs/examples/organization/get-key.md b/docs/examples/mysql/promote-restoration.md similarity index 61% rename from docs/examples/organization/get-key.md rename to docs/examples/mysql/promote-restoration.md index bf651e9e..887ed4b9 100644 --- a/docs/examples/organization/get-key.md +++ b/docs/examples/mysql/promote-restoration.md @@ -2,16 +2,17 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$organization = new Organization($client); +$mysql = new Mysql($client); -$result = $organization->getKey( - keyId: '' +$result = $mysql->promoteRestoration( + databaseId: '', + restorationId: '' ); ``` diff --git a/docs/examples/oauth2/approve.md b/docs/examples/oauth2/approve.md index 5540b110..2a9f07aa 100644 --- a/docs/examples/oauth2/approve.md +++ b/docs/examples/oauth2/approve.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/authorize-post.md b/docs/examples/oauth2/authorize-post.md index d7a465ad..a99f3604 100644 --- a/docs/examples/oauth2/authorize-post.md +++ b/docs/examples/oauth2/authorize-post.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->authorizePost( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '' // optional ); diff --git a/docs/examples/oauth2/authorize.md b/docs/examples/oauth2/authorize.md index ad373715..3765b5a3 100644 --- a/docs/examples/oauth2/authorize.md +++ b/docs/examples/oauth2/authorize.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->authorize( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '', // optional requestUri: '' // optional ); diff --git a/docs/examples/oauth2/create-device-authorization.md b/docs/examples/oauth2/create-device-authorization.md index 00358d8a..6385a1a1 100644 --- a/docs/examples/oauth2/create-device-authorization.md +++ b/docs/examples/oauth2/create-device-authorization.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -15,7 +15,7 @@ $result = $oauth2->createDeviceAuthorization( clientId: '', // optional scope: '', // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/create-grant.md b/docs/examples/oauth2/create-grant.md index 95467652..a0328e69 100644 --- a/docs/examples/oauth2/create-grant.md +++ b/docs/examples/oauth2/create-grant.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/create-par.md b/docs/examples/oauth2/create-par.md index ddb3d7d6..9c57b1df 100644 --- a/docs/examples/oauth2/create-par.md +++ b/docs/examples/oauth2/create-par.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -23,7 +23,7 @@ $result = $oauth2->createPAR( prompt: '', // optional maxAge: 0, // optional authorizationDetails: '', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/create-token.md b/docs/examples/oauth2/create-token.md index a4be2d6f..8ec9d22f 100644 --- a/docs/examples/oauth2/create-token.md +++ b/docs/examples/oauth2/create-token.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); @@ -20,7 +20,7 @@ $result = $oauth2->createToken( clientSecret: '', // optional codeVerifier: '', // optional redirectUri: 'https://example.com', // optional - resource: '', // optional + resource: [], // optional audience: '' // optional ); ``` diff --git a/docs/examples/oauth2/get-grant.md b/docs/examples/oauth2/get-grant.md index a6469c30..d83efe8f 100644 --- a/docs/examples/oauth2/get-grant.md +++ b/docs/examples/oauth2/get-grant.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/list-organizations.md b/docs/examples/oauth2/list-organizations.md index 49c1f499..7237c3f8 100644 --- a/docs/examples/oauth2/list-organizations.md +++ b/docs/examples/oauth2/list-organizations.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/list-projects.md b/docs/examples/oauth2/list-projects.md index 3bbcf901..9abc1548 100644 --- a/docs/examples/oauth2/list-projects.md +++ b/docs/examples/oauth2/list-projects.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/reject.md b/docs/examples/oauth2/reject.md index bd98d721..0cc9cf7f 100644 --- a/docs/examples/oauth2/reject.md +++ b/docs/examples/oauth2/reject.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/oauth2/revoke.md b/docs/examples/oauth2/revoke.md index 7122ed7f..1e823003 100644 --- a/docs/examples/oauth2/revoke.md +++ b/docs/examples/oauth2/revoke.md @@ -6,8 +6,8 @@ use Appwrite\Services\Oauth2; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setProject(''); // Your project ID + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $oauth2 = new Oauth2($client); diff --git a/docs/examples/organization/create-key.md b/docs/examples/organization/create-key.md deleted file mode 100644 index c7cb7dde..00000000 --- a/docs/examples/organization/create-key.md +++ /dev/null @@ -1,21 +0,0 @@ -```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->createKey( - keyId: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTSREAD()], - expire: '2020-10-15T06:38:00.000+00:00' // optional -); -``` diff --git a/docs/examples/organization/update-key.md b/docs/examples/organization/update-key.md deleted file mode 100644 index 575e6119..00000000 --- a/docs/examples/organization/update-key.md +++ /dev/null @@ -1,21 +0,0 @@ -```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->updateKey( - keyId: '', - name: '', - scopes: [OrganizationKeyScopes::PROJECTSREAD()], - expire: '2020-10-15T06:38:00.000+00:00' // optional -); -``` diff --git a/docs/examples/postgresql/create-restoration.md b/docs/examples/postgresql/create-restoration.md index f94c6972..d5de4e01 100644 --- a/docs/examples/postgresql/create-restoration.md +++ b/docs/examples/postgresql/create-restoration.md @@ -16,6 +16,9 @@ $result = $postgresql->createRestoration( type: 'backup', // optional backupId: '', // optional targetDatabaseId: '', // optional - targetTime: '2020-10-15T06:38:00.000+00:00' // optional + targetTime: '2020-10-15T06:38:00.000+00:00', // optional + restoreMode: 'in_place', // optional + targetName: '', // optional + autoPromote: false // optional ); ``` diff --git a/docs/examples/users/list-logs.md b/docs/examples/postgresql/promote-restoration.md similarity index 58% rename from docs/examples/users/list-logs.md rename to docs/examples/postgresql/promote-restoration.md index b050bab0..dc1fc49d 100644 --- a/docs/examples/users/list-logs.md +++ b/docs/examples/postgresql/promote-restoration.md @@ -2,18 +2,17 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$users = new Users($client); +$postgresql = new Postgresql($client); -$result = $users->listLogs( - userId: '', - queries: [], // optional - total: false // optional +$result = $postgresql->promoteRestoration( + databaseId: '', + restorationId: '' ); ``` diff --git a/docs/examples/project/create-ephemeral-key.md b/docs/examples/project/create-ephemeral-key.md index 224dc841..763800e6 100644 --- a/docs/examples/project/create-ephemeral-key.md +++ b/docs/examples/project/create-ephemeral-key.md @@ -13,7 +13,7 @@ $client = (new Client()) $project = new Project($client); $result = $project->createEphemeralKey( - scopes: [ProjectKeyScopes::PROJECTREAD()], + scopes: [ProjectKeyScopes::USERSREAD()], duration: 600 ); ``` diff --git a/docs/examples/project/create-smtp-test.md b/docs/examples/project/create-smtp-test.md index a16026a8..be2a588b 100644 --- a/docs/examples/project/create-smtp-test.md +++ b/docs/examples/project/create-smtp-test.md @@ -12,6 +12,8 @@ $client = (new Client()) $project = new Project($client); $result = $project->createSMTPTest( - emails: [] + emails: [ + 'recipient@example.com' + ] ); ``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md index db883945..ae2996b7 100644 --- a/docs/examples/project/update-key.md +++ b/docs/examples/project/update-key.md @@ -15,7 +15,7 @@ $project = new Project($client); $result = $project->updateKey( keyId: '', name: '', - scopes: [ProjectKeyScopes::PROJECTREAD()], + scopes: [ProjectKeyScopes::USERSREAD()], expire: '2020-10-15T06:38:00.000+00:00' // optional ); ``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md index aace3165..e94b8406 100644 --- a/docs/examples/project/update-labels.md +++ b/docs/examples/project/update-labels.md @@ -12,6 +12,8 @@ $client = (new Client()) $project = new Project($client); $result = $project->updateLabels( - labels: [] + labels: [ + 'production' + ] ); ``` diff --git a/docs/examples/project/update-o-auth-2-kakao.md b/docs/examples/project/update-o-auth-2-kakao.md index 78fe1cbd..7f88288e 100644 --- a/docs/examples/project/update-o-auth-2-kakao.md +++ b/docs/examples/project/update-o-auth-2-kakao.md @@ -15,7 +15,7 @@ $project = new Project($client); $result = $project->updateOAuth2Kakao( clientId: '', // optional clientSecret: '', // optional - prompt: [ProjectOAuth2KakaoPrompt::NONE()], // optional - enabled: false // optional + enabled: false, // optional + prompt: [ProjectOAuth2KakaoPrompt::NONE()] // optional ); ``` diff --git a/docs/examples/organization/list-keys.md b/docs/examples/proxy/create-smtp-rule.md similarity index 58% rename from docs/examples/organization/list-keys.md rename to docs/examples/proxy/create-smtp-rule.md index dbe27502..ecffbf19 100644 --- a/docs/examples/organization/list-keys.md +++ b/docs/examples/proxy/create-smtp-rule.md @@ -2,17 +2,18 @@ setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID ->setKey(''); // Your secret API key -$organization = new Organization($client); +$proxy = new Proxy($client); -$result = $organization->listKeys( - queries: [], // optional - total: false // optional +$result = $proxy->createSMTPRule( + domain: 'example.com', + functionId: '', + branch: '' // optional ); ``` diff --git a/docs/examples/tablesdb/create-enum-column.md b/docs/examples/tablesdb/create-enum-column.md index c9e3f5fb..ba0f5ec0 100644 --- a/docs/examples/tablesdb/create-enum-column.md +++ b/docs/examples/tablesdb/create-enum-column.md @@ -15,7 +15,10 @@ $result = $tablesDB->createEnumColumn( databaseId: '', tableId: '', key: '', - elements: ["active", "inactive"], + elements: [ + 'active', + 'inactive' + ], required: false, default: 'active', // optional array: false // optional diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 2b840eb3..29327378 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -18,7 +18,9 @@ $result = $tablesDB->createIndex( tableId: '', key: '', type: TablesDBIndexType::KEY(), - columns: [], + columns: [ + 'username' + ], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md index 4d220468..d3ed71e8 100644 --- a/docs/examples/tablesdb/create-line-column.md +++ b/docs/examples/tablesdb/create-line-column.md @@ -16,6 +16,19 @@ $result = $tablesDB->createLineColumn( tableId: '', key: '', required: false, - default: [[1, 2], [3, 4], [5, 6]] // optional + default: [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ] // optional ); ``` diff --git a/docs/examples/tablesdb/create-operations.md b/docs/examples/tablesdb/create-operations.md index e60cf34e..f18a6c45 100644 --- a/docs/examples/tablesdb/create-operations.md +++ b/docs/examples/tablesdb/create-operations.md @@ -14,15 +14,15 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->createOperations( transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "tableId": "", - "rowId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + [ + 'action' => 'create', + 'databaseId' => '', + 'tableId' => '', + 'rowId' => '', + 'data' => [ + 'name' => 'Walter O\'Brien' + ] + ] + ] // optional ); ``` diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md index 76079b21..47deb73b 100644 --- a/docs/examples/tablesdb/create-point-column.md +++ b/docs/examples/tablesdb/create-point-column.md @@ -16,6 +16,9 @@ $result = $tablesDB->createPointColumn( tableId: '', key: '', required: false, - default: [1, 2] // optional + default: [ + 1, + 2 + ] // optional ); ``` diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md index 7018c1e1..66baac48 100644 --- a/docs/examples/tablesdb/create-polygon-column.md +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -16,6 +16,25 @@ $result = $tablesDB->createPolygonColumn( tableId: '', key: '', required: false, - default: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // optional + default: [ + [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ] + ] // optional ); ``` diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 1af62007..9f39591e 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -20,7 +20,7 @@ $result = $tablesDB->createRow( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 30, 'isAdmin' => false ], diff --git a/docs/examples/tablesdb/create-rows.md b/docs/examples/tablesdb/create-rows.md index 6ae0f802..da4c43e6 100644 --- a/docs/examples/tablesdb/create-rows.md +++ b/docs/examples/tablesdb/create-rows.md @@ -14,7 +14,16 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->createRows( databaseId: '', tableId: '', - rows: [], + rows: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/tablesdb/delete-rows.md b/docs/examples/tablesdb/delete-rows.md index 2b13b6c7..a8149898 100644 --- a/docs/examples/tablesdb/delete-rows.md +++ b/docs/examples/tablesdb/delete-rows.md @@ -14,7 +14,9 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->deleteRows( databaseId: '', tableId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}' + ], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/tablesdb/update-enum-column.md b/docs/examples/tablesdb/update-enum-column.md index 9d657ba6..fc3bff58 100644 --- a/docs/examples/tablesdb/update-enum-column.md +++ b/docs/examples/tablesdb/update-enum-column.md @@ -15,7 +15,10 @@ $result = $tablesDB->updateEnumColumn( databaseId: '', tableId: '', key: '', - elements: ["active", "inactive"], + elements: [ + 'active', + 'inactive' + ], required: false, default: 'active', newKey: '' // optional diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md index 58257151..55665a78 100644 --- a/docs/examples/tablesdb/update-line-column.md +++ b/docs/examples/tablesdb/update-line-column.md @@ -16,7 +16,20 @@ $result = $tablesDB->updateLineColumn( tableId: '', key: '', required: false, - default: [[1, 2], [3, 4], [5, 6]], // optional + default: [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md index 3b55a7ab..a76649a7 100644 --- a/docs/examples/tablesdb/update-point-column.md +++ b/docs/examples/tablesdb/update-point-column.md @@ -16,7 +16,10 @@ $result = $tablesDB->updatePointColumn( tableId: '', key: '', required: false, - default: [1, 2], // optional + default: [ + 1, + 2 + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md index 05be2de0..86d67b81 100644 --- a/docs/examples/tablesdb/update-polygon-column.md +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -16,7 +16,26 @@ $result = $tablesDB->updatePolygonColumn( tableId: '', key: '', required: false, - default: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional + default: [ + [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ] + ], // optional newKey: '' // optional ); ``` diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index 197179e8..bce35dea 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -20,7 +20,7 @@ $result = $tablesDB->updateRow( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 33, 'isAdmin' => false ], // optional diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 5e9dd0aa..aa59212c 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -17,7 +17,7 @@ $result = $tablesDB->updateRows( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 33, 'isAdmin' => false ], // optional diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 37786239..1127cb9b 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -20,7 +20,7 @@ $result = $tablesDB->upsertRow( data: [ 'username' => 'walter.obrien', 'email' => 'walter.obrien@example.com', - 'fullName' => 'Walter O'Brien', + 'fullName' => 'Walter O\'Brien', 'age' => 33, 'isAdmin' => false ], // optional diff --git a/docs/examples/tablesdb/upsert-rows.md b/docs/examples/tablesdb/upsert-rows.md index 56aa2657..8d920bd5 100644 --- a/docs/examples/tablesdb/upsert-rows.md +++ b/docs/examples/tablesdb/upsert-rows.md @@ -14,7 +14,16 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->upsertRows( databaseId: '', tableId: '', - rows: [], + rows: [ + [ + '$id' => 'example1', + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O\'Brien', + 'age' => 30, + 'isAdmin' => false + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index cd9524a7..9470ad59 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -13,7 +13,9 @@ $teams = new Teams($client); $result = $teams->createMembership( teamId: '', - roles: [], + roles: [ + 'editor' + ], email: 'email@example.com', // optional userId: '', // optional phone: '+12065550100', // optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 87741774..15391122 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -14,6 +14,8 @@ $teams = new Teams($client); $result = $teams->updateMembership( teamId: '', membershipId: '', - roles: [] + roles: [ + 'editor' + ] ); ``` diff --git a/docs/examples/users/update-labels.md b/docs/examples/users/update-labels.md index 7ac457f5..7b6cc3b3 100644 --- a/docs/examples/users/update-labels.md +++ b/docs/examples/users/update-labels.md @@ -13,6 +13,8 @@ $users = new Users($client); $result = $users->updateLabels( userId: '', - labels: [] + labels: [ + 'subscriber' + ] ); ``` diff --git a/docs/examples/vectorsdb/create-collection.md b/docs/examples/vectorsdb/create-collection.md index c3ed6628..3bbdb076 100644 --- a/docs/examples/vectorsdb/create-collection.md +++ b/docs/examples/vectorsdb/create-collection.md @@ -17,7 +17,7 @@ $result = $vectorsDB->createCollection( databaseId: '', collectionId: '', name: '', - dimension: 1, + dimension: 4, permissions: [Permission::read(Role::any())], // optional documentSecurity: false, // optional enabled: false // optional diff --git a/docs/examples/vectorsdb/create-document.md b/docs/examples/vectorsdb/create-document.md index b97f81e4..f72c5fda 100644 --- a/docs/examples/vectorsdb/create-document.md +++ b/docs/examples/vectorsdb/create-document.md @@ -19,10 +19,10 @@ $result = $vectorsDB->createDocument( documentId: '', data: [ 'embeddings' => [ - '0' => 0.12, - '1' => -0.55, - '2' => 0.88, - '3' => 1.02 + 0.12, + -0.55, + 0.88, + 1.02 ], 'metadata' => [ 'key' => 'value' diff --git a/docs/examples/vectorsdb/create-documents.md b/docs/examples/vectorsdb/create-documents.md index 2d1c9c2f..0a7123ca 100644 --- a/docs/examples/vectorsdb/create-documents.md +++ b/docs/examples/vectorsdb/create-documents.md @@ -14,7 +14,20 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->createDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'embeddings' => [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + 'metadata' => [ + 'name' => 'First document' + ] + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/vectorsdb/create-index.md b/docs/examples/vectorsdb/create-index.md index d3e699cb..4883ccb8 100644 --- a/docs/examples/vectorsdb/create-index.md +++ b/docs/examples/vectorsdb/create-index.md @@ -18,7 +18,9 @@ $result = $vectorsDB->createIndex( collectionId: '', key: '', type: VectorsDBIndexType::HNSWEUCLIDEAN(), - attributes: [], + attributes: [ + 'embeddings' + ], orders: [OrderBy::ASC()], // optional lengths: [] // optional ); diff --git a/docs/examples/vectorsdb/create-operations.md b/docs/examples/vectorsdb/create-operations.md index c311d5e4..dac52647 100644 --- a/docs/examples/vectorsdb/create-operations.md +++ b/docs/examples/vectorsdb/create-operations.md @@ -14,15 +14,23 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->createOperations( transactionId: '', operations: [ - { - "action": "create", - "databaseId": "", - "collectionId": "", - "documentId": "", - "data": { - "name": "Walter O'Brien" - } - } - ] // optional + [ + 'action' => 'create', + 'databaseId' => '', + 'collectionId' => '', + 'documentId' => '', + 'data' => [ + 'embeddings' => [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + 'metadata' => [ + 'name' => 'First document' + ] + ] + ] + ] // optional ); ``` diff --git a/docs/examples/vectorsdb/delete-documents.md b/docs/examples/vectorsdb/delete-documents.md index 17b0831d..77811f17 100644 --- a/docs/examples/vectorsdb/delete-documents.md +++ b/docs/examples/vectorsdb/delete-documents.md @@ -14,7 +14,9 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->deleteDocuments( databaseId: '', collectionId: '', - queries: [], // optional + queries: [ + '{"method":"equal", "attribute":"$id", "values":[""]}' + ], // optional transactionId: '' // optional ); ``` diff --git a/docs/examples/vectorsdb/update-collection.md b/docs/examples/vectorsdb/update-collection.md index 7898ee03..d9815b61 100644 --- a/docs/examples/vectorsdb/update-collection.md +++ b/docs/examples/vectorsdb/update-collection.md @@ -17,7 +17,7 @@ $result = $vectorsDB->updateCollection( databaseId: '', collectionId: '', name: '', - dimension: 1, // optional + dimension: 4, // optional permissions: [Permission::read(Role::any())], // optional documentSecurity: false, // optional enabled: false // optional diff --git a/docs/examples/vectorsdb/upsert-documents.md b/docs/examples/vectorsdb/upsert-documents.md index 11e5d31f..7d89dcdb 100644 --- a/docs/examples/vectorsdb/upsert-documents.md +++ b/docs/examples/vectorsdb/upsert-documents.md @@ -14,7 +14,20 @@ $vectorsDB = new VectorsDB($client); $result = $vectorsDB->upsertDocuments( databaseId: '', collectionId: '', - documents: [], + documents: [ + [ + '$id' => 'example1', + 'embeddings' => [ + 0.12, + -0.55, + 0.88, + 1.02 + ], + 'metadata' => [ + 'name' => 'First document' + ] + ] + ], transactionId: '' // optional ); ``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 2b437a54..1e0ae9f9 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -15,7 +15,9 @@ $result = $webhooks->create( webhookId: '', url: 'https://example.com/webhook', name: '', - events: [], + events: [ + 'users.*.create' + ], enabled: false, // optional tls: false, // optional authUsername: '', // optional diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 95dafcf0..104a58b1 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -15,7 +15,9 @@ $result = $webhooks->update( webhookId: '', name: '', url: 'https://example.com/webhook', - events: [], + events: [ + 'users.*.create' + ], enabled: false, // optional tls: false, // optional authUsername: '', // optional diff --git a/docs/functions.md b/docs/functions.md index 9d6f555c..5cddf805 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -124,6 +124,7 @@ PUT https://cloud.appwrite.io/v1/functions/{functionId} | 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 | | interval | integer | Minutes between scheduled executions. Appwrite picks when within each interval the function runs. Use 0 to disable. Cannot be combined with schedule. When omitted, the current interval is kept unless schedule is set. | | +| emailEnabled | boolean | Enable inbound email triggering for this function. When false or omitted on create, SMTP recipients are rejected. Opt-in; default is off. | | ```http request diff --git a/docs/messaging.md b/docs/messaging.md index e2d897da..5dbed35d 100644 --- a/docs/messaging.md +++ b/docs/messaging.md @@ -11,7 +11,7 @@ GET https://cloud.appwrite.io/v1/messaging/messages | 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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType | [] | +| 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: scheduledAt, deliveredAt, deliveredTotal, status, description, providerType, users, targets | [] | | 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 | @@ -363,7 +363,7 @@ POST https://cloud.appwrite.io/v1/messaging/providers/appwrite | name | string | Provider name. | | | enabled | boolean | Set as enabled. | | | qos | integer | Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. | | -| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. | | ```http request @@ -380,7 +380,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/providers/appwrite/{providerId} | name | string | Provider name. | | | enabled | boolean | Set as enabled. | | | qos | integer | Default QoS for topics on this provider (0 or 1). Null lets the subscriber choose. | | -| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Default message retention in seconds for offline delivery. Max 7 days (604800). Applies to topics with a null expiry; the lowest across enabled Appwrite providers wins. | | ```http request @@ -839,7 +839,7 @@ POST https://cloud.appwrite.io/v1/messaging/providers/twilio | --- | --- | --- | --- | | providerId | string | Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | | name | string | Provider name. | | -| from | string | Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | +| from | string | Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. | | | accountSid | string | Twilio account secret ID. | | | authToken | string | Twilio authentication token. | | | enabled | boolean | Set as enabled. | | @@ -860,7 +860,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/providers/twilio/{providerId} | enabled | boolean | Set as enabled. | | | accountSid | string | Twilio account secret ID. | | | authToken | string | Twilio authentication token. | | -| from | string | Sender number. | | +| from | string | Sender phone number or alphanumeric sender ID. Format phone numbers with a leading '+' and a country code, e.g., +16175551212. | | ```http request @@ -955,7 +955,7 @@ POST https://cloud.appwrite.io/v1/messaging/topics | name | string | Topic Name. | | | subscribe | array | An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | ["users"] | | qos | integer | MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. | | -| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. | | ```http request @@ -987,7 +987,7 @@ PATCH https://cloud.appwrite.io/v1/messaging/topics/{topicId} | name | string | Topic Name. | | | subscribe | array | An array of role strings with subscribe permission. By default all users are granted with any subscribe permission. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long. | | | qos | integer | MQTT delivery quality of service for this topic. 0 is fire-and-forget (delivered only to clients connected at publish time). 1 persists each message and replays it when a client reconnects without having acknowledged it. Null lets the subscriber choose. | | -| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). | | +| expiry | integer | Message retention in seconds for offline delivery. Max 7 days (604800). Null inherits the lowest expiry of the project's enabled Appwrite providers, or the 7-day ledger window if none sets one. | | ```http request diff --git a/docs/mongo.md b/docs/mongo.md index 084c9fca..1eaebc24 100644 --- a/docs/mongo.md +++ b/docs/mongo.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/mongo | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/mongo/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request @@ -423,7 +423,9 @@ GET https://cloud.appwrite.io/v1/mongo/{databaseId}/restorations POST https://cloud.appwrite.io/v1/mongo/{databaseId}/restorations ``` -** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. ** +** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. ** ### Parameters @@ -432,8 +434,11 @@ POST https://cloud.appwrite.io/v1/mongo/{databaseId}/restorations | databaseId | string | **Required** Database ID. | | | type | string | Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. | backup | | backupId | string | Backup ID to restore from (required for backup type). | | -| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. | | +| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. | | | targetTime | string | Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. | | +| restoreMode | string | Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. | | +| targetName | string | Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. | | +| autoPromote | boolean | Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. | 1 | ```http request @@ -450,6 +455,23 @@ GET https://cloud.appwrite.io/v1/mongo/{databaseId}/restorations/{restorationId} | restorationId | string | **Required** Restoration ID. | | +```http request +POST https://cloud.appwrite.io/v1/mongo/{databaseId}/restorations/{restorationId}/promotions +``` + +** Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| restorationId | string | **Required** Restoration ID. | | + + ```http request GET https://cloud.appwrite.io/v1/mongo/{databaseId}/status ``` diff --git a/docs/mysql.md b/docs/mysql.md index ced7ecea..e4444440 100644 --- a/docs/mysql.md +++ b/docs/mysql.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/mysql | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/mysql/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request @@ -320,7 +320,7 @@ PATCH https://cloud.appwrite.io/v1/mysql/{databaseId}/credentials POST https://cloud.appwrite.io/v1/mysql/{databaseId}/executions ``` -** Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. ** +** Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. ** ### Parameters @@ -329,7 +329,7 @@ POST https://cloud.appwrite.io/v1/mysql/{databaseId}/executions | databaseId | string | **Required** Database ID. | | | sql | string | SQL statement to execute. Exactly one statement per request. | | | bindings | object | Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. | {} | -| timeoutSeconds | integer | Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. | | +| timeoutSeconds | integer | Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. | | ```http request @@ -432,7 +432,7 @@ PATCH https://cloud.appwrite.io/v1/mysql/{databaseId}/pooler | mode | string | Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. | | | maxConnections | integer | Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. | | | defaultPoolSize | integer | Default pool size per user. | | -| readWriteSplitting | boolean | Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. | | +| readWriteSplitting | boolean | Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. | | | poolerCpuRequest | string | Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). | | | poolerCpuLimit | string | Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. | | | poolerMemoryRequest | string | Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). | | @@ -473,7 +473,9 @@ GET https://cloud.appwrite.io/v1/mysql/{databaseId}/restorations POST https://cloud.appwrite.io/v1/mysql/{databaseId}/restorations ``` -** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. ** +** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. ** ### Parameters @@ -482,8 +484,11 @@ POST https://cloud.appwrite.io/v1/mysql/{databaseId}/restorations | databaseId | string | **Required** Database ID. | | | type | string | Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. | backup | | backupId | string | Backup ID to restore from (required for backup type). | | -| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. | | +| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. | | | targetTime | string | Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. | | +| restoreMode | string | Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. | | +| targetName | string | Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. | | +| autoPromote | boolean | Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. | 1 | ```http request @@ -500,6 +505,23 @@ GET https://cloud.appwrite.io/v1/mysql/{databaseId}/restorations/{restorationId} | restorationId | string | **Required** Restoration ID. | | +```http request +POST https://cloud.appwrite.io/v1/mysql/{databaseId}/restorations/{restorationId}/promotions +``` + +** Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| restorationId | string | **Required** Restoration ID. | | + + ```http request GET https://cloud.appwrite.io/v1/mysql/{databaseId}/status ``` diff --git a/docs/oauth2.md b/docs/oauth2.md index 46c3bc67..e9928cbf 100644 --- a/docs/oauth2.md +++ b/docs/oauth2.md @@ -39,7 +39,7 @@ GET https://cloud.appwrite.io/v1/oauth2/{project_id}/authorize | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | | request_uri | string | OAuth2 authorization request handle returned by the pushed authorization request endpoint. | | @@ -66,7 +66,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/authorize | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age paraleter for customization of consent screen. Maximum allowable elapsed time in seconds since the user last authenticated. If exceeded, re-authentication is required. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | | request_uri | string | OAuth2 authorization request handle returned by the pushed authorization request endpoint. | | @@ -85,7 +85,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/device_authorization | client_id | string | OAuth2 client ID. Either a registered app ID or an HTTPS client ID metadata document URL. | | | scope | string | Space-separated OAuth2 scopes. Can include project scopes, and built-in scopes: `openid`, `email`, `profile`. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | @@ -172,7 +172,7 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/par | prompt | string | OIDC prompt parameter for customization of consent screen. Space-separated list of: none, login, consent, select_account. | | | max_age | integer | OIDC max_age parameter for customization of consent screen. | | | authorization_details | string | Rich authorization request. JSON array of objects, each with a `type` and project-defined fields | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | @@ -242,6 +242,6 @@ POST https://cloud.appwrite.io/v1/oauth2/{project_id}/token | client_secret | string | OAuth2 client secret. Required for confidential apps. | | | code_verifier | string | PKCE code verifier. Required for public apps. | | | redirect_uri | string | Redirect URI. Required for `authorization_code` grant type. | | -| resource | string | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | +| resource | array | RFC 8707 resource indicator URI or URI list. Each value must be an absolute URI without a fragment. | [] | | audience | string | Compatibility alias for a single OAuth2 resource indicator URI. | | diff --git a/docs/organization.md b/docs/organization.md index dc3895c1..350a7d14 100644 --- a/docs/organization.md +++ b/docs/organization.md @@ -96,78 +96,6 @@ DELETE https://cloud.appwrite.io/v1/organization/installations/{installationId} | installationId | string | **Required** Installation unique ID. | | -```http request -GET https://cloud.appwrite.io/v1/organization/keys -``` - -** Get a list of all API keys 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: expire, accessedAt, name, scopes | [] | -| 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/keys -``` - -** Create a new organization API key. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| 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 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. | | - - -```http request -GET https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including its scopes. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | - - -```http request -PUT https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | -| name | string | Key name. Max length: 128 chars. | | -| 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. | | - - -```http request -DELETE https://cloud.appwrite.io/v1/organization/keys/{keyId} -``` - -** Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| keyId | string | **Required** Key unique ID. | | - - ```http request GET https://cloud.appwrite.io/v1/organization/memberships ``` @@ -268,7 +196,7 @@ POST https://cloud.appwrite.io/v1/organization/projects | --- | --- | --- | --- | | projectId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars. | | | name | string | Project name. Max length: 128 chars. | | -| region | string | Project Region. | default | +| region | string | Project Region. | | ```http request diff --git a/docs/postgresql.md b/docs/postgresql.md index d1af41f3..90c8ceb0 100644 --- a/docs/postgresql.md +++ b/docs/postgresql.md @@ -35,16 +35,16 @@ POST https://cloud.appwrite.io/v1/postgresql | idleTimeoutMinutes | integer | Minutes of inactivity before container scales to zero. | 15 | | pitr | boolean | Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window. | 1 | | pitrRetentionDays | integer | Number of days to retain PITR data. | 7 | -| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | | +| storageAutoscaling | boolean | Enable automatic storage expansion when usage exceeds threshold. | 1 | | storageAutoscalingThresholdPercent | integer | Storage usage percentage (50-95) that triggers automatic expansion. | 85 | -| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. 0 means no limit. | 0 | +| storageAutoscalingMaxGb | integer | Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit. | | ```http request GET https://cloud.appwrite.io/v1/postgresql/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request @@ -320,7 +320,7 @@ PATCH https://cloud.appwrite.io/v1/postgresql/{databaseId}/credentials POST https://cloud.appwrite.io/v1/postgresql/{databaseId}/executions ``` -** Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. ** +** Execute SQL through the console-facing Cloud endpoint. Cloud proxies through the edge platform to the per-database SQL API sidecar. Application traffic should bypass cloud entirely and POST directly to the per-database hostname: `https://db-{project}-{db}.{region}.appwrite.center/v1/sql/executions` with an `X-Appwrite-Key` header — that path scales to the whole DB fleet without a per-query cloud round-trip. The statement type must be on the database's configured allow-list. Use bound parameters for any user-supplied values — the API does not interpolate raw strings. Long-running statements (for example CREATE INDEX) can outlive the HTTP request: if the request ends before a result is returned, check the database before retrying, and prefer a direct connection for work that may take minutes. ** ### Parameters @@ -329,7 +329,7 @@ POST https://cloud.appwrite.io/v1/postgresql/{databaseId}/executions | databaseId | string | **Required** Database ID. | | | sql | string | SQL statement to execute. Exactly one statement per request. | | | bindings | object | Optional bound parameters. Pass either a positional list or a name => value map matching the placeholder style used in the SQL. | {} | -| timeoutSeconds | integer | Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. | | +| timeoutSeconds | integer | Per-call execution timeout override. Must be less than or equal to the database's configured sqlApiTimeoutSeconds. Statements that may exceed this — or the HTTP request timeout in front of Cloud — should use a direct connection instead. | | ```http request @@ -473,7 +473,7 @@ PATCH https://cloud.appwrite.io/v1/postgresql/{databaseId}/pooler | mode | string | Connection pool mode. Allowed values: transaction, session. Transaction mode returns connections to the pool after each transaction; session mode holds connections for the entire session lifetime. | | | maxConnections | integer | Client-connection ceiling the pooler accepts. Supported on MySQL and MariaDB only; the PostgreSQL pooler has no client cap, so set networkMaxConnections on the database instead. | | | defaultPoolSize | integer | Default pool size per user. | | -| readWriteSplitting | boolean | Route SELECTs to HA replicas, writes and locked reads to the primary. Defaults to true when HA is enabled. | | +| readWriteSplitting | boolean | Route SELECTs to HA replicas, writes and locked reads to the primary. Off by default, and only takes effect while HA is enabled. Replication is asynchronous, so a read issued immediately after a write may not observe it. | | | poolerCpuRequest | string | Pooler sidecar CPU request override (Kubernetes quantity, e.g. "250m" or "1"). Leave null for the proportional default (5% of DB CPU, floor 100m). | | | poolerCpuLimit | string | Pooler sidecar CPU limit override (Kubernetes quantity, e.g. "500m" or "1"). Leave null for the proportional default (10% of DB CPU, floor 200m). Changing this field rolls the database pod. | | | poolerMemoryRequest | string | Pooler sidecar memory request override (Kubernetes quantity, e.g. "128Mi" or "1Gi"). Leave null for the proportional default (7.5% of DB memory, floor 64Mi). | | @@ -514,7 +514,9 @@ GET https://cloud.appwrite.io/v1/postgresql/{databaseId}/restorations POST https://cloud.appwrite.io/v1/postgresql/{databaseId}/restorations ``` -** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. ** +** Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases. + +By default the backup is replayed over the database it was taken from. Pass `restoreMode` as `clone` to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass `autoPromote` as false to hold the clone until you promote it yourself. Pass `restoreMode` as `copy` to recover onto a separate database with its own endpoint, either one you name with `targetDatabaseId` or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup. ** ### Parameters @@ -523,8 +525,11 @@ POST https://cloud.appwrite.io/v1/postgresql/{databaseId}/restorations | databaseId | string | **Required** Database ID. | | | type | string | Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery. | backup | | backupId | string | Backup ID to restore from (required for backup type). | | -| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. | | +| targetDatabaseId | string | Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database. | | | targetTime | string | Target time for PITR (required for pitr type) as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) datetime. | | +| restoreMode | string | Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise. | | +| targetName | string | Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars. | | +| autoPromote | boolean | Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself. | 1 | ```http request @@ -541,6 +546,23 @@ GET https://cloud.appwrite.io/v1/postgresql/{databaseId}/restorations/{restorati | restorationId | string | **Required** Restoration ID. | | +```http request +POST https://cloud.appwrite.io/v1/postgresql/{databaseId}/restorations/{restorationId}/promotions +``` + +** Switch the database over to the clone a restoration recovered. The database keeps +its endpoint and credentials; clients reconnect once. Writes made after the +recovery point are discarded, and the side being replaced is retained briefly so +the switch can be reversed. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| restorationId | string | **Required** Restoration ID. | | + + ```http request GET https://cloud.appwrite.io/v1/postgresql/{databaseId}/status ``` diff --git a/docs/project.md b/docs/project.md index add475e8..df5337f8 100644 --- a/docs/project.md +++ b/docs/project.md @@ -25,7 +25,7 @@ PATCH https://cloud.appwrite.io/v1/project/auth-methods/{methodId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| methodId | string | **Required** Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone | | +| methodId | string | **Required** Auth Method ID. Possible values: email-password,magic-url,email-otp,anonymous,invites,jwt,phone,passkey | | | enabled | boolean | Auth method status. | | @@ -648,8 +648,8 @@ PATCH https://cloud.appwrite.io/v1/project/oauth2/kakao | --- | --- | --- | --- | | clientId | string | 'REST API key' of Kakao OAuth2 app. For example: 839ff5000000000000000000013206de | | | clientSecret | string | 'Client Secret' of Kakao OAuth2 app. For example: jLNVOK00000000000000000000yJebea. Generate it under Kakao Login > Security and set its status to enabled | | -| prompt | array | Array of Kakao OAuth2 prompt values. 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. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. | | | 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. | | +| prompt | array | Array of Kakao OAuth2 prompt values. 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. "create" means: prompt the user to sign up. "select_account" means: prompt the user to select an account. Pass an empty array to use the Kakao default. | | ```http request @@ -1104,7 +1104,7 @@ POST https://cloud.appwrite.io/v1/project/platforms/android PUT https://cloud.appwrite.io/v1/project/platforms/android/{platformId} ``` -** Update an Android platform by its unique ID. Use this endpoint to update the platform's name or application ID. ** +** Update an Android platform by its unique ID. Use this endpoint to update the platform's name, application ID or signing certificate fingerprints. ** ### Parameters @@ -1537,7 +1537,7 @@ GET https://cloud.appwrite.io/v1/project/policies/{policyId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| policyId | string | **Required** Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. | | +| policyId | string | **Required** Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, password-pwned, password-rotation, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email, passkey. | | ```http request @@ -1627,7 +1627,7 @@ PATCH https://cloud.appwrite.io/v1/project/templates/email | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| templateId | string | Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession | | +| templateId | string | Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery | | | locale | string | Custom email template locale. If left empty, the fallback locale (en) will be used. | | | subject | string | Subject of the email template. Can be up to 255 characters. | | | message | string | Plain or HTML body of the email template message. Can be up to 10MB of content. | | @@ -1647,7 +1647,7 @@ GET https://cloud.appwrite.io/v1/project/templates/email/{templateId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| templateId | string | **Required** Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession | | +| templateId | string | **Required** Custom email template type. Can be one of: verification, magicSession, recovery, invitation, mfaChallenge, sessionAlert, otpSession, otpVerification, otpRecovery | | | locale | string | Custom email template locale. If left empty, the fallback locale (en) will be used. | | diff --git a/docs/proxy.md b/docs/proxy.md index baf24feb..2ed4f707 100644 --- a/docs/proxy.md +++ b/docs/proxy.md @@ -7,7 +7,9 @@ POST https://cloud.appwrite.io/v1/proxy/invalidations ** Create a new CDN cache invalidation for a domain. Executes a hard purge of cached content. -Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. ** +Depending on type, the invalidation purges a single cache tag, a single URL path, or all cached content for the domain. + +Domains that route to a function do not support cache invalidation. ** ### Parameters @@ -28,7 +30,7 @@ GET https://cloud.appwrite.io/v1/proxy/rules | 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/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch | [] | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch, protocol | [] | | total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | @@ -100,6 +102,21 @@ Rule ID is automatically generated as MD5 hash of a rule domain for performance | branch | string | Name of VCS branch to deploy changes automatically | | +```http request +POST https://cloud.appwrite.io/v1/proxy/rules/smtp +``` + +** Create an SMTP ingress rule that asynchronously executes an Appwrite Function for incoming email. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| domain | string | Domain that receives email. | | +| functionId | string | ID of function to execute. | | +| branch | string | Name of VCS branch to deploy changes automatically. | | + + ```http request GET https://cloud.appwrite.io/v1/proxy/rules/{ruleId} ``` diff --git a/docs/storage.md b/docs/storage.md index cecf8af3..e24fa98a 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -201,7 +201,7 @@ GET https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId}/previ | fileId | string | **Required** File ID | | | width | integer | Resize preview image width, Pass an integer between 0 to 4000. | 0 | | height | integer | Resize preview image height, Pass an integer between 0 to 4000. | 0 | -| gravity | string | Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right | center | +| gravity | string | Image crop gravity. Can be one of auto,center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right | center | | quality | integer | Preview image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. | -1 | | borderWidth | integer | Preview image border in pixels. Pass an integer between 0 to 100. Defaults to 0. | 0 | | borderColor | string | Preview image border color. Use a valid HEX color, no # is needed for prefix. | | diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 4f2816ef..61642ce3 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -39,7 +39,7 @@ POST https://cloud.appwrite.io/v1/tablesdb GET https://cloud.appwrite.io/v1/tablesdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request @@ -199,7 +199,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations ``` -** Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live, with a brief read-only window during cutover. ** +** Start migrating a serverless TablesDB database onto a dedicated MySQL compute. Data is copied to the target while the source stays live. Reads continue throughout. Row writes are held for up to a few seconds while routing switches to the dedicated compute; a write the switch has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. Schema changes (tables, columns, indexes) are refused from creation until the cutover completes, and resume once the migration is `soaking`. ** ### Parameters @@ -242,7 +242,7 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations/{migrationI POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/migrations/{migrationId}/cutovers ``` -** Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns, with a brief read-only window. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. ** +** Cut a verified TablesDB migration over to its dedicated compute. Only applies to a migration created with `autoCutover` disabled, which waits at `ready_to_cutover` until this is called. The routing flip happens shortly after this returns. Reads are unaffected; row writes are held for up to a few seconds while it lands, and a write the flip has not absorbed within that hold is refused with `database_migration_cutover` and can be retried. One call buys one attempt: a cutover that fails a check returns the migration to `verifying` and parks it again, so call this once more to retry. ** ### Parameters @@ -327,7 +327,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables | rowSecurity | boolean | Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. | 1 | | columns | array | Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. | [] | -| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | +| indexes | array | Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial, trigram), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). | [] | ```http request @@ -911,6 +911,24 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | restrict | +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key} +``` + +** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | | +| newKey | string | New Column Key. | | + + ```http request POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/string ``` @@ -1100,24 +1118,6 @@ DELETE https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/colum | key | string | **Required** Column Key. | | -```http request -PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship -``` - -** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| onDelete | string | Delete constraint. Possible values are: cascade, restrict, setNull. | | -| newKey | string | New Column Key. | | - - ```http request GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes ``` @@ -1139,7 +1139,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/indexes ``` ** Creates an index on the columns listed. Your index should include all the columns you will query in a single request. -Type can be `key`, `fulltext`, or `unique`. ** +Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` is only available on PostgreSQL and lets `contains`, `startsWith`, and `endsWith` queries on string columns use an index. ** ### Parameters diff --git a/docs/teams.md b/docs/teams.md index c08fa9b7..d7477399 100644 --- a/docs/teams.md +++ b/docs/teams.md @@ -28,7 +28,7 @@ POST https://cloud.appwrite.io/v1/teams | --- | --- | --- | --- | | teamId | string | Team 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 | Team name. Max length: 128 chars. | | -| roles | array | Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long. | ["owner"] | +| roles | array | Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. 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. | ["owner"] | ```http request diff --git a/docs/users.md b/docs/users.md index 17e7c54d..4c70df69 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, accessedAt | [] | +| 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, passwordPwned, 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 | @@ -226,7 +226,7 @@ PATCH https://cloud.appwrite.io/v1/users/{userId}/email PATCH https://cloud.appwrite.io/v1/users/{userId}/impersonator ``` -** Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. +** Enable or disable whether a user can impersonate other users. When impersonation headers are used, the request runs as the target user for API behavior, while internal audit logs still attribute the action to the original impersonator and store the impersonated target details only in internal audit payload data. Account endpoints are read-only while impersonating: they report the target's account, and anything that would change it is refused, so an impersonator cannot alter the target's credentials or delete their account. ** ### Parameters @@ -268,21 +268,6 @@ Labels can be used to grant access to resources. While teams are a way for user' | labels | array | Array of user labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. | | -```http request -GET https://cloud.appwrite.io/v1/users/{userId}/logs -``` - -** Get the user activity logs list by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| userId | string | **Required** User 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/users/{userId}/memberships ``` diff --git a/docs/vectorsdb.md b/docs/vectorsdb.md index 70da401a..d94cc7b0 100644 --- a/docs/vectorsdb.md +++ b/docs/vectorsdb.md @@ -38,7 +38,7 @@ POST https://cloud.appwrite.io/v1/vectorsdb GET https://cloud.appwrite.io/v1/vectorsdb/specifications ``` -** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, pricing, and whether it is enabled for the organization. ** +** List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization. ** ```http request diff --git a/docs/webhooks.md b/docs/webhooks.md index c8b7ec5c..5ed6ad59 100644 --- a/docs/webhooks.md +++ b/docs/webhooks.md @@ -31,8 +31,8 @@ POST https://cloud.appwrite.io/v1/webhooks | events | array | Events list. Maximum of 100 events are allowed. | | | enabled | boolean | Enable or disable a webhook. | 1 | | tls | boolean | Certificate verification, false for disabled or true for enabled. | | -| authUsername | string | Webhook HTTP user. Max length: 256 chars. | | -| authPassword | string | Webhook HTTP password. Max length: 256 chars. | | +| authUsername | string | Webhook HTTP user. Max length: 255 chars. | | +| authPassword | string | Webhook HTTP password. Max length: 2048 chars. | | | secret | string | Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. | | @@ -65,8 +65,8 @@ PUT https://cloud.appwrite.io/v1/webhooks/{webhookId} | events | array | Events list. Maximum of 100 events are allowed. | | | enabled | boolean | Enable or disable a webhook. | 1 | | tls | boolean | Certificate verification, false for disabled or true for enabled. | | -| authUsername | string | Webhook HTTP user. Max length: 256 chars. | | -| authPassword | string | Webhook HTTP password. Max length: 256 chars. | | +| authUsername | string | Webhook HTTP user. Max length: 255 chars. | | +| authPassword | string | Webhook HTTP password. Max length: 2048 chars. Omit to keep the current password; it is cleared when the URL changes or TLS verification is disabled. | | ```http request diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 7aaf3809..194e66bb 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -4,8 +4,10 @@ namespace Appwrite; +use Appwrite\Query\Builder as QueryBuilder; use Ahc\Jwt\JWT; use Psr\Http\Client\ClientExceptionInterface; +use Psr\Http\Client\ClientInterface; use Utopia\Client\Adapter\Curl\Client as CurlAdapter; use Utopia\Client\Client as HttpClient; use Utopia\Psr7\Request\Factory as RequestFactory; @@ -43,11 +45,11 @@ class Client * */ protected array $headers = [ - 'user-agent' => 'AppwritePHPSDK/30.4.0 ()', + 'user-agent' => 'AppwritePHPSDK/31.0.0 ()', 'x-sdk-name' => 'PHP', 'x-sdk-platform' => 'server', 'x-sdk-language' => 'php', - 'x-sdk-version' => '30.4.0', + 'x-sdk-version' => '31.0.0', ]; /** @@ -105,12 +107,13 @@ class Client protected RequestFactory $requestFactory; /** - * Client constructor. + * An injected PSR-18 transport owns its timeout, TLS, connection reuse and + * redirect configuration. Without one, the SDK configures its cURL client. */ - public function __construct() + public function __construct(private readonly ?ClientInterface $transport = null) { $this->requestFactory = new RequestFactory(); - $this->headers['X-Appwrite-Response-Format'] = '2.0.0'; + $this->headers['X-Appwrite-Response-Format'] = '2.5.0'; } /** @@ -233,21 +236,6 @@ public function setForwardedUserAgent(string $value): Client return $this; } - /** - * Set DevKey - * - * Your secret dev API key - * - * - */ - public function setDevKey(string $value): Client - { - $this->addHeader('X-Appwrite-Dev-Key', $value); - $this->config['devkey'] = $value; - - return $this; - } - /** * Set Cookie * @@ -433,6 +421,7 @@ public function call( $this->headers['authorization'] = $this->getAuthorization(); } $headers = array_merge($this->headers, $headers); + $params = \array_map(self::flatten(...), $params); $contentType = strtolower((string) ($headers['content-type'] ?? '')); if ($contentType === '') { unset($headers['content-type']); @@ -505,7 +494,7 @@ public function call( * Flatten params array to PHP multiple format * */ - protected function flatten(array $data, string $prefix = ''): array + protected function flattenForm(array $data, string $prefix = ''): array { $output = []; @@ -513,7 +502,7 @@ protected function flatten(array $data, string $prefix = ''): array $finalKey = $prefix ? "{$prefix}[{$key}]" : $key; if (is_array($value)) { - $output = array_merge($output, $this->flatten($value, $finalKey)); + $output = array_merge($output, $this->flattenForm($value, $finalKey)); } else { $output[$finalKey] = $value; } @@ -539,6 +528,40 @@ protected function prepareParams($data) return $data; } + public static function flatten(mixed $value): mixed + { + if ($value instanceof QueryBuilder) { + return $value->build(); + } + if ($value instanceof Query) { + return $value->__toString(); + } + if (!\is_array($value) || !\array_is_list($value)) { + return $value; + } + + $out = []; + $changed = false; + foreach ($value as $item) { + $flat = self::flatten($item); + if ($item instanceof QueryBuilder || $item instanceof Query) { + if (\is_array($flat)) { + array_push($out, ...$flat); + } else { + $out[] = $flat; + } + $changed = true; + continue; + } + if ($flat !== $item) { + $changed = true; + } + $out[] = $flat; + } + + return $changed ? $out : $value; + } + /** * Convert flattened params into Utopia multipart parts. * @@ -549,7 +572,7 @@ protected function toMultipartParts(array $data): array { $parts = []; - foreach ($this->flatten($data) as $name => $value) { + foreach ($this->flattenForm($data) as $name => $value) { $name = (string) $name; if ($value instanceof Part) { @@ -578,8 +601,12 @@ protected function toMultipartParts(array $data): array return $parts; } - protected function getHttpClient(bool $followRedirects): HttpClient + protected function getHttpClient(bool $followRedirects): ClientInterface { + if ($this->transport instanceof ClientInterface) { + return $this->transport; + } + if ($followRedirects) { return $this->httpClient ??= $this->createHttpClient(true); } diff --git a/src/Appwrite/Enums/BillingPlanGroup.php b/src/Appwrite/Enums/BillingPlanGroup.php index 59b1adab..c3a69534 100644 --- a/src/Appwrite/Enums/BillingPlanGroup.php +++ b/src/Appwrite/Enums/BillingPlanGroup.php @@ -9,7 +9,6 @@ class BillingPlanGroup implements JsonSerializable, Stringable { - private static BillingPlanGroup $STARTER; private static BillingPlanGroup $FREE; private static BillingPlanGroup $START; private static BillingPlanGroup $PRO; @@ -29,12 +28,6 @@ public function jsonSerialize(): string return $this->value; } - public static function STARTER(): BillingPlanGroup - { - self::$STARTER ??= new BillingPlanGroup('starter'); - - return self::$STARTER; - } public static function FREE(): BillingPlanGroup { self::$FREE ??= new BillingPlanGroup('free'); @@ -63,7 +56,6 @@ public static function SCALE(): BillingPlanGroup public static function from(string $value): self { return match ($value) { - 'starter' => self::STARTER(), 'free' => self::FREE(), 'start' => self::START(), 'pro' => self::PRO(), diff --git a/src/Appwrite/Enums/ExecutionTrigger.php b/src/Appwrite/Enums/ExecutionTrigger.php index fccf3f23..99ed21da 100644 --- a/src/Appwrite/Enums/ExecutionTrigger.php +++ b/src/Appwrite/Enums/ExecutionTrigger.php @@ -12,6 +12,7 @@ class ExecutionTrigger implements JsonSerializable, Stringable private static ExecutionTrigger $HTTP; private static ExecutionTrigger $SCHEDULE; private static ExecutionTrigger $EVENT; + private static ExecutionTrigger $EMAIL; private function __construct(private readonly string $value) { @@ -45,6 +46,12 @@ public static function EVENT(): ExecutionTrigger return self::$EVENT; } + public static function EMAIL(): ExecutionTrigger + { + self::$EMAIL ??= new ExecutionTrigger('email'); + + return self::$EMAIL; + } public static function from(string $value): self { @@ -52,6 +59,7 @@ public static function from(string $value): self 'http' => self::HTTP(), 'schedule' => self::SCHEDULE(), 'event' => self::EVENT(), + 'email' => self::EMAIL(), default => throw new \InvalidArgumentException('Unknown ExecutionTrigger value: ' . $value), }; } diff --git a/src/Appwrite/Enums/OrganizationKeyScopes.php b/src/Appwrite/Enums/OrganizationKeyScopes.php deleted file mode 100644 index b28e58e9..00000000 --- a/src/Appwrite/Enums/OrganizationKeyScopes.php +++ /dev/null @@ -1,162 +0,0 @@ -value; - } - - public function jsonSerialize(): string - { - return $this->value; - } - - public static function PROJECTSREAD(): OrganizationKeyScopes - { - self::$PROJECTSREAD ??= new OrganizationKeyScopes('projects.read'); - - return self::$PROJECTSREAD; - } - public static function PROJECTSWRITE(): OrganizationKeyScopes - { - self::$PROJECTSWRITE ??= new OrganizationKeyScopes('projects.write'); - - return self::$PROJECTSWRITE; - } - public static function DEVKEYSREAD(): OrganizationKeyScopes - { - self::$DEVKEYSREAD ??= new OrganizationKeyScopes('devKeys.read'); - - return self::$DEVKEYSREAD; - } - public static function DEVKEYSWRITE(): OrganizationKeyScopes - { - self::$DEVKEYSWRITE ??= new OrganizationKeyScopes('devKeys.write'); - - return self::$DEVKEYSWRITE; - } - public static function ORGANIZATIONKEYSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONKEYSREAD ??= new OrganizationKeyScopes('organization.keys.read'); - - return self::$ORGANIZATIONKEYSREAD; - } - public static function ORGANIZATIONKEYSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONKEYSWRITE ??= new OrganizationKeyScopes('organization.keys.write'); - - return self::$ORGANIZATIONKEYSWRITE; - } - public static function ORGANIZATIONINSTALLATIONSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONINSTALLATIONSREAD ??= new OrganizationKeyScopes('organization.installations.read'); - - return self::$ORGANIZATIONINSTALLATIONSREAD; - } - public static function ORGANIZATIONINSTALLATIONSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONINSTALLATIONSWRITE ??= new OrganizationKeyScopes('organization.installations.write'); - - return self::$ORGANIZATIONINSTALLATIONSWRITE; - } - public static function ORGANIZATIONMEMBERSHIPSREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONMEMBERSHIPSREAD ??= new OrganizationKeyScopes('organization.memberships.read'); - - return self::$ORGANIZATIONMEMBERSHIPSREAD; - } - public static function ORGANIZATIONMEMBERSHIPSWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONMEMBERSHIPSWRITE ??= new OrganizationKeyScopes('organization.memberships.write'); - - return self::$ORGANIZATIONMEMBERSHIPSWRITE; - } - public static function ORGANIZATIONREAD(): OrganizationKeyScopes - { - self::$ORGANIZATIONREAD ??= new OrganizationKeyScopes('organization.read'); - - return self::$ORGANIZATIONREAD; - } - public static function ORGANIZATIONWRITE(): OrganizationKeyScopes - { - self::$ORGANIZATIONWRITE ??= new OrganizationKeyScopes('organization.write'); - - return self::$ORGANIZATIONWRITE; - } - public static function DOMAINSREAD(): OrganizationKeyScopes - { - self::$DOMAINSREAD ??= new OrganizationKeyScopes('domains.read'); - - return self::$DOMAINSREAD; - } - public static function DOMAINSWRITE(): OrganizationKeyScopes - { - self::$DOMAINSWRITE ??= new OrganizationKeyScopes('domains.write'); - - return self::$DOMAINSWRITE; - } - public static function KEYSREAD(): OrganizationKeyScopes - { - self::$KEYSREAD ??= new OrganizationKeyScopes('keys.read'); - - return self::$KEYSREAD; - } - public static function KEYSWRITE(): OrganizationKeyScopes - { - self::$KEYSWRITE ??= new OrganizationKeyScopes('keys.write'); - - return self::$KEYSWRITE; - } - - public static function from(string $value): self - { - return match ($value) { - 'projects.read' => self::PROJECTSREAD(), - 'projects.write' => self::PROJECTSWRITE(), - 'devKeys.read' => self::DEVKEYSREAD(), - 'devKeys.write' => self::DEVKEYSWRITE(), - 'organization.keys.read' => self::ORGANIZATIONKEYSREAD(), - 'organization.keys.write' => self::ORGANIZATIONKEYSWRITE(), - 'organization.installations.read' => self::ORGANIZATIONINSTALLATIONSREAD(), - 'organization.installations.write' => self::ORGANIZATIONINSTALLATIONSWRITE(), - '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(), - 'keys.write' => self::KEYSWRITE(), - default => throw new \InvalidArgumentException('Unknown OrganizationKeyScopes value: ' . $value), - }; - } -} diff --git a/src/Appwrite/Enums/ProxyRuleProtocol.php b/src/Appwrite/Enums/ProxyRuleProtocol.php new file mode 100644 index 00000000..0c7423de --- /dev/null +++ b/src/Appwrite/Enums/ProxyRuleProtocol.php @@ -0,0 +1,50 @@ +value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function HTTP(): ProxyRuleProtocol + { + self::$HTTP ??= new ProxyRuleProtocol('http'); + + return self::$HTTP; + } + public static function SMTP(): ProxyRuleProtocol + { + self::$SMTP ??= new ProxyRuleProtocol('smtp'); + + return self::$SMTP; + } + + public static function from(string $value): self + { + return match ($value) { + 'http' => self::HTTP(), + 'smtp' => self::SMTP(), + default => throw new \InvalidArgumentException('Unknown ProxyRuleProtocol value: ' . $value), + }; + } +} diff --git a/src/Appwrite/Models/ActivityEventList.php b/src/Appwrite/Models/ActivityEventList.php index 8fd47418..357d7578 100644 --- a/src/Appwrite/Models/ActivityEventList.php +++ b/src/Appwrite/Models/ActivityEventList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'events' => [], ]; - if (!array_key_exists('events', $data)) { - throw new \InvalidArgumentException('Missing required field "events" for ' . static::class . '.'); - } - return new static( total: $data['total'], events: is_array($data['events']) diff --git a/src/Appwrite/Models/App.php b/src/Appwrite/Models/App.php index 24d11d56..7b0f9e16 100644 --- a/src/Appwrite/Models/App.php +++ b/src/Appwrite/Models/App.php @@ -104,12 +104,9 @@ public static function from(array $data): static 'userId' => "", 'installationScopes' => [], 'installationRedirectUrl' => "", + 'secrets' => [], ]; - if (!array_key_exists('secrets', $data)) { - throw new \InvalidArgumentException('Missing required field "secrets" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/AppInstallationList.php b/src/Appwrite/Models/AppInstallationList.php index cd5c3396..09803f30 100644 --- a/src/Appwrite/Models/AppInstallationList.php +++ b/src/Appwrite/Models/AppInstallationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'installations' => [], ]; - if (!array_key_exists('installations', $data)) { - throw new \InvalidArgumentException('Missing required field "installations" for ' . static::class . '.'); - } - return new static( total: $data['total'], installations: is_array($data['installations']) diff --git a/src/Appwrite/Models/AppKeyList.php b/src/Appwrite/Models/AppKeyList.php index 25f9edf9..577dfc64 100644 --- a/src/Appwrite/Models/AppKeyList.php +++ b/src/Appwrite/Models/AppKeyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'keys' => [], ]; - if (!array_key_exists('keys', $data)) { - throw new \InvalidArgumentException('Missing required field "keys" for ' . static::class . '.'); - } - return new static( total: $data['total'], keys: is_array($data['keys']) diff --git a/src/Appwrite/Models/AppScopeList.php b/src/Appwrite/Models/AppScopeList.php index 7ccaf66a..06bace42 100644 --- a/src/Appwrite/Models/AppScopeList.php +++ b/src/Appwrite/Models/AppScopeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'scopes' => [], ]; - if (!array_key_exists('scopes', $data)) { - throw new \InvalidArgumentException('Missing required field "scopes" for ' . static::class . '.'); - } - return new static( total: $data['total'], scopes: is_array($data['scopes']) diff --git a/src/Appwrite/Models/AppSecretList.php b/src/Appwrite/Models/AppSecretList.php index eae43eb6..9eb22f83 100644 --- a/src/Appwrite/Models/AppSecretList.php +++ b/src/Appwrite/Models/AppSecretList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'secrets' => [], ]; - if (!array_key_exists('secrets', $data)) { - throw new \InvalidArgumentException('Missing required field "secrets" for ' . static::class . '.'); - } - return new static( total: $data['total'], secrets: is_array($data['secrets']) diff --git a/src/Appwrite/Models/AppsList.php b/src/Appwrite/Models/AppsList.php index 4b028315..5685206d 100644 --- a/src/Appwrite/Models/AppsList.php +++ b/src/Appwrite/Models/AppsList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'apps' => [], ]; - if (!array_key_exists('apps', $data)) { - throw new \InvalidArgumentException('Missing required field "apps" for ' . static::class . '.'); - } - return new static( total: $data['total'], apps: is_array($data['apps']) diff --git a/src/Appwrite/Models/AttributeEnum.php b/src/Appwrite/Models/AttributeEnum.php index d2d84316..c99bdc57 100644 --- a/src/Appwrite/Models/AttributeEnum.php +++ b/src/Appwrite/Models/AttributeEnum.php @@ -57,15 +57,13 @@ public static function from(array $data): static 'required' => false, '$createdAt' => "", '$updatedAt' => "", + 'elements' => [], 'format' => "enum", ]; if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('elements', $data)) { - throw new \InvalidArgumentException('Missing required field "elements" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/AttributeList.php b/src/Appwrite/Models/AttributeList.php index 0dd3e89e..b583570c 100644 --- a/src/Appwrite/Models/AttributeList.php +++ b/src/Appwrite/Models/AttributeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'attributes' => [], ]; - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - return new static( total: $data['total'], attributes: $data['attributes'] diff --git a/src/Appwrite/Models/BackupArchive.php b/src/Appwrite/Models/BackupArchive.php index 44422c20..949c9466 100644 --- a/src/Appwrite/Models/BackupArchive.php +++ b/src/Appwrite/Models/BackupArchive.php @@ -20,12 +20,12 @@ * @param string $createdAt archive creation time in iso 8601 format. * @param string $updatedAt archive update date in iso 8601 format. * @param string $policyId archive policy id. - * @param int $size archive size in bytes. * @param string $status the status of the archive creation. possible values: pending, processing, uploading, completed, failed, skipped. - * @param string $startedAt the backup start time. * @param string $migrationId migration id. * @param array $services the services that are backed up by this archive. * @param array $resources the resources that are backed up by this archive. + * @param int|null $size archive size in bytes. null until the size is known. + * @param string|null $startedAt the backup start time. null until the backup starts. * @param string|null $resourceId the resource id to backup. set only if this archive should backup a single resource. * @param string|null $resourceType the resource type to backup. set only if this archive should backup a single resource. */ @@ -34,12 +34,12 @@ public function __construct( public string $createdAt, public string $updatedAt, public string $policyId, - public int $size, public string $status, - public string $startedAt, public string $migrationId, public array $services, public array $resources, + public ?int $size = null, + public ?string $startedAt = null, public ?string $resourceId = null, public ?string $resourceType = null ) { @@ -57,32 +57,21 @@ public static function from(array $data): static 'policyId' => "", 'status' => "", 'migrationId' => "", + 'services' => [], + 'resources' => [], ]; - if (!array_key_exists('size', $data)) { - throw new \InvalidArgumentException('Missing required field "size" for ' . static::class . '.'); - } - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], updatedAt: $data['$updatedAt'], policyId: $data['policyId'], - size: $data['size'], status: $data['status'], - startedAt: $data['startedAt'], migrationId: $data['migrationId'], services: $data['services'], resources: $data['resources'], + size: $data['size'] ?? null, + startedAt: $data['startedAt'] ?? null, resourceId: $data['resourceId'] ?? null, resourceType: $data['resourceType'] ?? null ); diff --git a/src/Appwrite/Models/BackupArchiveList.php b/src/Appwrite/Models/BackupArchiveList.php index 49691da9..e166d7a7 100644 --- a/src/Appwrite/Models/BackupArchiveList.php +++ b/src/Appwrite/Models/BackupArchiveList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'archives' => [], ]; - if (!array_key_exists('archives', $data)) { - throw new \InvalidArgumentException('Missing required field "archives" for ' . static::class . '.'); - } - return new static( total: $data['total'], archives: is_array($data['archives']) diff --git a/src/Appwrite/Models/BackupPolicy.php b/src/Appwrite/Models/BackupPolicy.php index 790139c0..b527ffbc 100644 --- a/src/Appwrite/Models/BackupPolicy.php +++ b/src/Appwrite/Models/BackupPolicy.php @@ -55,19 +55,14 @@ public static function from(array $data): static 'name' => "", '$createdAt' => "", '$updatedAt' => "", + 'services' => [], + 'resources' => [], 'retention' => 1, 'schedule' => "0 * * * *", 'type' => "full", 'enabled' => false, ]; - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], name: $data['name'], diff --git a/src/Appwrite/Models/BackupPolicyList.php b/src/Appwrite/Models/BackupPolicyList.php index f27fe912..ab81c662 100644 --- a/src/Appwrite/Models/BackupPolicyList.php +++ b/src/Appwrite/Models/BackupPolicyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'policies' => [], ]; - if (!array_key_exists('policies', $data)) { - throw new \InvalidArgumentException('Missing required field "policies" for ' . static::class . '.'); - } - return new static( total: $data['total'], policies: is_array($data['policies']) diff --git a/src/Appwrite/Models/BackupRestoration.php b/src/Appwrite/Models/BackupRestoration.php index c6581f63..0a588ec3 100644 --- a/src/Appwrite/Models/BackupRestoration.php +++ b/src/Appwrite/Models/BackupRestoration.php @@ -22,11 +22,11 @@ * @param string $archiveId backup archive id. * @param string $policyId backup policy id. * @param string $status the status of the restoration. possible values: pending, downloading, processing, completed, failed. - * @param string $startedAt the backup start time. * @param string $migrationId migration id. * @param array $services the services that are backed up by this policy. * @param array $resources the resources that are backed up by this policy. - * @param string $options optional data in key-value object. + * @param array $options restoration options as a key-value object. + * @param string|null $startedAt the restoration start time. null until the restoration starts. */ public function __construct( public string $id, @@ -35,11 +35,11 @@ public function __construct( public string $archiveId, public string $policyId, public string $status, - public string $startedAt, public string $migrationId, public array $services, public array $resources, - public string $options + public array $options, + public ?string $startedAt = null ) { } @@ -56,19 +56,11 @@ public static function from(array $data): static 'policyId' => "", 'status' => "", 'migrationId' => "", + 'services' => [], + 'resources' => [], 'options' => [], ]; - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('resources', $data)) { - throw new \InvalidArgumentException('Missing required field "resources" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], @@ -76,11 +68,11 @@ public static function from(array $data): static archiveId: $data['archiveId'], policyId: $data['policyId'], status: $data['status'], - startedAt: $data['startedAt'], migrationId: $data['migrationId'], services: $data['services'], resources: $data['resources'], - options: $data['options'] + options: $data['options'], + startedAt: $data['startedAt'] ?? null ); } diff --git a/src/Appwrite/Models/BackupRestorationList.php b/src/Appwrite/Models/BackupRestorationList.php index 6d7f13dc..86759d45 100644 --- a/src/Appwrite/Models/BackupRestorationList.php +++ b/src/Appwrite/Models/BackupRestorationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'restorations' => [], ]; - if (!array_key_exists('restorations', $data)) { - throw new \InvalidArgumentException('Missing required field "restorations" for ' . static::class . '.'); - } - return new static( total: $data['total'], restorations: is_array($data['restorations']) diff --git a/src/Appwrite/Models/BillingPlan.php b/src/Appwrite/Models/BillingPlan.php index c8da4643..29ad81c0 100644 --- a/src/Appwrite/Models/BillingPlan.php +++ b/src/Appwrite/Models/BillingPlan.php @@ -30,6 +30,7 @@ * @param int $screenshotsGenerated screenshots generated * @param int $webhooks webhooks * @param int $wafRules maximum waf rules per project + * @param int $environments maximum environments per project. 0 when the plan does not offer environments. * @param int $projects projects * @param int $platforms platforms * @param int $users users @@ -54,7 +55,6 @@ * @param int $usageLogs usage history days * @param int $projectInactivityDays number of days of console inactivity before a project is paused. 0 means pausing is disabled. * @param int $alertLimit alert threshold percentage - * @param UsageBillingPlan $usage additional resources * @param BillingPlanAddon $addons addons * @param bool $budgetCapEnabled budget cap enabled or disabled. * @param bool $customSmtp custom smtp @@ -83,10 +83,10 @@ * @param BillingPlanGroup $group group of this billing plan for variants * @param float $databaseComputeCredit included monthly dedicated-database compute credit in usd. resets each billing cycle with no roll-over. * @param int|null $members members - * @param int|null $environments maximum environments per project. 0 when the plan does not offer environments. * @param int|null $activityLogs activity log days * @param array|null $usageLogsIntervals usage log time intervals allowed for this plan (e.g. 15m, 1h, 1d). * @param array|null $usageAggregateOnlyMetrics metrics this plan only records as a total. they cannot be broken down by dimension or filtered, because the stored events cover a fraction of the real traffic. + * @param UsageBillingPlan|null $usage additional resources. null when the plan does not support usage billing. * @param array|null $eligibleCountries iso country codes eligible for this regional plan. empty means no restriction. * @param bool|null $backupsEnabled does plan support backup policies. * @param int|null $backupPolicies how many policies does plan support @@ -107,6 +107,7 @@ public function __construct( public int $screenshotsGenerated, public int $webhooks, public int $wafRules, + public int $environments, public int $projects, public int $platforms, public int $users, @@ -131,7 +132,6 @@ public function __construct( public int $usageLogs, public int $projectInactivityDays, public int $alertLimit, - public UsageBillingPlan $usage, public BillingPlanAddon $addons, public bool $budgetCapEnabled, public bool $customSmtp, @@ -160,10 +160,10 @@ public function __construct( public BillingPlanGroup $group, public float $databaseComputeCredit, public ?int $members = null, - public ?int $environments = null, public ?int $activityLogs = null, public ?array $usageLogsIntervals = null, public ?array $usageAggregateOnlyMetrics = null, + public ?UsageBillingPlan $usage = null, public ?array $eligibleCountries = null, public ?bool $backupsEnabled = null, public ?int $backupPolicies = null, @@ -191,6 +191,7 @@ public static function from(array $data): static 'screenshotsGenerated' => 0, 'webhooks' => 0, 'wafRules' => 0, + 'environments' => 0, 'projects' => 0, 'platforms' => 0, 'users' => 0, @@ -241,9 +242,6 @@ public static function from(array $data): static 'databaseComputeCredit' => 0, ]; - 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 . '.'); } @@ -267,6 +265,7 @@ public static function from(array $data): static screenshotsGenerated: $data['screenshotsGenerated'], webhooks: $data['webhooks'], wafRules: $data['wafRules'], + environments: $data['environments'], projects: $data['projects'], platforms: $data['platforms'], users: $data['users'], @@ -291,7 +290,6 @@ functions: $data['functions'], 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'], @@ -320,10 +318,10 @@ functionsIntervalMinimum: $data['functionsIntervalMinimum'], group: static::hydrateTypedValue(BillingPlanGroup::class, $data['group']), databaseComputeCredit: $data['databaseComputeCredit'], members: $data['members'] ?? null, - environments: $data['environments'] ?? null, activityLogs: $data['activityLogs'] ?? null, usageLogsIntervals: $data['usageLogsIntervals'] ?? null, usageAggregateOnlyMetrics: $data['usageAggregateOnlyMetrics'] ?? null, + usage: array_key_exists('usage', $data) ? static::hydrateTypedValue(UsageBillingPlan::class, $data['usage'], true) : null, eligibleCountries: $data['eligibleCountries'] ?? null, backupsEnabled: $data['backupsEnabled'] ?? null, backupPolicies: $data['backupPolicies'] ?? null, diff --git a/src/Appwrite/Models/Block.php b/src/Appwrite/Models/Block.php index f40cb573..3b918222 100644 --- a/src/Appwrite/Models/Block.php +++ b/src/Appwrite/Models/Block.php @@ -20,12 +20,6 @@ * @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. - * @param string $organizationId id of the organization that owns the project. - * @param string $billingPlan billing plan of the organization that owns the project. - * @param string|null $reason reason for the block. can be null if no reason was provided. * @param string|null $expiredAt block expiration date in iso 8601 format. can be null if the block does not expire. */ public function __construct( @@ -33,12 +27,6 @@ public function __construct( public string $resourceType, public string $resourceId, public string $mode, - public string $projectName, - public string $region, - public string $organizationName, - public string $organizationId, - public string $billingPlan, - public ?string $reason = null, public ?string $expiredAt = null ) { } @@ -55,33 +43,11 @@ public static function from(array $data): static 'mode' => "full", ]; - if (!array_key_exists('projectName', $data)) { - throw new \InvalidArgumentException('Missing required field "projectName" for ' . static::class . '.'); - } - if (!array_key_exists('region', $data)) { - throw new \InvalidArgumentException('Missing required field "region" for ' . static::class . '.'); - } - if (!array_key_exists('organizationName', $data)) { - throw new \InvalidArgumentException('Missing required field "organizationName" for ' . static::class . '.'); - } - if (!array_key_exists('organizationId', $data)) { - throw new \InvalidArgumentException('Missing required field "organizationId" for ' . static::class . '.'); - } - if (!array_key_exists('billingPlan', $data)) { - throw new \InvalidArgumentException('Missing required field "billingPlan" for ' . static::class . '.'); - } - return new static( createdAt: $data['$createdAt'], resourceType: $data['resourceType'], resourceId: $data['resourceId'], mode: $data['mode'], - projectName: $data['projectName'], - region: $data['region'], - organizationName: $data['organizationName'], - organizationId: $data['organizationId'], - billingPlan: $data['billingPlan'], - reason: $data['reason'] ?? null, expiredAt: $data['expiredAt'] ?? null ); } @@ -96,13 +62,7 @@ public function toArray(): array '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), - 'region' => static::serializeValue($this->region), - 'organizationName' => static::serializeValue($this->organizationName), - 'organizationId' => static::serializeValue($this->organizationId), - 'billingPlan' => static::serializeValue($this->billingPlan) + 'expiredAt' => static::serializeValue($this->expiredAt) ]; } } diff --git a/src/Appwrite/Models/BucketList.php b/src/Appwrite/Models/BucketList.php index 4ee13e87..d5e2831f 100644 --- a/src/Appwrite/Models/BucketList.php +++ b/src/Appwrite/Models/BucketList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'buckets' => [], ]; - if (!array_key_exists('buckets', $data)) { - throw new \InvalidArgumentException('Missing required field "buckets" for ' . static::class . '.'); - } - return new static( total: $data['total'], buckets: is_array($data['buckets']) diff --git a/src/Appwrite/Models/Collection.php b/src/Appwrite/Models/Collection.php index 34e1ff95..cf23cf70 100644 --- a/src/Appwrite/Models/Collection.php +++ b/src/Appwrite/Models/Collection.php @@ -54,24 +54,17 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'documentSecurity' => false, + 'attributes' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/CollectionList.php b/src/Appwrite/Models/CollectionList.php index 435e41ad..19110117 100644 --- a/src/Appwrite/Models/CollectionList.php +++ b/src/Appwrite/Models/CollectionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'collections' => [], ]; - if (!array_key_exists('collections', $data)) { - throw new \InvalidArgumentException('Missing required field "collections" for ' . static::class . '.'); - } - return new static( total: $data['total'], collections: is_array($data['collections']) diff --git a/src/Appwrite/Models/ColumnEnum.php b/src/Appwrite/Models/ColumnEnum.php index f9c4c458..31b43871 100644 --- a/src/Appwrite/Models/ColumnEnum.php +++ b/src/Appwrite/Models/ColumnEnum.php @@ -57,15 +57,13 @@ public static function from(array $data): static 'required' => false, '$createdAt' => "", '$updatedAt' => "", + 'elements' => [], 'format' => "enum", ]; if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('elements', $data)) { - throw new \InvalidArgumentException('Missing required field "elements" for ' . static::class . '.'); - } return new static( key: $data['key'], diff --git a/src/Appwrite/Models/ColumnIndexList.php b/src/Appwrite/Models/ColumnIndexList.php index b5eaf075..1ce04240 100644 --- a/src/Appwrite/Models/ColumnIndexList.php +++ b/src/Appwrite/Models/ColumnIndexList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'indexes' => [], ]; - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( total: $data['total'], indexes: is_array($data['indexes']) diff --git a/src/Appwrite/Models/ColumnList.php b/src/Appwrite/Models/ColumnList.php index 108ff6a4..bc3a30f3 100644 --- a/src/Appwrite/Models/ColumnList.php +++ b/src/Appwrite/Models/ColumnList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'columns' => [], ]; - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - return new static( total: $data['total'], columns: $data['columns'] diff --git a/src/Appwrite/Models/ContinentList.php b/src/Appwrite/Models/ContinentList.php index 3af16511..dbf1b56c 100644 --- a/src/Appwrite/Models/ContinentList.php +++ b/src/Appwrite/Models/ContinentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'continents' => [], ]; - if (!array_key_exists('continents', $data)) { - throw new \InvalidArgumentException('Missing required field "continents" for ' . static::class . '.'); - } - return new static( total: $data['total'], continents: is_array($data['continents']) diff --git a/src/Appwrite/Models/CountryList.php b/src/Appwrite/Models/CountryList.php index 0a9210a9..84ce278a 100644 --- a/src/Appwrite/Models/CountryList.php +++ b/src/Appwrite/Models/CountryList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'countries' => [], ]; - if (!array_key_exists('countries', $data)) { - throw new \InvalidArgumentException('Missing required field "countries" for ' . static::class . '.'); - } - return new static( total: $data['total'], countries: is_array($data['countries']) diff --git a/src/Appwrite/Models/CurrencyList.php b/src/Appwrite/Models/CurrencyList.php index d2b33e37..9243c75f 100644 --- a/src/Appwrite/Models/CurrencyList.php +++ b/src/Appwrite/Models/CurrencyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'currencies' => [], ]; - if (!array_key_exists('currencies', $data)) { - throw new \InvalidArgumentException('Missing required field "currencies" for ' . static::class . '.'); - } - return new static( total: $data['total'], currencies: is_array($data['currencies']) diff --git a/src/Appwrite/Models/Database.php b/src/Appwrite/Models/Database.php index bd3a45e1..6cbaff98 100644 --- a/src/Appwrite/Models/Database.php +++ b/src/Appwrite/Models/Database.php @@ -30,7 +30,7 @@ * @param string|null $specification compute specification identifier of the dedicated backing, e.g. s-2vcpu-2gb. null when the database has no dedicated backing. * @param int|null $replicas number of secondary high availability replicas, excluding the primary. null when backing configuration is unavailable. * @param string|null $error error message when the dedicated backing failed. null when the database has no dedicated backing or has not failed. - * @param string|null $containerStatus container status of the dedicated backing: active or inactive. null when the database has no dedicated backing or the runtime has not reported one. + * @param string|null $containerStatus container status of the dedicated backing: active, inactive, or failed (a wake was declined because the backing namespace is gone). null when the database has no dedicated backing or the runtime has not reported one. * @param string|null $lifecycleState idle-lifecycle state of the dedicated backing: active, warm, cold, or hibernated. null when the database has no dedicated backing or the runtime has not reported one. * @param list|null $policies database backup policies. * @param list|null $archives database backup archives. diff --git a/src/Appwrite/Models/DatabaseList.php b/src/Appwrite/Models/DatabaseList.php index 86fb3468..8a1dd971 100644 --- a/src/Appwrite/Models/DatabaseList.php +++ b/src/Appwrite/Models/DatabaseList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'databases' => [], ]; - if (!array_key_exists('databases', $data)) { - throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); - } - return new static( total: $data['total'], databases: is_array($data['databases']) diff --git a/src/Appwrite/Models/DatabaseMigrationList.php b/src/Appwrite/Models/DatabaseMigrationList.php index ae2528dd..480bf847 100644 --- a/src/Appwrite/Models/DatabaseMigrationList.php +++ b/src/Appwrite/Models/DatabaseMigrationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'migrations' => [], ]; - if (!array_key_exists('migrations', $data)) { - throw new \InvalidArgumentException('Missing required field "migrations" for ' . static::class . '.'); - } - return new static( total: $data['total'], migrations: is_array($data['migrations']) diff --git a/src/Appwrite/Models/DatabaseStatus.php b/src/Appwrite/Models/DatabaseStatus.php index 6fdaf141..b685e035 100644 --- a/src/Appwrite/Models/DatabaseStatus.php +++ b/src/Appwrite/Models/DatabaseStatus.php @@ -21,13 +21,13 @@ * @param string $engine database engine: postgresql, mysql, or mongodb. * @param string $version database engine version. * @param int $uptime database uptime in seconds. - * @param DatabaseStatusConnections $connections connection statistics. * @param string $syncMode requested replication sync mode. possible values: async, sync, quorum. compare with effectivesyncmode for what the primary is enforcing. * @param bool $syncDegraded whether the enforced replication is weaker than the requested syncmode. * @param int $syncAcknowledgements number of standby acknowledgements the primary waits for before a write is committed. * @param int $syncStandbyCount number of standbys registered with the primary for synchronous replication. * @param list $replicas list of database replicas and their status. every configured member appears, including one the backend has not brought up, which is reported as not healthy. * @param list $volumes storage volume information. + * @param DatabaseStatusConnections|null $connections connection statistics. null when the database has not been probed. * @param string|null $effectiveSyncMode replication sync mode the primary is actually enforcing. null when high availability is disabled or the state could not be read. * @param bool|null $syncStateConfirmed whether the other sync fields are an engine reading rather than a recorded estimate. true when the primary answered what it is enforcing, including when that answer contradicted the record, in which case the contradicted values are replaced by the ones the engine reports. false when the reading could not be taken: the probe did not answer, there was no engine to ask, or the values describe a configuration change just applied rather than anything measured. absent when no engine was asked at all, so an unprobed database is distinguishable from an unconfirmed one. false never means a standby was found lagging, because it is the absence of a reading rather than a negative one, so draw no conclusion about replication health from it or from a response that omits it. */ @@ -37,13 +37,13 @@ public function __construct( public string $engine, public string $version, public int $uptime, - public DatabaseStatusConnections $connections, public string $syncMode, public bool $syncDegraded, public int $syncAcknowledgements, public int $syncStandbyCount, public array $replicas, public array $volumes, + public ?DatabaseStatusConnections $connections = null, public ?string $effectiveSyncMode = null, public ?bool $syncStateConfirmed = null ) { @@ -64,25 +64,16 @@ public static function from(array $data): static 'syncDegraded' => false, 'syncAcknowledgements' => 0, 'syncStandbyCount' => 0, + 'replicas' => [], + 'volumes' => [], ]; - if (!array_key_exists('connections', $data)) { - throw new \InvalidArgumentException('Missing required field "connections" for ' . static::class . '.'); - } - if (!array_key_exists('replicas', $data)) { - throw new \InvalidArgumentException('Missing required field "replicas" for ' . static::class . '.'); - } - if (!array_key_exists('volumes', $data)) { - throw new \InvalidArgumentException('Missing required field "volumes" for ' . static::class . '.'); - } - return new static( health: $data['health'], ready: $data['ready'], engine: $data['engine'], version: $data['version'], uptime: $data['uptime'], - connections: static::hydrateTypedValue(DatabaseStatusConnections::class, $data['connections']), syncMode: $data['syncMode'], syncDegraded: $data['syncDegraded'], syncAcknowledgements: $data['syncAcknowledgements'], @@ -99,6 +90,7 @@ public static function from(array $data): static $data['volumes'] ) : $data['volumes'], + connections: array_key_exists('connections', $data) ? static::hydrateTypedValue(DatabaseStatusConnections::class, $data['connections'], true) : null, effectiveSyncMode: $data['effectiveSyncMode'] ?? null, syncStateConfirmed: $data['syncStateConfirmed'] ?? null ); diff --git a/src/Appwrite/Models/DedicatedDatabase.php b/src/Appwrite/Models/DedicatedDatabase.php index acd6c5d1..fd356542 100644 --- a/src/Appwrite/Models/DedicatedDatabase.php +++ b/src/Appwrite/Models/DedicatedDatabase.php @@ -21,25 +21,23 @@ * @param string $updatedAt database update date in iso 8601 format. * @param string $projectId project id that owns this database. * @param string $name database display name. - * @param string $api product api that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. - * @param string $engine database engine: postgresql, mysql, or mongodb. null until the backing reports one. * @param string $version database engine version. * @param string $specification specification identifier. * @param string $backend database backend provider. possible values: edge. * @param string $hostname database hostname for connections. - * @param int $connectionPort database port for connections. derived from the engine when the backing has not reported one yet. * @param string $connectionUser database username for connections. * @param string $connectionPassword database password for connections. - * @param int $credentialGeneration committed generation of the primary connection credentials. null until the rotation contract has been initialized. * @param string $connectionString full database connection string (uri format). * @param bool $ssl whether ssl/tls is required for client connections. * @param string $status database status. possible values: provisioning, ready, inactive, paused, failed, deleted, restoring, scaling. - * @param string $containerStatus container status for lifecycle-managed database runtimes: active or inactive. + * @param string $containerStatus container status for lifecycle-managed database runtimes: active, inactive, or failed (a wake was declined because the backing namespace is gone). * @param string $lifecycleState idle-lifecycle state of the database. possible values: active, warm, cold, hibernated. * @param int $idleTimeoutMinutes minutes of inactivity before container scales to zero. * @param int $cpu cpu allocated in millicores. * @param int $memory memory allocated in mb. * @param int $storage storage allocated in gb. + * @param string $storageStatus storage resize status. possible values: idle (no resize in flight), resizing (the volume is growing towards storagetargetgb). + * @param int $storageTargetGb size in gb the volume is growing towards while storagestatus is resizing. 0 when no resize is in flight. * @param string $storageClass storage class. currently always 'ssd'; digitalocean exposes a single block-storage class. * @param int $storageMaxGb maximum storage allowed in gb. 0 means use system default. * @param string $nodePool kubernetes node pool where the database is scheduled. @@ -53,7 +51,7 @@ * @param int $pitrRetentionDays number of days to retain pitr data. * @param bool $storageAutoscaling whether automatic storage expansion is enabled. * @param int $storageAutoscalingThresholdPercent storage usage percentage that triggers automatic expansion. - * @param int $storageAutoscalingMaxGb maximum storage size in gb for autoscaling. 0 means no limit. + * @param int $storageAutoscalingMaxGb maximum storage size in gb for autoscaling. defaults to 3 times the specification's storage. 0 means no limit. * @param string $maintenanceWindowDay day of the week for the maintenance window. possible values: sun, mon, tue, wed, thu, fri, sat. * @param int $maintenanceWindowHourUtc hour in utc (0-23) when the maintenance window starts. * @param bool $metricsEnabled whether metrics collection is enabled. @@ -63,10 +61,12 @@ * @param int $sqlApiMaxBytes maximum serialised sql api result payload in bytes. results larger than this are truncated. * @param int $sqlApiTimeoutSeconds maximum server-side sql api execution time in seconds before the query is cancelled. * @param string $error error message if status is failed. + * @param string|null $api product api that owns this database: tablesdb, documentsdb, vectorsdb, mysql, postgresql, or mongodb. + * @param string|null $engine database engine: postgresql, mysql, or mongodb. null until the backing reports one. + * @param int|null $connectionPort database port for connections. derived from the engine when the backing has not reported one yet. + * @param int|null $credentialGeneration committed generation of the primary connection credentials. null until the rotation contract has been initialized. * @param string|null $lastAccessedAt last activity timestamp in iso 8601 format. * @param string|null $idleUntil display-only timestamp when the database is expected to be considered idle (iso 8601 format). derived from last activity; lifecycle transitions are driven by lifecyclestate. - * @param string|null $storageStatus storage resize status. possible values: idle (no resize in flight), resizing (the volume is growing towards storagetargetgb). - * @param int|null $storageTargetGb size in gb the volume is growing towards while storagestatus is resizing. 0 when no resize is in flight. * @param string|null $storageResizeStartedAt time the in-flight storage resize started, in iso 8601 format. */ public function __construct( @@ -75,16 +75,12 @@ public function __construct( public string $updatedAt, public string $projectId, public string $name, - public string $api, - public string $engine, public string $version, public string $specification, public string $backend, public string $hostname, - public int $connectionPort, public string $connectionUser, public string $connectionPassword, - public int $credentialGeneration, public string $connectionString, public bool $ssl, public string $status, @@ -94,6 +90,8 @@ public function __construct( public int $cpu, public int $memory, public int $storage, + public string $storageStatus, + public int $storageTargetGb, public string $storageClass, public int $storageMaxGb, public string $nodePool, @@ -117,10 +115,12 @@ public function __construct( public int $sqlApiMaxBytes, public int $sqlApiTimeoutSeconds, public string $error, + public ?string $api = null, + public ?string $engine = null, + public ?int $connectionPort = null, + public ?int $credentialGeneration = null, public ?string $lastAccessedAt = null, public ?string $idleUntil = null, - public ?string $storageStatus = null, - public ?int $storageTargetGb = null, public ?string $storageResizeStartedAt = null ) { } @@ -151,6 +151,8 @@ public static function from(array $data): static 'cpu' => 500, 'memory' => 512, 'storage' => 10, + 'storageStatus' => "idle", + 'storageTargetGb' => 0, 'storageClass' => "ssd", 'storageMaxGb' => 0, 'nodePool' => "", @@ -176,35 +178,18 @@ public static function from(array $data): static 'error' => "", ]; - if (!array_key_exists('api', $data)) { - throw new \InvalidArgumentException('Missing required field "api" for ' . static::class . '.'); - } - if (!array_key_exists('engine', $data)) { - throw new \InvalidArgumentException('Missing required field "engine" for ' . static::class . '.'); - } - if (!array_key_exists('connectionPort', $data)) { - throw new \InvalidArgumentException('Missing required field "connectionPort" for ' . static::class . '.'); - } - if (!array_key_exists('credentialGeneration', $data)) { - throw new \InvalidArgumentException('Missing required field "credentialGeneration" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], updatedAt: $data['$updatedAt'], projectId: $data['projectId'], name: $data['name'], - api: $data['api'], - engine: $data['engine'], version: $data['version'], specification: $data['specification'], backend: $data['backend'], hostname: $data['hostname'], - connectionPort: $data['connectionPort'], connectionUser: $data['connectionUser'], connectionPassword: $data['connectionPassword'], - credentialGeneration: $data['credentialGeneration'], connectionString: $data['connectionString'], ssl: $data['ssl'], status: $data['status'], @@ -214,6 +199,8 @@ public static function from(array $data): static cpu: $data['cpu'], memory: $data['memory'], storage: $data['storage'], + storageStatus: $data['storageStatus'], + storageTargetGb: $data['storageTargetGb'], storageClass: $data['storageClass'], storageMaxGb: $data['storageMaxGb'], nodePool: $data['nodePool'], @@ -237,10 +224,12 @@ public static function from(array $data): static sqlApiMaxBytes: $data['sqlApiMaxBytes'], sqlApiTimeoutSeconds: $data['sqlApiTimeoutSeconds'], error: $data['error'], + api: $data['api'] ?? null, + engine: $data['engine'] ?? null, + connectionPort: $data['connectionPort'] ?? null, + credentialGeneration: $data['credentialGeneration'] ?? null, lastAccessedAt: $data['lastAccessedAt'] ?? null, idleUntil: $data['idleUntil'] ?? null, - storageStatus: $data['storageStatus'] ?? null, - storageTargetGb: $data['storageTargetGb'] ?? null, storageResizeStartedAt: $data['storageResizeStartedAt'] ?? null ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseBackupList.php b/src/Appwrite/Models/DedicatedDatabaseBackupList.php index fb6b0225..745fe62c 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBackupList.php +++ b/src/Appwrite/Models/DedicatedDatabaseBackupList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'backups' => [], ]; - if (!array_key_exists('backups', $data)) { - throw new \InvalidArgumentException('Missing required field "backups" for ' . static::class . '.'); - } - return new static( total: $data['total'], backups: is_array($data['backups']) diff --git a/src/Appwrite/Models/DedicatedDatabaseBranch.php b/src/Appwrite/Models/DedicatedDatabaseBranch.php index 47704627..7ddfe531 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBranch.php +++ b/src/Appwrite/Models/DedicatedDatabaseBranch.php @@ -21,13 +21,13 @@ * @param string $namespace kubernetes namespace where the branch is deployed. * @param int $expiresAt unix timestamp when the branch expires. * @param string $host branch hostname for direct connections. - * @param int $port branch port. null until the backing reports one. * @param string $database advertised catalog the client connects to. mysql/mariadb use default; postgres uses the routing label. * @param string $username database username. shared with the parent database. * @param string $password database password. shared with the parent database. * @param bool $ssl whether ssl is required. * @param string $engine database engine. possible values: postgresql, mysql, mongodb. * @param string $connectionString full connection string for the branch. + * @param int|null $port branch port. null until the backing reports one. */ public function __construct( public string $branchId, @@ -35,13 +35,13 @@ public function __construct( public string $namespace, public int $expiresAt, public string $host, - public int $port, public string $database, public string $username, public string $password, public bool $ssl, public string $engine, - public string $connectionString + public string $connectionString, + public ?int $port = null ) { } @@ -64,23 +64,19 @@ public static function from(array $data): static 'connectionString' => "", ]; - if (!array_key_exists('port', $data)) { - throw new \InvalidArgumentException('Missing required field "port" for ' . static::class . '.'); - } - return new static( branchId: $data['branchId'], branchName: $data['branchName'], namespace: $data['namespace'], expiresAt: $data['expiresAt'], host: $data['host'], - port: $data['port'], database: $data['database'], username: $data['username'], password: $data['password'], ssl: $data['ssl'], engine: $data['engine'], - connectionString: $data['connectionString'] + connectionString: $data['connectionString'], + port: $data['port'] ?? null ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseBranchList.php b/src/Appwrite/Models/DedicatedDatabaseBranchList.php index 4212a97d..c7bd5afc 100644 --- a/src/Appwrite/Models/DedicatedDatabaseBranchList.php +++ b/src/Appwrite/Models/DedicatedDatabaseBranchList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'branches' => [], ]; - if (!array_key_exists('branches', $data)) { - throw new \InvalidArgumentException('Missing required field "branches" for ' . static::class . '.'); - } - return new static( total: $data['total'], branches: is_array($data['branches']) diff --git a/src/Appwrite/Models/DedicatedDatabaseExecution.php b/src/Appwrite/Models/DedicatedDatabaseExecution.php index 12e54077..283c9897 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExecution.php +++ b/src/Appwrite/Models/DedicatedDatabaseExecution.php @@ -41,15 +41,12 @@ public static function from(array $data): static $data += [ 'rows' => [], 'rowCount' => 0, + 'columns' => [], 'durationMs' => 0, 'truncated' => false, 'bytes' => 0, ]; - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - return new static( rows: $data['rows'], rowCount: $data['rowCount'], diff --git a/src/Appwrite/Models/DedicatedDatabaseExtensions.php b/src/Appwrite/Models/DedicatedDatabaseExtensions.php index b1532138..9f294000 100644 --- a/src/Appwrite/Models/DedicatedDatabaseExtensions.php +++ b/src/Appwrite/Models/DedicatedDatabaseExtensions.php @@ -35,12 +35,9 @@ public static function from(array $data): static $data += [ 'installed' => [], 'available' => [], + 'metadata' => [], ]; - if (!array_key_exists('metadata', $data)) { - throw new \InvalidArgumentException('Missing required field "metadata" for ' . static::class . '.'); - } - return new static( installed: $data['installed'], available: $data['available'], diff --git a/src/Appwrite/Models/DedicatedDatabaseList.php b/src/Appwrite/Models/DedicatedDatabaseList.php index a9784de3..796742c0 100644 --- a/src/Appwrite/Models/DedicatedDatabaseList.php +++ b/src/Appwrite/Models/DedicatedDatabaseList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'databases' => [], ]; - if (!array_key_exists('databases', $data)) { - throw new \InvalidArgumentException('Missing required field "databases" for ' . static::class . '.'); - } - return new static( total: $data['total'], databases: is_array($data['databases']) diff --git a/src/Appwrite/Models/DedicatedDatabaseOperationList.php b/src/Appwrite/Models/DedicatedDatabaseOperationList.php index 7710285e..c8d97389 100644 --- a/src/Appwrite/Models/DedicatedDatabaseOperationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseOperationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'operations' => [], ]; - if (!array_key_exists('operations', $data)) { - throw new \InvalidArgumentException('Missing required field "operations" for ' . static::class . '.'); - } - return new static( total: $data['total'], operations: is_array($data['operations']) diff --git a/src/Appwrite/Models/DedicatedDatabaseReplicas.php b/src/Appwrite/Models/DedicatedDatabaseReplicas.php index 563630fe..451679fc 100644 --- a/src/Appwrite/Models/DedicatedDatabaseReplicas.php +++ b/src/Appwrite/Models/DedicatedDatabaseReplicas.php @@ -48,12 +48,9 @@ public static function from(array $data): static 'syncDegraded' => false, 'syncAcknowledgements' => 0, 'syncStandbyCount' => 0, + 'members' => [], ]; - if (!array_key_exists('members', $data)) { - throw new \InvalidArgumentException('Missing required field "members" for ' . static::class . '.'); - } - return new static( replicas: $data['replicas'], syncMode: $data['syncMode'], diff --git a/src/Appwrite/Models/DedicatedDatabaseRestoration.php b/src/Appwrite/Models/DedicatedDatabaseRestoration.php index 02927028..8502ddf7 100644 --- a/src/Appwrite/Models/DedicatedDatabaseRestoration.php +++ b/src/Appwrite/Models/DedicatedDatabaseRestoration.php @@ -19,29 +19,31 @@ * @param string $id restoration id. * @param string $createdAt restoration creation time in iso 8601 format. * @param string $databaseId database id being restored into. - * @param string $sourceDatabaseId source database id when restoring a backup into another database. * @param string $projectId project id. - * @param string $backupId backup id used for restoration (null for pitr). * @param string $type restoration type. possible values: backup (restore from a specific backup snapshot), pitr (point-in-time recovery to a specific timestamp). + * @param string $restoreMode where the backup was restored. possible values: in_place (replayed over the database that took the backup), clone (recovered onto a second workload beside the database, which keeps serving until the clone is promoted onto its endpoint), copy (recovered onto a separate database with its own endpoint). * @param string $status restoration status. possible values: pending (queued for processing), running (currently in progress), completed (successfully finished), failed (encountered an error). - * @param string $targetTime target time for pitr restoration in iso 8601 format. - * @param string $startedAt restoration start time in iso 8601 format. - * @param string $completedAt restoration completion time in iso 8601 format. * @param string $error error message if restoration failed. + * @param string|null $sourceDatabaseId source database id when restoring a backup into another database. + * @param string|null $backupId backup id used for restoration (null for pitr). + * @param string|null $targetTime target time for pitr restoration in iso 8601 format. + * @param string|null $startedAt restoration start time in iso 8601 format. + * @param string|null $completedAt restoration completion time in iso 8601 format. */ public function __construct( public string $id, public string $createdAt, public string $databaseId, - public string $sourceDatabaseId, public string $projectId, - public string $backupId, public string $type, + public string $restoreMode, public string $status, - public string $targetTime, - public string $startedAt, - public string $completedAt, - public string $error + public string $error, + public ?string $sourceDatabaseId = null, + public ?string $backupId = null, + public ?string $targetTime = null, + public ?string $startedAt = null, + public ?string $completedAt = null ) { } @@ -56,39 +58,25 @@ public static function from(array $data): static 'databaseId' => "", 'projectId' => "", 'type' => "backup", + 'restoreMode' => "in_place", 'status' => "pending", 'error' => "", ]; - if (!array_key_exists('sourceDatabaseId', $data)) { - throw new \InvalidArgumentException('Missing required field "sourceDatabaseId" for ' . static::class . '.'); - } - if (!array_key_exists('backupId', $data)) { - throw new \InvalidArgumentException('Missing required field "backupId" for ' . static::class . '.'); - } - if (!array_key_exists('targetTime', $data)) { - throw new \InvalidArgumentException('Missing required field "targetTime" for ' . static::class . '.'); - } - if (!array_key_exists('startedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "startedAt" for ' . static::class . '.'); - } - if (!array_key_exists('completedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "completedAt" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], databaseId: $data['databaseId'], - sourceDatabaseId: $data['sourceDatabaseId'], projectId: $data['projectId'], - backupId: $data['backupId'], type: $data['type'], + restoreMode: $data['restoreMode'], status: $data['status'], - targetTime: $data['targetTime'], - startedAt: $data['startedAt'], - completedAt: $data['completedAt'], - error: $data['error'] + error: $data['error'], + sourceDatabaseId: $data['sourceDatabaseId'] ?? null, + backupId: $data['backupId'] ?? null, + targetTime: $data['targetTime'] ?? null, + startedAt: $data['startedAt'] ?? null, + completedAt: $data['completedAt'] ?? null ); } @@ -105,6 +93,7 @@ public function toArray(): array 'projectId' => static::serializeValue($this->projectId), 'backupId' => static::serializeValue($this->backupId), 'type' => static::serializeValue($this->type), + 'restoreMode' => static::serializeValue($this->restoreMode), 'status' => static::serializeValue($this->status), 'targetTime' => static::serializeValue($this->targetTime), 'startedAt' => static::serializeValue($this->startedAt), diff --git a/src/Appwrite/Models/DedicatedDatabaseRestorationList.php b/src/Appwrite/Models/DedicatedDatabaseRestorationList.php index b4491a49..b599e127 100644 --- a/src/Appwrite/Models/DedicatedDatabaseRestorationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseRestorationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'restorations' => [], ]; - if (!array_key_exists('restorations', $data)) { - throw new \InvalidArgumentException('Missing required field "restorations" for ' . static::class . '.'); - } - return new static( total: $data['total'], restorations: is_array($data['restorations']) diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecification.php b/src/Appwrite/Models/DedicatedDatabaseSpecification.php index a4612cc0..aa10cd8e 100644 --- a/src/Appwrite/Models/DedicatedDatabaseSpecification.php +++ b/src/Appwrite/Models/DedicatedDatabaseSpecification.php @@ -19,31 +19,31 @@ * @param string $slug specification slug. use this value when creating a dedicated database. * @param string $name human readable specification name. * @param float $price monthly price of the specification in usd. + * @param float $storageOverageRate price per gb of storage above the included amount, per month, in usd. + * @param float $bandwidthOverageRate price per gb of bandwidth above the included amount, per month, in usd. + * @param float $replicaRate high availability replica price as a fraction of the specification price. + * @param float $pitrRate point-in-time recovery price as a fraction of the specification price. * @param int $cpu allocated cpu in millicores. * @param int $memory allocated memory in mb. * @param int $maxConnections maximum number of concurrent connections. * @param int $includedStorage included storage in gb before overage charges apply. * @param int $includedBandwidth included bandwidth in gb before overage charges apply. * @param bool $enabled whether the specification is available on the current plan. - * @param float|null $storageOverageRate price per gb of storage above the included amount, per month, in usd. - * @param float|null $bandwidthOverageRate price per gb of bandwidth above the included amount, per month, in usd. - * @param float|null $replicaRate high availability replica price as a fraction of the specification price. - * @param float|null $pitrRate point-in-time recovery price as a fraction of the specification price. */ public function __construct( public string $slug, public string $name, public float $price, + public float $storageOverageRate, + public float $bandwidthOverageRate, + public float $replicaRate, + public float $pitrRate, public int $cpu, public int $memory, public int $maxConnections, public int $includedStorage, public int $includedBandwidth, - public bool $enabled, - public ?float $storageOverageRate = null, - public ?float $bandwidthOverageRate = null, - public ?float $replicaRate = null, - public ?float $pitrRate = null + public bool $enabled ) { } @@ -56,6 +56,10 @@ public static function from(array $data): static 'slug' => "", 'name' => "", 'price' => 0, + 'storageOverageRate' => 0, + 'bandwidthOverageRate' => 0, + 'replicaRate' => 0, + 'pitrRate' => 0, 'cpu' => 0, 'memory' => 0, 'maxConnections' => 0, @@ -68,16 +72,16 @@ public static function from(array $data): static slug: $data['slug'], name: $data['name'], price: $data['price'], + storageOverageRate: $data['storageOverageRate'], + bandwidthOverageRate: $data['bandwidthOverageRate'], + replicaRate: $data['replicaRate'], + pitrRate: $data['pitrRate'], cpu: $data['cpu'], memory: $data['memory'], maxConnections: $data['maxConnections'], includedStorage: $data['includedStorage'], includedBandwidth: $data['includedBandwidth'], - enabled: $data['enabled'], - storageOverageRate: $data['storageOverageRate'] ?? null, - bandwidthOverageRate: $data['bandwidthOverageRate'] ?? null, - replicaRate: $data['replicaRate'] ?? null, - pitrRate: $data['pitrRate'] ?? null + enabled: $data['enabled'] ); } diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php b/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php index 9ac12067..3f3aca02 100644 --- a/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php +++ b/src/Appwrite/Models/DedicatedDatabaseSpecificationList.php @@ -18,12 +18,10 @@ * * @param list $specifications list of dedicated database specifications. * @param int $total total number of specifications. - * @param DedicatedDatabaseSpecificationPricing $pricing overage and add-on pricing shared across all specifications. */ public function __construct( public array $specifications, - public int $total, - public DedicatedDatabaseSpecificationPricing $pricing + public int $total ) { } @@ -33,16 +31,10 @@ public function __construct( public static function from(array $data): static { $data += [ + 'specifications' => [], 'total' => 0, ]; - if (!array_key_exists('specifications', $data)) { - throw new \InvalidArgumentException('Missing required field "specifications" for ' . static::class . '.'); - } - if (!array_key_exists('pricing', $data)) { - throw new \InvalidArgumentException('Missing required field "pricing" for ' . static::class . '.'); - } - return new static( specifications: is_array($data['specifications']) ? array_map( @@ -50,8 +42,7 @@ public static function from(array $data): static $data['specifications'] ) : $data['specifications'], - total: $data['total'], - pricing: static::hydrateTypedValue(DedicatedDatabaseSpecificationPricing::class, $data['pricing']) + total: $data['total'] ); } @@ -62,8 +53,7 @@ public function toArray(): array { return [ 'specifications' => static::serializeValue($this->specifications), - 'total' => static::serializeValue($this->total), - 'pricing' => static::serializeValue($this->pricing) + 'total' => static::serializeValue($this->total) ]; } } diff --git a/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php b/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php deleted file mode 100644 index c8a11f5f..00000000 --- a/src/Appwrite/Models/DedicatedDatabaseSpecificationPricing.php +++ /dev/null @@ -1,70 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('storageOverageRate', $data)) { - throw new \InvalidArgumentException('Missing required field "storageOverageRate" for ' . static::class . '.'); - } - if (!array_key_exists('bandwidthOverageRate', $data)) { - throw new \InvalidArgumentException('Missing required field "bandwidthOverageRate" for ' . static::class . '.'); - } - if (!array_key_exists('replicaRate', $data)) { - throw new \InvalidArgumentException('Missing required field "replicaRate" for ' . static::class . '.'); - } - if (!array_key_exists('pitrRate', $data)) { - throw new \InvalidArgumentException('Missing required field "pitrRate" for ' . static::class . '.'); - } - - return new static( - storageOverageRate: $data['storageOverageRate'], - bandwidthOverageRate: $data['bandwidthOverageRate'], - replicaRate: $data['replicaRate'], - pitrRate: $data['pitrRate'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'storageOverageRate' => static::serializeValue($this->storageOverageRate), - 'bandwidthOverageRate' => static::serializeValue($this->bandwidthOverageRate), - 'replicaRate' => static::serializeValue($this->replicaRate), - 'pitrRate' => static::serializeValue($this->pitrRate) - ]; - } -} diff --git a/src/Appwrite/Models/DeploymentList.php b/src/Appwrite/Models/DeploymentList.php index 84e99d1e..cd39aa38 100644 --- a/src/Appwrite/Models/DeploymentList.php +++ b/src/Appwrite/Models/DeploymentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'deployments' => [], ]; - if (!array_key_exists('deployments', $data)) { - throw new \InvalidArgumentException('Missing required field "deployments" for ' . static::class . '.'); - } - return new static( total: $data['total'], deployments: is_array($data['deployments']) diff --git a/src/Appwrite/Models/DevKey.php b/src/Appwrite/Models/DevKey.php deleted file mode 100644 index 971c16fa..00000000 --- a/src/Appwrite/Models/DevKey.php +++ /dev/null @@ -1,98 +0,0 @@ - $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('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - - return new static( - id: $data['$id'], - createdAt: $data['$createdAt'], - updatedAt: $data['$updatedAt'], - name: $data['name'], - expire: $data['expire'], - secret: $data['secret'], - accessedAt: $data['accessedAt'], - sdks: $data['sdks'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - '$id' => static::serializeValue($this->id), - '$createdAt' => static::serializeValue($this->createdAt), - '$updatedAt' => static::serializeValue($this->updatedAt), - 'name' => static::serializeValue($this->name), - 'expire' => static::serializeValue($this->expire), - 'secret' => static::serializeValue($this->secret), - 'accessedAt' => static::serializeValue($this->accessedAt), - 'sdks' => static::serializeValue($this->sdks) - ]; - } -} diff --git a/src/Appwrite/Models/Document.php b/src/Appwrite/Models/Document.php index b0cf5b9c..fa1231f8 100644 --- a/src/Appwrite/Models/Document.php +++ b/src/Appwrite/Models/Document.php @@ -49,12 +49,9 @@ public static function from(array $data): static '$databaseId' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - $additionalProperties = static::extractAdditionalPropertiesFromFields( $data, [ diff --git a/src/Appwrite/Models/DocumentList.php b/src/Appwrite/Models/DocumentList.php index 8a34e498..68bfb14e 100644 --- a/src/Appwrite/Models/DocumentList.php +++ b/src/Appwrite/Models/DocumentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'documents' => [], ]; - if (!array_key_exists('documents', $data)) { - throw new \InvalidArgumentException('Missing required field "documents" for ' . static::class . '.'); - } - return new static( total: $data['total'], documents: is_array($data['documents']) diff --git a/src/Appwrite/Models/EmailTemplateList.php b/src/Appwrite/Models/EmailTemplateList.php index 934220ab..015cc0db 100644 --- a/src/Appwrite/Models/EmailTemplateList.php +++ b/src/Appwrite/Models/EmailTemplateList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'templates' => [], ]; - if (!array_key_exists('templates', $data)) { - throw new \InvalidArgumentException('Missing required field "templates" for ' . static::class . '.'); - } - return new static( total: $data['total'], templates: is_array($data['templates']) diff --git a/src/Appwrite/Models/EmbeddingList.php b/src/Appwrite/Models/EmbeddingList.php index dde35f28..7e362a18 100644 --- a/src/Appwrite/Models/EmbeddingList.php +++ b/src/Appwrite/Models/EmbeddingList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'embeddings' => [], ]; - if (!array_key_exists('embeddings', $data)) { - throw new \InvalidArgumentException('Missing required field "embeddings" for ' . static::class . '.'); - } - return new static( total: $data['total'], embeddings: is_array($data['embeddings']) diff --git a/src/Appwrite/Models/EphemeralKey.php b/src/Appwrite/Models/EphemeralKey.php index 0709c91c..c338f61e 100644 --- a/src/Appwrite/Models/EphemeralKey.php +++ b/src/Appwrite/Models/EphemeralKey.php @@ -53,12 +53,9 @@ public static function from(array $data): static 'scopes' => [], 'secret' => "", 'accessedAt' => "", + 'sdks' => [], ]; - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/Execution.php b/src/Appwrite/Models/Execution.php index 8ac7d6fa..1b462770 100644 --- a/src/Appwrite/Models/Execution.php +++ b/src/Appwrite/Models/Execution.php @@ -27,7 +27,7 @@ * @param string $resourceId function or site id. * @param ExecutionResourceType $resourceType execution resource type. * @param string $deploymentId deployment id used to create the execution. - * @param ExecutionTrigger $trigger the trigger that caused the resource to execute. possible values can be: `http`, `schedule`, or `event`. + * @param ExecutionTrigger $trigger the trigger that caused the resource to execute. possible values can be: `http`, `schedule`, `event`, or `email`. * @param ExecutionStatus $status the status of the resource execution. possible values can be: `waiting`, `processing`, `completed`, `failed`, or `scheduled`. * @param string $requestMethod http request method type. * @param string $requestPath http request path and query. @@ -37,7 +37,7 @@ * @param list $responseHeaders http response headers as a key-value object. this will return only whitelisted headers. all headers are returned if execution is created as synchronous. * @param string $logs resource logs. includes the last 4,000 characters. this will return an empty string unless the response is returned using an api key or as part of a webhook payload. * @param string $errors resource errors. includes the last 4,000 characters. this will return an empty string unless the response is returned using an api key or as part of a webhook payload. - * @param float $duration resource(function/site) execution duration in seconds. + * @param float $duration total time the resource(function/site) took to respond, in seconds. * @param string|null $scheduledAt the scheduled time for execution. if left empty, execution will be queued immediately. */ public function __construct( @@ -72,33 +72,27 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'resourceId' => "", 'resourceType' => "functions", 'deploymentId' => "", 'requestMethod' => "", 'requestPath' => "", + 'requestHeaders' => [], 'responseStatusCode' => 0, 'responseBody' => "", + 'responseHeaders' => [], 'logs' => "", 'errors' => "", 'duration' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } if (!array_key_exists('trigger', $data)) { throw new \InvalidArgumentException('Missing required field "trigger" for ' . static::class . '.'); } if (!array_key_exists('status', $data)) { throw new \InvalidArgumentException('Missing required field "status" for ' . static::class . '.'); } - if (!array_key_exists('requestHeaders', $data)) { - throw new \InvalidArgumentException('Missing required field "requestHeaders" for ' . static::class . '.'); - } - if (!array_key_exists('responseHeaders', $data)) { - throw new \InvalidArgumentException('Missing required field "responseHeaders" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/ExecutionList.php b/src/Appwrite/Models/ExecutionList.php index ee91c286..2b164511 100644 --- a/src/Appwrite/Models/ExecutionList.php +++ b/src/Appwrite/Models/ExecutionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'executions' => [], ]; - if (!array_key_exists('executions', $data)) { - throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.'); - } - return new static( total: $data['total'], executions: is_array($data['executions']) diff --git a/src/Appwrite/Models/FileList.php b/src/Appwrite/Models/FileList.php index f934a390..cab60fc5 100644 --- a/src/Appwrite/Models/FileList.php +++ b/src/Appwrite/Models/FileList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'files' => [], ]; - if (!array_key_exists('files', $data)) { - throw new \InvalidArgumentException('Missing required field "files" for ' . static::class . '.'); - } - return new static( total: $data['total'], files: is_array($data['files']) diff --git a/src/Appwrite/Models/Framework.php b/src/Appwrite/Models/Framework.php index 7c3efaff..20a43d42 100644 --- a/src/Appwrite/Models/Framework.php +++ b/src/Appwrite/Models/Framework.php @@ -40,15 +40,10 @@ public static function from(array $data): static 'key' => "", 'name' => "", 'buildRuntime' => "", + 'runtimes' => [], + 'adapters' => [], ]; - if (!array_key_exists('runtimes', $data)) { - throw new \InvalidArgumentException('Missing required field "runtimes" for ' . static::class . '.'); - } - if (!array_key_exists('adapters', $data)) { - throw new \InvalidArgumentException('Missing required field "adapters" for ' . static::class . '.'); - } - return new static( key: $data['key'], name: $data['name'], diff --git a/src/Appwrite/Models/FrameworkList.php b/src/Appwrite/Models/FrameworkList.php index 8188732e..9397daa1 100644 --- a/src/Appwrite/Models/FrameworkList.php +++ b/src/Appwrite/Models/FrameworkList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'frameworks' => [], ]; - if (!array_key_exists('frameworks', $data)) { - throw new \InvalidArgumentException('Missing required field "frameworks" for ' . static::class . '.'); - } - return new static( total: $data['total'], frameworks: is_array($data['frameworks']) diff --git a/src/Appwrite/Models/FunctionList.php b/src/Appwrite/Models/FunctionList.php index e5f38db1..39fca279 100644 --- a/src/Appwrite/Models/FunctionList.php +++ b/src/Appwrite/Models/FunctionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'functions' => [], ]; - if (!array_key_exists('functions', $data)) { - throw new \InvalidArgumentException('Missing required field "functions" for ' . static::class . '.'); - } - return new static( total: $data['total'], functions: is_array($data['functions']) diff --git a/src/Appwrite/Models/FunctionModel.php b/src/Appwrite/Models/FunctionModel.php index a6fbc219..900ce96b 100644 --- a/src/Appwrite/Models/FunctionModel.php +++ b/src/Appwrite/Models/FunctionModel.php @@ -48,6 +48,7 @@ * @param array $providerPaths list of file path patterns that trigger automatic deployments. supports glob wildcards. empty list deploys on all file changes. * @param string $buildSpecification machine specification for deployment builds. * @param string $runtimeSpecification machine specification for executions. + * @param bool $emailEnabled whether inbound email (smtp) may trigger this function. opt-in; default is false. when disabled, recipients for this function are rejected. * @param int|null $interval minutes between scheduled executions. 0 when the function has no interval. */ public function __construct( @@ -83,6 +84,7 @@ public function __construct( public array $providerPaths, public string $buildSpecification, public string $runtimeSpecification, + public bool $emailEnabled, public ?int $interval = null ) { } @@ -109,6 +111,7 @@ public static function from(array $data): static 'latestDeploymentCreatedAt' => "", 'latestDeploymentStatus' => "", 'scopes' => [], + 'vars' => [], 'events' => [], 'schedule' => "", 'timeout' => 15, @@ -124,12 +127,9 @@ public static function from(array $data): static 'providerPaths' => [], 'buildSpecification' => "s-1vcpu-512mb", 'runtimeSpecification' => "s-1vcpu-512mb", + 'emailEnabled' => false, ]; - if (!array_key_exists('vars', $data)) { - throw new \InvalidArgumentException('Missing required field "vars" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], @@ -168,6 +168,7 @@ public static function from(array $data): static providerPaths: $data['providerPaths'], buildSpecification: $data['buildSpecification'], runtimeSpecification: $data['runtimeSpecification'], + emailEnabled: $data['emailEnabled'], interval: $data['interval'] ?? null ); } @@ -210,7 +211,8 @@ public function toArray(): array 'providerBranches' => static::serializeValue($this->providerBranches), 'providerPaths' => static::serializeValue($this->providerPaths), 'buildSpecification' => static::serializeValue($this->buildSpecification), - 'runtimeSpecification' => static::serializeValue($this->runtimeSpecification) + 'runtimeSpecification' => static::serializeValue($this->runtimeSpecification), + 'emailEnabled' => static::serializeValue($this->emailEnabled) ]; } } diff --git a/src/Appwrite/Models/Identity.php b/src/Appwrite/Models/Identity.php index 7b208ff5..d7cc7c47 100644 --- a/src/Appwrite/Models/Identity.php +++ b/src/Appwrite/Models/Identity.php @@ -26,7 +26,7 @@ * @param string $providerAccessToken identity provider access token. * @param string $providerAccessTokenExpiry the date of when the access token expires in iso 8601 format. * @param string $providerRefreshToken identity provider refresh token. - * @param string|null $providerIdToken identity provider id token (jwt) from the most recent native sign-in. empty for identities created through the browser oauth2 flow. + * @param string $providerIdToken identity provider id token (jwt) from the most recent native sign-in. empty for identities created through the browser oauth2 flow. */ public function __construct( public string $id, @@ -39,7 +39,7 @@ public function __construct( public string $providerAccessToken, public string $providerAccessTokenExpiry, public string $providerRefreshToken, - public ?string $providerIdToken = null + public string $providerIdToken ) { } @@ -59,6 +59,7 @@ public static function from(array $data): static 'providerAccessToken' => "", 'providerAccessTokenExpiry' => "", 'providerRefreshToken' => "", + 'providerIdToken' => "", ]; return new static( @@ -72,7 +73,7 @@ public static function from(array $data): static providerAccessToken: $data['providerAccessToken'], providerAccessTokenExpiry: $data['providerAccessTokenExpiry'], providerRefreshToken: $data['providerRefreshToken'], - providerIdToken: $data['providerIdToken'] ?? null + providerIdToken: $data['providerIdToken'] ); } diff --git a/src/Appwrite/Models/IdentityList.php b/src/Appwrite/Models/IdentityList.php index f16cced6..d999ce18 100644 --- a/src/Appwrite/Models/IdentityList.php +++ b/src/Appwrite/Models/IdentityList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'identities' => [], ]; - if (!array_key_exists('identities', $data)) { - throw new \InvalidArgumentException('Missing required field "identities" for ' . static::class . '.'); - } - return new static( total: $data['total'], identities: is_array($data['identities']) diff --git a/src/Appwrite/Models/IndexList.php b/src/Appwrite/Models/IndexList.php index 4f2fbb8e..b9c1b65d 100644 --- a/src/Appwrite/Models/IndexList.php +++ b/src/Appwrite/Models/IndexList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'indexes' => [], ]; - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( total: $data['total'], indexes: is_array($data['indexes']) diff --git a/src/Appwrite/Models/Insight.php b/src/Appwrite/Models/Insight.php index b5b50f95..f05df485 100644 --- a/src/Appwrite/Models/Insight.php +++ b/src/Appwrite/Models/Insight.php @@ -74,12 +74,9 @@ public static function from(array $data): static 'parentResourceId' => "", 'title' => "", 'summary' => "", + 'ctas' => [], ]; - if (!array_key_exists('ctas', $data)) { - throw new \InvalidArgumentException('Missing required field "ctas" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/InsightList.php b/src/Appwrite/Models/InsightList.php index dfa3e4a9..3eee4fe6 100644 --- a/src/Appwrite/Models/InsightList.php +++ b/src/Appwrite/Models/InsightList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'insights' => [], ]; - if (!array_key_exists('insights', $data)) { - throw new \InvalidArgumentException('Missing required field "insights" for ' . static::class . '.'); - } - return new static( total: $data['total'], insights: is_array($data['insights']) diff --git a/src/Appwrite/Models/Key.php b/src/Appwrite/Models/Key.php index 216deb87..6b8e6841 100644 --- a/src/Appwrite/Models/Key.php +++ b/src/Appwrite/Models/Key.php @@ -53,12 +53,9 @@ public static function from(array $data): static 'scopes' => [], 'secret' => "", 'accessedAt' => "", + 'sdks' => [], ]; - if (!array_key_exists('sdks', $data)) { - throw new \InvalidArgumentException('Missing required field "sdks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/KeyList.php b/src/Appwrite/Models/KeyList.php index 042450fb..92c164b9 100644 --- a/src/Appwrite/Models/KeyList.php +++ b/src/Appwrite/Models/KeyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'keys' => [], ]; - if (!array_key_exists('keys', $data)) { - throw new \InvalidArgumentException('Missing required field "keys" for ' . static::class . '.'); - } - return new static( total: $data['total'], keys: is_array($data['keys']) diff --git a/src/Appwrite/Models/LanguageList.php b/src/Appwrite/Models/LanguageList.php index 6a57c4b8..7cf1275f 100644 --- a/src/Appwrite/Models/LanguageList.php +++ b/src/Appwrite/Models/LanguageList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'languages' => [], ]; - if (!array_key_exists('languages', $data)) { - throw new \InvalidArgumentException('Missing required field "languages" for ' . static::class . '.'); - } - return new static( total: $data['total'], languages: is_array($data['languages']) diff --git a/src/Appwrite/Models/LocaleCodeList.php b/src/Appwrite/Models/LocaleCodeList.php index 59223a66..a9f1dfcd 100644 --- a/src/Appwrite/Models/LocaleCodeList.php +++ b/src/Appwrite/Models/LocaleCodeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'localeCodes' => [], ]; - if (!array_key_exists('localeCodes', $data)) { - throw new \InvalidArgumentException('Missing required field "localeCodes" for ' . static::class . '.'); - } - return new static( total: $data['total'], localeCodes: is_array($data['localeCodes']) diff --git a/src/Appwrite/Models/Log.php b/src/Appwrite/Models/Log.php deleted file mode 100644 index 01bfb02f..00000000 --- a/src/Appwrite/Models/Log.php +++ /dev/null @@ -1,196 +0,0 @@ - $data - */ - public static function from(array $data): static - { - if (!array_key_exists('event', $data)) { - throw new \InvalidArgumentException('Missing required field "event" for ' . static::class . '.'); - } - if (!array_key_exists('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('userEmail', $data)) { - throw new \InvalidArgumentException('Missing required field "userEmail" for ' . static::class . '.'); - } - if (!array_key_exists('userName', $data)) { - throw new \InvalidArgumentException('Missing required field "userName" for ' . static::class . '.'); - } - if (!array_key_exists('mode', $data)) { - throw new \InvalidArgumentException('Missing required field "mode" for ' . static::class . '.'); - } - if (!array_key_exists('userType', $data)) { - throw new \InvalidArgumentException('Missing required field "userType" for ' . static::class . '.'); - } - if (!array_key_exists('ip', $data)) { - throw new \InvalidArgumentException('Missing required field "ip" for ' . static::class . '.'); - } - if (!array_key_exists('time', $data)) { - throw new \InvalidArgumentException('Missing required field "time" for ' . static::class . '.'); - } - if (!array_key_exists('osCode', $data)) { - throw new \InvalidArgumentException('Missing required field "osCode" for ' . static::class . '.'); - } - if (!array_key_exists('osName', $data)) { - throw new \InvalidArgumentException('Missing required field "osName" for ' . static::class . '.'); - } - if (!array_key_exists('osVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "osVersion" for ' . static::class . '.'); - } - if (!array_key_exists('clientType', $data)) { - throw new \InvalidArgumentException('Missing required field "clientType" for ' . static::class . '.'); - } - if (!array_key_exists('clientCode', $data)) { - throw new \InvalidArgumentException('Missing required field "clientCode" for ' . static::class . '.'); - } - if (!array_key_exists('clientName', $data)) { - throw new \InvalidArgumentException('Missing required field "clientName" for ' . static::class . '.'); - } - if (!array_key_exists('clientVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "clientVersion" for ' . static::class . '.'); - } - if (!array_key_exists('clientEngine', $data)) { - throw new \InvalidArgumentException('Missing required field "clientEngine" for ' . static::class . '.'); - } - if (!array_key_exists('clientEngineVersion', $data)) { - throw new \InvalidArgumentException('Missing required field "clientEngineVersion" for ' . static::class . '.'); - } - if (!array_key_exists('deviceName', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceName" for ' . static::class . '.'); - } - if (!array_key_exists('deviceBrand', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceBrand" for ' . static::class . '.'); - } - if (!array_key_exists('deviceModel', $data)) { - throw new \InvalidArgumentException('Missing required field "deviceModel" 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( - event: $data['event'], - userId: $data['userId'], - userEmail: $data['userEmail'], - userName: $data['userName'], - mode: $data['mode'], - userType: $data['userType'], - ip: $data['ip'], - time: $data['time'], - osCode: $data['osCode'], - osName: $data['osName'], - osVersion: $data['osVersion'], - clientType: $data['clientType'], - clientCode: $data['clientCode'], - clientName: $data['clientName'], - clientVersion: $data['clientVersion'], - clientEngine: $data['clientEngine'], - clientEngineVersion: $data['clientEngineVersion'], - deviceName: $data['deviceName'], - deviceBrand: $data['deviceBrand'], - deviceModel: $data['deviceModel'], - countryCode: $data['countryCode'], - countryName: $data['countryName'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'event' => static::serializeValue($this->event), - 'userId' => static::serializeValue($this->userId), - 'userEmail' => static::serializeValue($this->userEmail), - 'userName' => static::serializeValue($this->userName), - 'mode' => static::serializeValue($this->mode), - 'userType' => static::serializeValue($this->userType), - 'ip' => static::serializeValue($this->ip), - 'time' => static::serializeValue($this->time), - 'osCode' => static::serializeValue($this->osCode), - 'osName' => static::serializeValue($this->osName), - 'osVersion' => static::serializeValue($this->osVersion), - 'clientType' => static::serializeValue($this->clientType), - 'clientCode' => static::serializeValue($this->clientCode), - 'clientName' => static::serializeValue($this->clientName), - 'clientVersion' => static::serializeValue($this->clientVersion), - 'clientEngine' => static::serializeValue($this->clientEngine), - 'clientEngineVersion' => static::serializeValue($this->clientEngineVersion), - 'deviceName' => static::serializeValue($this->deviceName), - 'deviceBrand' => static::serializeValue($this->deviceBrand), - 'deviceModel' => static::serializeValue($this->deviceModel), - 'countryCode' => static::serializeValue($this->countryCode), - 'countryName' => static::serializeValue($this->countryName) - ]; - } -} diff --git a/src/Appwrite/Models/LogList.php b/src/Appwrite/Models/LogList.php deleted file mode 100644 index 944b82ca..00000000 --- a/src/Appwrite/Models/LogList.php +++ /dev/null @@ -1,61 +0,0 @@ - $logs list of logs. - */ - public function __construct( - public int $total, - public array $logs - ) { - } - - /** - * @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('logs', $data)) { - throw new \InvalidArgumentException('Missing required field "logs" for ' . static::class . '.'); - } - - return new static( - total: $data['total'], - logs: is_array($data['logs']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(Log::class, $item), - $data['logs'] - ) - : $data['logs'] - ); - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'total' => static::serializeValue($this->total), - 'logs' => static::serializeValue($this->logs) - ]; - } -} diff --git a/src/Appwrite/Models/MembershipList.php b/src/Appwrite/Models/MembershipList.php index 48529162..ece0e4b1 100644 --- a/src/Appwrite/Models/MembershipList.php +++ b/src/Appwrite/Models/MembershipList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'memberships' => [], ]; - if (!array_key_exists('memberships', $data)) { - throw new \InvalidArgumentException('Missing required field "memberships" for ' . static::class . '.'); - } - return new static( total: $data['total'], memberships: is_array($data['memberships']) diff --git a/src/Appwrite/Models/Message.php b/src/Appwrite/Models/Message.php index 267901bc..3d6ea590 100644 --- a/src/Appwrite/Models/Message.php +++ b/src/Appwrite/Models/Message.php @@ -59,21 +59,14 @@ public static function from(array $data): static '$createdAt' => "", '$updatedAt' => "", 'providerType' => "", + 'topics' => [], + 'users' => [], + 'targets' => [], 'deliveredTotal' => 0, 'data' => [], 'status' => "draft", ]; - if (!array_key_exists('topics', $data)) { - throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); - } - if (!array_key_exists('users', $data)) { - throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); - } - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/MessageList.php b/src/Appwrite/Models/MessageList.php index ea36b3e9..0f341543 100644 --- a/src/Appwrite/Models/MessageList.php +++ b/src/Appwrite/Models/MessageList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'messages' => [], ]; - if (!array_key_exists('messages', $data)) { - throw new \InvalidArgumentException('Missing required field "messages" for ' . static::class . '.'); - } - return new static( total: $data['total'], messages: is_array($data['messages']) diff --git a/src/Appwrite/Models/MockNumberList.php b/src/Appwrite/Models/MockNumberList.php index 60291620..b444d1b0 100644 --- a/src/Appwrite/Models/MockNumberList.php +++ b/src/Appwrite/Models/MockNumberList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'mockNumbers' => [], ]; - if (!array_key_exists('mockNumbers', $data)) { - throw new \InvalidArgumentException('Missing required field "mockNumbers" for ' . static::class . '.'); - } - return new static( total: $data['total'], mockNumbers: is_array($data['mockNumbers']) diff --git a/src/Appwrite/Models/OAuth2Apple.php b/src/Appwrite/Models/OAuth2Apple.php index 91b6b61c..0e9d8915 100644 --- a/src/Appwrite/Models/OAuth2Apple.php +++ b/src/Appwrite/Models/OAuth2Apple.php @@ -22,8 +22,8 @@ * @param string $keyId apple oauth2 key id. * @param string $teamId apple oauth2 team id. * @param string $p8File apple oauth2 .p8 private key file contents. the secret key wrapped by the pem markers is 200 characters long. - * @param bool|null $nativeEnabled native sign in with apple is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. - * @param array|null $nativeClientIds app bundle ids accepted as id token audiences for native sign in with apple, next to the services id. + * @param bool $nativeEnabled native sign in with apple is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. + * @param array $nativeClientIds app bundle ids accepted as id token audiences for native sign in with apple, next to the services id. */ public function __construct( public string $id, @@ -32,8 +32,8 @@ public function __construct( public string $keyId, public string $teamId, public string $p8File, - public ?bool $nativeEnabled = null, - public ?array $nativeClientIds = null + public bool $nativeEnabled, + public array $nativeClientIds ) { } @@ -49,6 +49,8 @@ public static function from(array $data): static 'keyId' => "", 'teamId' => "", 'p8File' => "", + 'nativeEnabled' => false, + 'nativeClientIds' => [], ]; return new static( @@ -58,8 +60,8 @@ public static function from(array $data): static keyId: $data['keyId'], teamId: $data['teamId'], p8File: $data['p8File'], - nativeEnabled: $data['nativeEnabled'] ?? null, - nativeClientIds: $data['nativeClientIds'] ?? null + nativeEnabled: $data['nativeEnabled'], + nativeClientIds: $data['nativeClientIds'] ); } diff --git a/src/Appwrite/Models/OAuth2Auth0.php b/src/Appwrite/Models/OAuth2Auth0.php index 2e119529..f76d028f 100644 --- a/src/Appwrite/Models/OAuth2Auth0.php +++ b/src/Appwrite/Models/OAuth2Auth0.php @@ -22,16 +22,16 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId auth0 oauth2 client id. * @param string $clientSecret auth0 oauth2 client secret. + * @param list $prompt auth0 oauth2 prompt values. * @param string $endpoint auth0 oauth2 endpoint domain. - * @param list|null $prompt auth0 oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public string $endpoint, - public ?array $prompt = null + public array $prompt, + public string $endpoint ) { } @@ -45,6 +45,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'endpoint' => "", ]; @@ -53,17 +54,13 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - endpoint: $data['endpoint'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2Auth0Prompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2Auth0Prompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2Auth0Prompt::class, $data['prompt'])], + endpoint: $data['endpoint'] ); } diff --git a/src/Appwrite/Models/OAuth2Discord.php b/src/Appwrite/Models/OAuth2Discord.php index 34d4d3d0..ce554f36 100644 --- a/src/Appwrite/Models/OAuth2Discord.php +++ b/src/Appwrite/Models/OAuth2Discord.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId discord oauth2 client id. * @param string $clientSecret discord oauth2 client secret. - * @param list|null $prompt discord oauth2 prompt values. + * @param list $prompt discord oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2DiscordPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2DiscordPrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2DiscordPrompt::class, $data['prompt'])] ); } diff --git a/src/Appwrite/Models/OAuth2Github.php b/src/Appwrite/Models/OAuth2Github.php index 3e40437f..b7b2e1c0 100644 --- a/src/Appwrite/Models/OAuth2Github.php +++ b/src/Appwrite/Models/OAuth2Github.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId github oauth2 client id. for github apps, use the "app id" when both an app id and client id are available. * @param string $clientSecret github oauth2 client secret. - * @param list|null $prompt github oauth2 prompt values. + * @param list $prompt github oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GithubPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GithubPrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2GithubPrompt::class, $data['prompt'])] ); } diff --git a/src/Appwrite/Models/OAuth2Google.php b/src/Appwrite/Models/OAuth2Google.php index ac2a6bef..8f6e47b8 100644 --- a/src/Appwrite/Models/OAuth2Google.php +++ b/src/Appwrite/Models/OAuth2Google.php @@ -23,8 +23,8 @@ * @param string $clientId google oauth2 client id. * @param string $clientSecret google oauth2 client secret. * @param list $prompt google oauth2 prompt values. - * @param bool|null $nativeEnabled native google sign-in is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. - * @param array|null $nativeClientIds additional oauth2 client ids accepted as id token audiences for native sign-in, next to the client id. + * @param bool $nativeEnabled native google sign-in is active and can be used to create sessions from an id token. independent of enabled, which only controls the browser-based flow. + * @param array $nativeClientIds additional oauth2 client ids accepted as id token audiences for native sign-in, next to the client id. */ public function __construct( public string $id, @@ -32,8 +32,8 @@ public function __construct( public string $clientId, public string $clientSecret, public array $prompt, - public ?bool $nativeEnabled = null, - public ?array $nativeClientIds = null + public bool $nativeEnabled, + public array $nativeClientIds ) { } @@ -48,6 +48,8 @@ public static function from(array $data): static 'clientId' => "", 'clientSecret' => "", 'prompt' => ["consent"], + 'nativeEnabled' => false, + 'nativeClientIds' => [], ]; return new static( @@ -60,9 +62,9 @@ public static function from(array $data): static static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GooglePrompt::class, $item), $data['prompt'] ) - : $data['prompt'], - nativeEnabled: $data['nativeEnabled'] ?? null, - nativeClientIds: $data['nativeClientIds'] ?? null + : [static::hydrateTypedValue(OAuth2GooglePrompt::class, $data['prompt'])], + nativeEnabled: $data['nativeEnabled'], + nativeClientIds: $data['nativeClientIds'] ); } diff --git a/src/Appwrite/Models/OAuth2Kakao.php b/src/Appwrite/Models/OAuth2Kakao.php index 2d329b74..c1f3264d 100644 --- a/src/Appwrite/Models/OAuth2Kakao.php +++ b/src/Appwrite/Models/OAuth2Kakao.php @@ -56,7 +56,7 @@ public static function from(array $data): static static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2KakaoPrompt::class, $item), $data['prompt'] ) - : $data['prompt'] + : [static::hydrateTypedValue(OAuth2KakaoPrompt::class, $data['prompt'])] ); } diff --git a/src/Appwrite/Models/OAuth2Microsoft.php b/src/Appwrite/Models/OAuth2Microsoft.php index 12cddc22..ad51fd2c 100644 --- a/src/Appwrite/Models/OAuth2Microsoft.php +++ b/src/Appwrite/Models/OAuth2Microsoft.php @@ -22,16 +22,16 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $applicationId microsoft oauth2 application id. * @param string $applicationSecret microsoft oauth2 application secret. + * @param list $prompt microsoft oauth2 prompt values. * @param string $tenant microsoft entra id tenant identifier. use 'common', 'organizations', 'consumers' or a specific tenant id. - * @param list|null $prompt microsoft oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $applicationId, public string $applicationSecret, - public string $tenant, - public ?array $prompt = null + public array $prompt, + public string $tenant ) { } @@ -45,6 +45,7 @@ public static function from(array $data): static 'enabled' => false, 'applicationId' => "", 'applicationSecret' => "", + 'prompt' => [], 'tenant' => "", ]; @@ -53,17 +54,13 @@ public static function from(array $data): static enabled: $data['enabled'], applicationId: $data['applicationId'], applicationSecret: $data['applicationSecret'], - tenant: $data['tenant'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2MicrosoftPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2MicrosoftPrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2MicrosoftPrompt::class, $data['prompt'])], + tenant: $data['tenant'] ); } diff --git a/src/Appwrite/Models/OAuth2Oidc.php b/src/Appwrite/Models/OAuth2Oidc.php index 3f4a32f6..a7602e43 100644 --- a/src/Appwrite/Models/OAuth2Oidc.php +++ b/src/Appwrite/Models/OAuth2Oidc.php @@ -22,11 +22,11 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId openid connect oauth2 client id. * @param string $clientSecret openid connect oauth2 client secret. + * @param list $prompt openid connect prompt values controlling the authentication and consent screens. * @param string $wellKnownURL openid connect well-known configuration url. when set, authorization, token, and user info endpoints can be discovered automatically. * @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( @@ -34,11 +34,11 @@ public function __construct( public bool $enabled, public string $clientId, public string $clientSecret, + public array $prompt, public string $wellKnownURL, public string $authorizationURL, public string $tokenURL, public string $userInfoURL, - public array $prompt, public ?int $maxAge = null ) { } @@ -53,11 +53,11 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'wellKnownURL' => "", 'authorizationURL' => "", 'tokenURL' => "", 'userInfoURL' => "", - 'prompt' => [], ]; return new static( @@ -65,16 +65,16 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - wellKnownURL: $data['wellKnownURL'], - authorizationURL: $data['authorizationURL'], - tokenURL: $data['tokenURL'], - userInfoURL: $data['userInfoURL'], prompt: is_array($data['prompt']) ? array_map( static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OidcPrompt::class, $item), $data['prompt'] ) - : $data['prompt'], + : [static::hydrateTypedValue(OAuth2OidcPrompt::class, $data['prompt'])], + wellKnownURL: $data['wellKnownURL'], + authorizationURL: $data['authorizationURL'], + tokenURL: $data['tokenURL'], + userInfoURL: $data['userInfoURL'], maxAge: $data['maxAge'] ?? null ); } @@ -89,11 +89,11 @@ public function toArray(): array 'enabled' => static::serializeValue($this->enabled), 'clientId' => static::serializeValue($this->clientId), 'clientSecret' => static::serializeValue($this->clientSecret), + 'prompt' => static::serializeValue($this->prompt), 'wellKnownURL' => static::serializeValue($this->wellKnownURL), 'authorizationURL' => static::serializeValue($this->authorizationURL), 'tokenURL' => static::serializeValue($this->tokenURL), 'userInfoURL' => static::serializeValue($this->userInfoURL), - 'prompt' => static::serializeValue($this->prompt), 'maxAge' => static::serializeValue($this->maxAge) ]; } diff --git a/src/Appwrite/Models/OAuth2Okta.php b/src/Appwrite/Models/OAuth2Okta.php index 10f220af..b5c12a20 100644 --- a/src/Appwrite/Models/OAuth2Okta.php +++ b/src/Appwrite/Models/OAuth2Okta.php @@ -22,18 +22,18 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId okta oauth2 client id. * @param string $clientSecret okta oauth2 client secret. + * @param list $prompt okta oauth2 prompt values. * @param string $domain okta oauth2 domain. * @param string $authorizationServerId okta oauth2 authorization server id. - * @param list|null $prompt okta oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, + public array $prompt, public string $domain, - public string $authorizationServerId, - public ?array $prompt = null + public string $authorizationServerId ) { } @@ -47,6 +47,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], 'domain' => "", 'authorizationServerId' => "", ]; @@ -56,18 +57,14 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - domain: $data['domain'], - authorizationServerId: $data['authorizationServerId'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OktaPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2OktaPrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2OktaPrompt::class, $data['prompt'])], + domain: $data['domain'], + authorizationServerId: $data['authorizationServerId'] ); } diff --git a/src/Appwrite/Models/OAuth2ProviderList.php b/src/Appwrite/Models/OAuth2ProviderList.php index bd2607be..4e278802 100644 --- a/src/Appwrite/Models/OAuth2ProviderList.php +++ b/src/Appwrite/Models/OAuth2ProviderList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'providers' => [], ]; - if (!array_key_exists('providers', $data)) { - throw new \InvalidArgumentException('Missing required field "providers" for ' . static::class . '.'); - } - return new static( total: $data['total'], providers: $data['providers'] diff --git a/src/Appwrite/Models/OAuth2Salesforce.php b/src/Appwrite/Models/OAuth2Salesforce.php index bea4ea61..1317fb68 100644 --- a/src/Appwrite/Models/OAuth2Salesforce.php +++ b/src/Appwrite/Models/OAuth2Salesforce.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $customerKey salesforce oauth2 consumer key. * @param string $customerSecret salesforce oauth2 consumer secret. - * @param list|null $prompt salesforce oauth2 prompt values. + * @param list $prompt salesforce oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $customerKey, public string $customerSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'customerKey' => "", 'customerSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], customerKey: $data['customerKey'], customerSecret: $data['customerSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2SalesforcePrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2SalesforcePrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2SalesforcePrompt::class, $data['prompt'])] ); } diff --git a/src/Appwrite/Models/OAuth2Zoho.php b/src/Appwrite/Models/OAuth2Zoho.php index 31966c63..a8a09e0d 100644 --- a/src/Appwrite/Models/OAuth2Zoho.php +++ b/src/Appwrite/Models/OAuth2Zoho.php @@ -22,14 +22,14 @@ * @param bool $enabled oauth2 provider is active and can be used to create sessions. * @param string $clientId zoho oauth2 client id. * @param string $clientSecret zoho oauth2 client secret. - * @param list|null $prompt zoho oauth2 prompt values. + * @param list $prompt zoho oauth2 prompt values. */ public function __construct( public string $id, public bool $enabled, public string $clientId, public string $clientSecret, - public ?array $prompt = null + public array $prompt ) { } @@ -43,6 +43,7 @@ public static function from(array $data): static 'enabled' => false, 'clientId' => "", 'clientSecret' => "", + 'prompt' => [], ]; return new static( @@ -50,16 +51,12 @@ public static function from(array $data): static enabled: $data['enabled'], clientId: $data['clientId'], clientSecret: $data['clientSecret'], - prompt: array_key_exists('prompt', $data) - ? ( - is_array($data['prompt']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2ZohoPrompt::class, $item), - $data['prompt'] - ) - : $data['prompt'] + prompt: is_array($data['prompt']) + ? array_map( + static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2ZohoPrompt::class, $item), + $data['prompt'] ) - : null + : [static::hydrateTypedValue(OAuth2ZohoPrompt::class, $data['prompt'])] ); } diff --git a/src/Appwrite/Models/Oauth2ConsentList.php b/src/Appwrite/Models/Oauth2ConsentList.php index 5b83a171..1397c04b 100644 --- a/src/Appwrite/Models/Oauth2ConsentList.php +++ b/src/Appwrite/Models/Oauth2ConsentList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'consents' => [], ]; - if (!array_key_exists('consents', $data)) { - throw new \InvalidArgumentException('Missing required field "consents" for ' . static::class . '.'); - } - return new static( total: $data['total'], consents: is_array($data['consents']) diff --git a/src/Appwrite/Models/Oauth2ConsentTokenList.php b/src/Appwrite/Models/Oauth2ConsentTokenList.php index 0a0a7bb4..1b23700d 100644 --- a/src/Appwrite/Models/Oauth2ConsentTokenList.php +++ b/src/Appwrite/Models/Oauth2ConsentTokenList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tokens' => [], ]; - if (!array_key_exists('tokens', $data)) { - throw new \InvalidArgumentException('Missing required field "tokens" for ' . static::class . '.'); - } - return new static( total: $data['total'], tokens: is_array($data['tokens']) diff --git a/src/Appwrite/Models/Oauth2OrganizationList.php b/src/Appwrite/Models/Oauth2OrganizationList.php index 6549f554..c5134675 100644 --- a/src/Appwrite/Models/Oauth2OrganizationList.php +++ b/src/Appwrite/Models/Oauth2OrganizationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'organizations' => [], ]; - if (!array_key_exists('organizations', $data)) { - throw new \InvalidArgumentException('Missing required field "organizations" for ' . static::class . '.'); - } - return new static( total: $data['total'], organizations: is_array($data['organizations']) diff --git a/src/Appwrite/Models/Oauth2ProjectList.php b/src/Appwrite/Models/Oauth2ProjectList.php index 111dda83..ad709350 100644 --- a/src/Appwrite/Models/Oauth2ProjectList.php +++ b/src/Appwrite/Models/Oauth2ProjectList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'projects' => [], ]; - if (!array_key_exists('projects', $data)) { - throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); - } - return new static( total: $data['total'], projects: is_array($data['projects']) diff --git a/src/Appwrite/Models/Organization.php b/src/Appwrite/Models/Organization.php index 569bc18f..dbed5cbc 100644 --- a/src/Appwrite/Models/Organization.php +++ b/src/Appwrite/Models/Organization.php @@ -27,19 +27,19 @@ * @param string $billingPlanId organization's billing plan id. * @param BillingPlan $billingPlanDetails organization's billing plan. * @param string $billingEmail billing email set for the organization. - * @param string $billingStartDate billing cycle start date. - * @param string $billingCurrentInvoiceDate current invoice cycle start date. - * @param string $billingNextInvoiceDate next invoice cycle start date. - * @param int $billingTrialDays number of trial days. - * @param string $billingAggregationId current active aggregation id. - * @param string $billingInvoiceId current active aggregation id. - * @param string $paymentMethodId default payment method. * @param string $status team status. * @param bool $markedForDeletion marked for deletion * @param string $platform product with which the organization is associated (appwrite or imagine) * @param array $projects selected projects * @param int|null $billingBudget project budget limit. null when no budget is set. + * @param string|null $billingStartDate billing cycle start date. + * @param string|null $billingCurrentInvoiceDate current invoice cycle start date. + * @param string|null $billingNextInvoiceDate next invoice cycle start date. * @param string|null $billingTrialStartDate start date of trial. + * @param int|null $billingTrialDays number of trial days. + * @param string|null $billingAggregationId current active aggregation id. + * @param string|null $billingInvoiceId current active aggregation id. + * @param string|null $paymentMethodId default payment method. * @param string|null $billingAddressId default payment method. * @param string|null $backupPaymentMethodId backup payment method. * @param string|null $remarks remarks on team status. @@ -64,19 +64,19 @@ public function __construct( public string $billingPlanId, public BillingPlan $billingPlanDetails, public string $billingEmail, - public string $billingStartDate, - public string $billingCurrentInvoiceDate, - public string $billingNextInvoiceDate, - public int $billingTrialDays, - public string $billingAggregationId, - public string $billingInvoiceId, - public string $paymentMethodId, public string $status, public bool $markedForDeletion, public string $platform, public array $projects, public ?int $billingBudget = null, + public ?string $billingStartDate = null, + public ?string $billingCurrentInvoiceDate = null, + public ?string $billingNextInvoiceDate = null, public ?string $billingTrialStartDate = null, + public ?int $billingTrialDays = null, + public ?string $billingAggregationId = null, + public ?string $billingInvoiceId = null, + public ?string $paymentMethodId = null, public ?string $billingAddressId = null, public ?string $backupPaymentMethodId = null, public ?string $remarks = null, @@ -118,27 +118,6 @@ public static function from(array $data): static if (!array_key_exists('billingPlanDetails', $data)) { throw new \InvalidArgumentException('Missing required field "billingPlanDetails" 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('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 . '.'); - } return new static( id: $data['$id'], @@ -152,19 +131,19 @@ public static function from(array $data): static billingPlanId: $data['billingPlanId'], billingPlanDetails: static::hydrateTypedValue(BillingPlan::class, $data['billingPlanDetails']), billingEmail: $data['billingEmail'], - billingStartDate: $data['billingStartDate'], - billingCurrentInvoiceDate: $data['billingCurrentInvoiceDate'], - billingNextInvoiceDate: $data['billingNextInvoiceDate'], - billingTrialDays: $data['billingTrialDays'], - billingAggregationId: $data['billingAggregationId'], - billingInvoiceId: $data['billingInvoiceId'], - paymentMethodId: $data['paymentMethodId'], status: $data['status'], markedForDeletion: $data['markedForDeletion'], platform: $data['platform'], projects: $data['projects'], billingBudget: $data['billingBudget'] ?? null, + billingStartDate: $data['billingStartDate'] ?? null, + billingCurrentInvoiceDate: $data['billingCurrentInvoiceDate'] ?? null, + billingNextInvoiceDate: $data['billingNextInvoiceDate'] ?? null, billingTrialStartDate: $data['billingTrialStartDate'] ?? null, + billingTrialDays: $data['billingTrialDays'] ?? null, + billingAggregationId: $data['billingAggregationId'] ?? null, + billingInvoiceId: $data['billingInvoiceId'] ?? null, + paymentMethodId: $data['paymentMethodId'] ?? null, billingAddressId: $data['billingAddressId'] ?? null, backupPaymentMethodId: $data['backupPaymentMethodId'] ?? null, remarks: $data['remarks'] ?? null, diff --git a/src/Appwrite/Models/Passkey.php b/src/Appwrite/Models/Passkey.php index 19e27794..61233db4 100644 --- a/src/Appwrite/Models/Passkey.php +++ b/src/Appwrite/Models/Passkey.php @@ -36,21 +36,13 @@ public function __construct( */ 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('accessedAt', $data)) { - throw new \InvalidArgumentException('Missing required field "accessedAt" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + '$updatedAt' => "", + 'name' => "", + 'accessedAt' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PasskeyChallenge.php b/src/Appwrite/Models/PasskeyChallenge.php index bb415366..c0ba66ca 100644 --- a/src/Appwrite/Models/PasskeyChallenge.php +++ b/src/Appwrite/Models/PasskeyChallenge.php @@ -36,21 +36,13 @@ public function __construct( */ 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('passkeyId', $data)) { - throw new \InvalidArgumentException('Missing required field "passkeyId" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('publicKey', $data)) { - throw new \InvalidArgumentException('Missing required field "publicKey" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'passkeyId' => "", + 'expire' => "", + 'publicKey' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/PasskeyList.php b/src/Appwrite/Models/PasskeyList.php index f9506e55..7ef3d4b0 100644 --- a/src/Appwrite/Models/PasskeyList.php +++ b/src/Appwrite/Models/PasskeyList.php @@ -30,12 +30,10 @@ public function __construct( */ 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('passkeys', $data)) { - throw new \InvalidArgumentException('Missing required field "passkeys" for ' . static::class . '.'); - } + $data += [ + 'total' => 0, + 'passkeys' => [], + ]; return new static( total: $data['total'], diff --git a/src/Appwrite/Models/PhoneList.php b/src/Appwrite/Models/PhoneList.php index ac802484..318a2782 100644 --- a/src/Appwrite/Models/PhoneList.php +++ b/src/Appwrite/Models/PhoneList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'phones' => [], ]; - if (!array_key_exists('phones', $data)) { - throw new \InvalidArgumentException('Missing required field "phones" for ' . static::class . '.'); - } - return new static( total: $data['total'], phones: is_array($data['phones']) diff --git a/src/Appwrite/Models/PlatformAndroid.php b/src/Appwrite/Models/PlatformAndroid.php index 246df74b..bc9f9662 100644 --- a/src/Appwrite/Models/PlatformAndroid.php +++ b/src/Appwrite/Models/PlatformAndroid.php @@ -24,7 +24,7 @@ * @param string $name platform name. * @param PlatformType $type platform type. possible values are: windows, apple, android, linux, web. * @param string $applicationId android application id. - * @param array|null $fingerprints sha-256 fingerprints of the certificates the app is signed with. passkeys created in the app are accepted when its signature matches one. + * @param array $fingerprints sha-256 fingerprints of the certificates the app is signed with. passkeys created in the app are accepted when its signature matches one. */ public function __construct( public string $id, @@ -33,7 +33,7 @@ public function __construct( public string $name, public PlatformType $type, public string $applicationId, - public ?array $fingerprints = null + public array $fingerprints ) { } @@ -48,6 +48,7 @@ public static function from(array $data): static '$updatedAt' => "", 'name' => "", 'applicationId' => "", + 'fingerprints' => [], ]; if (!array_key_exists('type', $data)) { @@ -61,7 +62,7 @@ public static function from(array $data): static name: $data['name'], type: static::hydrateTypedValue(PlatformType::class, $data['type']), applicationId: $data['applicationId'], - fingerprints: $data['fingerprints'] ?? null + fingerprints: $data['fingerprints'] ); } diff --git a/src/Appwrite/Models/PlatformList.php b/src/Appwrite/Models/PlatformList.php index c8d64a41..6819d824 100644 --- a/src/Appwrite/Models/PlatformList.php +++ b/src/Appwrite/Models/PlatformList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'platforms' => [], ]; - if (!array_key_exists('platforms', $data)) { - throw new \InvalidArgumentException('Missing required field "platforms" for ' . static::class . '.'); - } - return new static( total: $data['total'], platforms: $data['platforms'] diff --git a/src/Appwrite/Models/PolicyList.php b/src/Appwrite/Models/PolicyList.php index a1599a40..16069c98 100644 --- a/src/Appwrite/Models/PolicyList.php +++ b/src/Appwrite/Models/PolicyList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'policies' => [], ]; - if (!array_key_exists('policies', $data)) { - throw new \InvalidArgumentException('Missing required field "policies" for ' . static::class . '.'); - } - return new static( total: $data['total'], policies: $data['policies'] diff --git a/src/Appwrite/Models/PolicyPasskey.php b/src/Appwrite/Models/PolicyPasskey.php index 5dd5735a..f094bda4 100644 --- a/src/Appwrite/Models/PolicyPasskey.php +++ b/src/Appwrite/Models/PolicyPasskey.php @@ -32,15 +32,11 @@ public function __construct( */ 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('rpId', $data)) { - throw new \InvalidArgumentException('Missing required field "rpId" for ' . static::class . '.'); - } - if (!array_key_exists('origins', $data)) { - throw new \InvalidArgumentException('Missing required field "origins" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + 'rpId' => "", + 'origins' => [], + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Presence.php b/src/Appwrite/Models/Presence.php index 95ae696c..bd211ffe 100644 --- a/src/Appwrite/Models/Presence.php +++ b/src/Appwrite/Models/Presence.php @@ -48,14 +48,11 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'userId' => "", 'source' => "", ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/PresenceList.php b/src/Appwrite/Models/PresenceList.php index c363e108..c2e12147 100644 --- a/src/Appwrite/Models/PresenceList.php +++ b/src/Appwrite/Models/PresenceList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'presences' => [], ]; - if (!array_key_exists('presences', $data)) { - throw new \InvalidArgumentException('Missing required field "presences" for ' . static::class . '.'); - } - return new static( total: $data['total'], presences: is_array($data['presences']) diff --git a/src/Appwrite/Models/Project.php b/src/Appwrite/Models/Project.php index 256193bd..9735a0d8 100644 --- a/src/Appwrite/Models/Project.php +++ b/src/Appwrite/Models/Project.php @@ -22,7 +22,6 @@ * @param string $name project name. * @param string $teamId project team id. * @param string $region project region - * @param list $devKeys deprecated since 1.9.5: list of dev keys. * @param bool $smtpEnabled status for custom smtp * @param string $smtpSenderName smtp sender name * @param string $smtpSenderEmail smtp sender email @@ -73,7 +72,6 @@ public function __construct( public string $name, public string $teamId, public string $region, - public array $devKeys, public bool $smtpEnabled, public string $smtpSenderName, public string $smtpSenderEmail, @@ -146,25 +144,13 @@ public static function from(array $data): static 'labels' => [], 'status' => "active", 'onboarding' => [], + 'authMethods' => [], + 'services' => [], + 'protocols' => [], + 'blocks' => [], 'consoleAccessedAt' => "", ]; - if (!array_key_exists('devKeys', $data)) { - throw new \InvalidArgumentException('Missing required field "devKeys" for ' . static::class . '.'); - } - if (!array_key_exists('authMethods', $data)) { - throw new \InvalidArgumentException('Missing required field "authMethods" for ' . static::class . '.'); - } - if (!array_key_exists('services', $data)) { - throw new \InvalidArgumentException('Missing required field "services" for ' . static::class . '.'); - } - if (!array_key_exists('protocols', $data)) { - throw new \InvalidArgumentException('Missing required field "protocols" for ' . static::class . '.'); - } - if (!array_key_exists('blocks', $data)) { - throw new \InvalidArgumentException('Missing required field "blocks" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], @@ -172,12 +158,6 @@ public static function from(array $data): static name: $data['name'], teamId: $data['teamId'], region: $data['region'], - devKeys: is_array($data['devKeys']) - ? array_map( - static fn (mixed $item): mixed => static::hydrateTypedValue(DevKey::class, $item), - $data['devKeys'] - ) - : $data['devKeys'], smtpEnabled: $data['smtpEnabled'], smtpSenderName: $data['smtpSenderName'], smtpSenderEmail: $data['smtpSenderEmail'], @@ -255,7 +235,6 @@ public function toArray(): array 'name' => static::serializeValue($this->name), 'teamId' => static::serializeValue($this->teamId), 'region' => static::serializeValue($this->region), - 'devKeys' => static::serializeValue($this->devKeys), 'smtpEnabled' => static::serializeValue($this->smtpEnabled), 'smtpSenderName' => static::serializeValue($this->smtpSenderName), 'smtpSenderEmail' => static::serializeValue($this->smtpSenderEmail), diff --git a/src/Appwrite/Models/ProjectList.php b/src/Appwrite/Models/ProjectList.php index f7261447..17d71c0c 100644 --- a/src/Appwrite/Models/ProjectList.php +++ b/src/Appwrite/Models/ProjectList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'projects' => [], ]; - if (!array_key_exists('projects', $data)) { - throw new \InvalidArgumentException('Missing required field "projects" for ' . static::class . '.'); - } - return new static( total: $data['total'], projects: is_array($data['projects']) diff --git a/src/Appwrite/Models/ProviderList.php b/src/Appwrite/Models/ProviderList.php index 68bbeb5d..bd6ba8ea 100644 --- a/src/Appwrite/Models/ProviderList.php +++ b/src/Appwrite/Models/ProviderList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'providers' => [], ]; - if (!array_key_exists('providers', $data)) { - throw new \InvalidArgumentException('Missing required field "providers" for ' . static::class . '.'); - } - return new static( total: $data['total'], providers: is_array($data['providers']) diff --git a/src/Appwrite/Models/ProxyRule.php b/src/Appwrite/Models/ProxyRule.php index cc9f7583..85fbbe10 100644 --- a/src/Appwrite/Models/ProxyRule.php +++ b/src/Appwrite/Models/ProxyRule.php @@ -6,6 +6,7 @@ use Appwrite\Enums\ProxyRuleDeploymentResourceType; use Appwrite\Enums\ProxyRuleStatus; +use Appwrite\Enums\ProxyRuleProtocol; /** * Rule @@ -33,7 +34,8 @@ * @param ProxyRuleStatus $status domain verification status. possible values are "unverified", "verifying", "verified" * @param string $logs logs from rule verification or certificate generation. certificate generation logs are prioritized if both are available. * @param string $renewAt certificate auto-renewal date in iso 8601 format. - * @param ProxyRuleDeploymentResourceType|null $deploymentResourceType type of deployment. possible values are "function", "site". used if rule's type is "deployment". + * @param ProxyRuleProtocol $protocol ingress protocol for the rule. + * @param ProxyRuleDeploymentResourceType|null $deploymentResourceType type of deployment resource: function, site, or dedicateddatabase. */ public function __construct( public string $id, @@ -50,6 +52,7 @@ public function __construct( public ProxyRuleStatus $status, public string $logs, public string $renewAt, + public ProxyRuleProtocol $protocol, public ?ProxyRuleDeploymentResourceType $deploymentResourceType = null ) { } @@ -73,6 +76,7 @@ public static function from(array $data): static 'deploymentVcsProviderBranch' => "", 'status' => "unverified", 'logs' => "", + 'protocol' => "http", ]; if (!array_key_exists('renewAt', $data)) { @@ -94,6 +98,7 @@ public static function from(array $data): static status: static::hydrateTypedValue(ProxyRuleStatus::class, $data['status']), logs: $data['logs'], renewAt: $data['renewAt'], + protocol: static::hydrateTypedValue(ProxyRuleProtocol::class, $data['protocol']), deploymentResourceType: array_key_exists('deploymentResourceType', $data) ? static::hydrateTypedValue(ProxyRuleDeploymentResourceType::class, $data['deploymentResourceType'], true) : null ); } @@ -118,7 +123,8 @@ public function toArray(): array 'deploymentVcsProviderBranch' => static::serializeValue($this->deploymentVcsProviderBranch), 'status' => static::serializeValue($this->status), 'logs' => static::serializeValue($this->logs), - 'renewAt' => static::serializeValue($this->renewAt) + 'renewAt' => static::serializeValue($this->renewAt), + 'protocol' => static::serializeValue($this->protocol) ]; } } diff --git a/src/Appwrite/Models/ProxyRuleList.php b/src/Appwrite/Models/ProxyRuleList.php index 413058a4..ac83cabf 100644 --- a/src/Appwrite/Models/ProxyRuleList.php +++ b/src/Appwrite/Models/ProxyRuleList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'rules' => [], ]; - if (!array_key_exists('rules', $data)) { - throw new \InvalidArgumentException('Missing required field "rules" for ' . static::class . '.'); - } - return new static( total: $data['total'], rules: is_array($data['rules']) diff --git a/src/Appwrite/Models/Report.php b/src/Appwrite/Models/Report.php index 8ecd43f9..e004db96 100644 --- a/src/Appwrite/Models/Report.php +++ b/src/Appwrite/Models/Report.php @@ -61,12 +61,9 @@ public static function from(array $data): static 'targetType' => "", 'target' => "", 'categories' => [], + 'insights' => [], ]; - if (!array_key_exists('insights', $data)) { - throw new \InvalidArgumentException('Missing required field "insights" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/ReportList.php b/src/Appwrite/Models/ReportList.php index ea32a528..5e129d3d 100644 --- a/src/Appwrite/Models/ReportList.php +++ b/src/Appwrite/Models/ReportList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'reports' => [], ]; - if (!array_key_exists('reports', $data)) { - throw new \InvalidArgumentException('Missing required field "reports" for ' . static::class . '.'); - } - return new static( total: $data['total'], reports: is_array($data['reports']) diff --git a/src/Appwrite/Models/ResourceTokenList.php b/src/Appwrite/Models/ResourceTokenList.php index 2b9b1885..c50b4801 100644 --- a/src/Appwrite/Models/ResourceTokenList.php +++ b/src/Appwrite/Models/ResourceTokenList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tokens' => [], ]; - if (!array_key_exists('tokens', $data)) { - throw new \InvalidArgumentException('Missing required field "tokens" for ' . static::class . '.'); - } - return new static( total: $data['total'], tokens: is_array($data['tokens']) diff --git a/src/Appwrite/Models/Row.php b/src/Appwrite/Models/Row.php index d37ab8ab..1e323515 100644 --- a/src/Appwrite/Models/Row.php +++ b/src/Appwrite/Models/Row.php @@ -49,12 +49,9 @@ public static function from(array $data): static '$databaseId' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - $additionalProperties = static::extractAdditionalPropertiesFromFields( $data, [ diff --git a/src/Appwrite/Models/RowList.php b/src/Appwrite/Models/RowList.php index f5194b86..9cf05c07 100644 --- a/src/Appwrite/Models/RowList.php +++ b/src/Appwrite/Models/RowList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'rows' => [], ]; - if (!array_key_exists('rows', $data)) { - throw new \InvalidArgumentException('Missing required field "rows" for ' . static::class . '.'); - } - return new static( total: $data['total'], rows: is_array($data['rows']) diff --git a/src/Appwrite/Models/Runtime.php b/src/Appwrite/Models/Runtime.php index 6b51ebed..84aa814d 100644 --- a/src/Appwrite/Models/Runtime.php +++ b/src/Appwrite/Models/Runtime.php @@ -50,12 +50,9 @@ public static function from(array $data): static 'base' => "", 'image' => "", 'logo' => "", + 'supports' => [], ]; - if (!array_key_exists('supports', $data)) { - throw new \InvalidArgumentException('Missing required field "supports" for ' . static::class . '.'); - } - return new static( id: $data['$id'], key: $data['key'], diff --git a/src/Appwrite/Models/RuntimeList.php b/src/Appwrite/Models/RuntimeList.php index 32baecf3..c13abbcf 100644 --- a/src/Appwrite/Models/RuntimeList.php +++ b/src/Appwrite/Models/RuntimeList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'runtimes' => [], ]; - if (!array_key_exists('runtimes', $data)) { - throw new \InvalidArgumentException('Missing required field "runtimes" for ' . static::class . '.'); - } - return new static( total: $data['total'], runtimes: is_array($data['runtimes']) diff --git a/src/Appwrite/Models/SessionList.php b/src/Appwrite/Models/SessionList.php index 33e062cc..d834c970 100644 --- a/src/Appwrite/Models/SessionList.php +++ b/src/Appwrite/Models/SessionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'sessions' => [], ]; - if (!array_key_exists('sessions', $data)) { - throw new \InvalidArgumentException('Missing required field "sessions" for ' . static::class . '.'); - } - return new static( total: $data['total'], sessions: is_array($data['sessions']) diff --git a/src/Appwrite/Models/Site.php b/src/Appwrite/Models/Site.php index 671bb5d4..3b00ca02 100644 --- a/src/Appwrite/Models/Site.php +++ b/src/Appwrite/Models/Site.php @@ -114,6 +114,7 @@ public static function from(array $data): static 'latestDeploymentCreatedAt' => "", 'latestDeploymentStatus' => "", 'scopes' => [], + 'vars' => [], 'timeout' => 15, 'installCommand' => "", 'buildCommand' => "", @@ -131,9 +132,6 @@ public static function from(array $data): static 'buildRuntime' => "", ]; - if (!array_key_exists('vars', $data)) { - throw new \InvalidArgumentException('Missing required field "vars" for ' . static::class . '.'); - } if (!array_key_exists('adapter', $data)) { throw new \InvalidArgumentException('Missing required field "adapter" for ' . static::class . '.'); } diff --git a/src/Appwrite/Models/SiteList.php b/src/Appwrite/Models/SiteList.php index e3b32b48..2adcf105 100644 --- a/src/Appwrite/Models/SiteList.php +++ b/src/Appwrite/Models/SiteList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'sites' => [], ]; - if (!array_key_exists('sites', $data)) { - throw new \InvalidArgumentException('Missing required field "sites" for ' . static::class . '.'); - } - return new static( total: $data['total'], sites: is_array($data['sites']) diff --git a/src/Appwrite/Models/SpecificationList.php b/src/Appwrite/Models/SpecificationList.php index e48faded..117627c5 100644 --- a/src/Appwrite/Models/SpecificationList.php +++ b/src/Appwrite/Models/SpecificationList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'specifications' => [], ]; - if (!array_key_exists('specifications', $data)) { - throw new \InvalidArgumentException('Missing required field "specifications" for ' . static::class . '.'); - } - return new static( total: $data['total'], specifications: is_array($data['specifications']) diff --git a/src/Appwrite/Models/SubscriberList.php b/src/Appwrite/Models/SubscriberList.php index 705cb0b5..cdd1819b 100644 --- a/src/Appwrite/Models/SubscriberList.php +++ b/src/Appwrite/Models/SubscriberList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'subscribers' => [], ]; - if (!array_key_exists('subscribers', $data)) { - throw new \InvalidArgumentException('Missing required field "subscribers" for ' . static::class . '.'); - } - return new static( total: $data['total'], subscribers: is_array($data['subscribers']) diff --git a/src/Appwrite/Models/Table.php b/src/Appwrite/Models/Table.php index 49869583..dc197d32 100644 --- a/src/Appwrite/Models/Table.php +++ b/src/Appwrite/Models/Table.php @@ -54,24 +54,17 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'rowSecurity' => false, + 'columns' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('columns', $data)) { - throw new \InvalidArgumentException('Missing required field "columns" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/TableList.php b/src/Appwrite/Models/TableList.php index c6352fb6..c3aa35fc 100644 --- a/src/Appwrite/Models/TableList.php +++ b/src/Appwrite/Models/TableList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'tables' => [], ]; - if (!array_key_exists('tables', $data)) { - throw new \InvalidArgumentException('Missing required field "tables" for ' . static::class . '.'); - } - return new static( total: $data['total'], tables: is_array($data['tables']) diff --git a/src/Appwrite/Models/TargetList.php b/src/Appwrite/Models/TargetList.php index 8596f116..e68cdcf4 100644 --- a/src/Appwrite/Models/TargetList.php +++ b/src/Appwrite/Models/TargetList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'targets' => [], ]; - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } - return new static( total: $data['total'], targets: is_array($data['targets']) diff --git a/src/Appwrite/Models/TeamList.php b/src/Appwrite/Models/TeamList.php index 8c75339d..b9647882 100644 --- a/src/Appwrite/Models/TeamList.php +++ b/src/Appwrite/Models/TeamList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'teams' => [], ]; - if (!array_key_exists('teams', $data)) { - throw new \InvalidArgumentException('Missing required field "teams" for ' . static::class . '.'); - } - return new static( total: $data['total'], teams: is_array($data['teams']) diff --git a/src/Appwrite/Models/TokenSecret.php b/src/Appwrite/Models/TokenSecret.php index deedef6b..a9b879de 100644 --- a/src/Appwrite/Models/TokenSecret.php +++ b/src/Appwrite/Models/TokenSecret.php @@ -38,24 +38,14 @@ public function __construct( */ 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('userId', $data)) { - throw new \InvalidArgumentException('Missing required field "userId" for ' . static::class . '.'); - } - if (!array_key_exists('secret', $data)) { - throw new \InvalidArgumentException('Missing required field "secret" for ' . static::class . '.'); - } - if (!array_key_exists('expire', $data)) { - throw new \InvalidArgumentException('Missing required field "expire" for ' . static::class . '.'); - } - if (!array_key_exists('phrase', $data)) { - throw new \InvalidArgumentException('Missing required field "phrase" for ' . static::class . '.'); - } + $data += [ + '$id' => "", + '$createdAt' => "", + 'userId' => "", + 'secret' => "", + 'expire' => "", + 'phrase' => "", + ]; return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/Topic.php b/src/Appwrite/Models/Topic.php index 42f22386..4719c755 100644 --- a/src/Appwrite/Models/Topic.php +++ b/src/Appwrite/Models/Topic.php @@ -25,7 +25,7 @@ * @param int $pushTotal total count of push subscribers subscribed to the topic. * @param array $subscribe subscribe permissions. * @param int|null $qos mqtt qos for delivery on this topic. null lets the subscriber choose their level. - * @param int|null $expiry message retention in seconds for offline delivery. + * @param int|null $expiry message retention in seconds for offline delivery. null inherits the lowest expiry of the project's enabled appwrite providers, or the 7-day ledger window if none sets one. */ public function __construct( public string $id, diff --git a/src/Appwrite/Models/TopicList.php b/src/Appwrite/Models/TopicList.php index 4ba86969..48bbc421 100644 --- a/src/Appwrite/Models/TopicList.php +++ b/src/Appwrite/Models/TopicList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'topics' => [], ]; - if (!array_key_exists('topics', $data)) { - throw new \InvalidArgumentException('Missing required field "topics" for ' . static::class . '.'); - } - return new static( total: $data['total'], topics: is_array($data['topics']) diff --git a/src/Appwrite/Models/TransactionList.php b/src/Appwrite/Models/TransactionList.php index 7e17740d..92fd205d 100644 --- a/src/Appwrite/Models/TransactionList.php +++ b/src/Appwrite/Models/TransactionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'transactions' => [], ]; - if (!array_key_exists('transactions', $data)) { - throw new \InvalidArgumentException('Missing required field "transactions" for ' . static::class . '.'); - } - return new static( total: $data['total'], transactions: is_array($data['transactions']) diff --git a/src/Appwrite/Models/UsageBillingPlan.php b/src/Appwrite/Models/UsageBillingPlan.php index eb9cab99..1db3b763 100644 --- a/src/Appwrite/Models/UsageBillingPlan.php +++ b/src/Appwrite/Models/UsageBillingPlan.php @@ -16,29 +16,29 @@ /** * UsageBillingPlan constructor. * - * @param AdditionalResource $bandwidth bandwidth additional resources - * @param AdditionalResource $executions executions additional resources - * @param AdditionalResource $realtime realtime additional resources - * @param AdditionalResource $realtimeMessages realtime messages additional resources - * @param AdditionalResource $storage storage additional resources - * @param AdditionalResource $users user additional resources - * @param AdditionalResource $gBHours gbhour additional resources - * @param AdditionalResource $imageTransformations image transformation additional resources + * @param AdditionalResource|null $bandwidth bandwidth additional resources + * @param AdditionalResource|null $executions executions additional resources * @param AdditionalResource|null $member member additional resources + * @param AdditionalResource|null $realtime realtime additional resources + * @param AdditionalResource|null $realtimeMessages realtime messages additional resources * @param AdditionalResource|null $realtimeBandwidth realtime bandwidth additional resources + * @param AdditionalResource|null $storage storage additional resources + * @param AdditionalResource|null $users user additional resources + * @param AdditionalResource|null $gBHours gbhour additional resources + * @param AdditionalResource|null $imageTransformations image transformation additional resources * @param AdditionalResource|null $credits credits additional resources */ public function __construct( - public AdditionalResource $bandwidth, - public AdditionalResource $executions, - public AdditionalResource $realtime, - public AdditionalResource $realtimeMessages, - public AdditionalResource $storage, - public AdditionalResource $users, - public AdditionalResource $gBHours, - public AdditionalResource $imageTransformations, + public ?AdditionalResource $bandwidth = null, + public ?AdditionalResource $executions = null, public ?AdditionalResource $member = null, + public ?AdditionalResource $realtime = null, + public ?AdditionalResource $realtimeMessages = null, public ?AdditionalResource $realtimeBandwidth = null, + public ?AdditionalResource $storage = null, + public ?AdditionalResource $users = null, + public ?AdditionalResource $gBHours = null, + public ?AdditionalResource $imageTransformations = null, public ?AdditionalResource $credits = null ) { } @@ -48,42 +48,18 @@ public function __construct( */ 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('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('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 . '.'); - } return new static( - bandwidth: static::hydrateTypedValue(AdditionalResource::class, $data['bandwidth']), - executions: static::hydrateTypedValue(AdditionalResource::class, $data['executions']), - realtime: static::hydrateTypedValue(AdditionalResource::class, $data['realtime']), - realtimeMessages: static::hydrateTypedValue(AdditionalResource::class, $data['realtimeMessages']), - 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']), + bandwidth: array_key_exists('bandwidth', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['bandwidth'], true) : null, + executions: array_key_exists('executions', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['executions'], true) : null, member: array_key_exists('member', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['member'], true) : null, + realtime: array_key_exists('realtime', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtime'], true) : null, + realtimeMessages: array_key_exists('realtimeMessages', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtimeMessages'], true) : null, realtimeBandwidth: array_key_exists('realtimeBandwidth', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['realtimeBandwidth'], true) : null, + storage: array_key_exists('storage', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['storage'], true) : null, + users: array_key_exists('users', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['users'], true) : null, + gBHours: array_key_exists('GBHours', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['GBHours'], true) : null, + imageTransformations: array_key_exists('imageTransformations', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['imageTransformations'], true) : null, credits: array_key_exists('credits', $data) ? static::hydrateTypedValue(AdditionalResource::class, $data['credits'], true) : null ); } diff --git a/src/Appwrite/Models/User.php b/src/Appwrite/Models/User.php index 476c9802..57c6d397 100644 --- a/src/Appwrite/Models/User.php +++ b/src/Appwrite/Models/User.php @@ -94,15 +94,13 @@ public static function from(array $data): static 'emailVerification' => false, 'phoneVerification' => false, 'mfa' => false, + 'targets' => [], 'accessedAt' => "", ]; if (!array_key_exists('prefs', $data)) { throw new \InvalidArgumentException('Missing required field "prefs" for ' . static::class . '.'); } - if (!array_key_exists('targets', $data)) { - throw new \InvalidArgumentException('Missing required field "targets" for ' . static::class . '.'); - } return new static( id: $data['$id'], diff --git a/src/Appwrite/Models/UserList.php b/src/Appwrite/Models/UserList.php index 8c4d99d0..b3c9b38c 100644 --- a/src/Appwrite/Models/UserList.php +++ b/src/Appwrite/Models/UserList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'users' => [], ]; - if (!array_key_exists('users', $data)) { - throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); - } - return new static( total: $data['total'], users: is_array($data['users']) diff --git a/src/Appwrite/Models/VariableList.php b/src/Appwrite/Models/VariableList.php index 698af61c..9a8ae59b 100644 --- a/src/Appwrite/Models/VariableList.php +++ b/src/Appwrite/Models/VariableList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'variables' => [], ]; - if (!array_key_exists('variables', $data)) { - throw new \InvalidArgumentException('Missing required field "variables" for ' . static::class . '.'); - } - return new static( total: $data['total'], variables: is_array($data['variables']) diff --git a/src/Appwrite/Models/VectorsdbCollection.php b/src/Appwrite/Models/VectorsdbCollection.php index 38e5ec63..1ec525b7 100644 --- a/src/Appwrite/Models/VectorsdbCollection.php +++ b/src/Appwrite/Models/VectorsdbCollection.php @@ -56,25 +56,18 @@ public static function from(array $data): static '$id' => "", '$createdAt' => "", '$updatedAt' => "", + '$permissions' => [], 'databaseId' => "", 'name' => "", 'enabled' => true, 'documentSecurity' => false, + 'attributes' => [], + 'indexes' => [], 'bytesMax' => 0, 'bytesUsed' => 0, 'dimension' => 0, ]; - if (!array_key_exists('$permissions', $data)) { - throw new \InvalidArgumentException('Missing required field "$permissions" for ' . static::class . '.'); - } - if (!array_key_exists('attributes', $data)) { - throw new \InvalidArgumentException('Missing required field "attributes" for ' . static::class . '.'); - } - if (!array_key_exists('indexes', $data)) { - throw new \InvalidArgumentException('Missing required field "indexes" for ' . static::class . '.'); - } - return new static( id: $data['$id'], createdAt: $data['$createdAt'], diff --git a/src/Appwrite/Models/VectorsdbCollectionList.php b/src/Appwrite/Models/VectorsdbCollectionList.php index e5c2c05c..8e414ae9 100644 --- a/src/Appwrite/Models/VectorsdbCollectionList.php +++ b/src/Appwrite/Models/VectorsdbCollectionList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'collections' => [], ]; - if (!array_key_exists('collections', $data)) { - throw new \InvalidArgumentException('Missing required field "collections" for ' . static::class . '.'); - } - return new static( total: $data['total'], collections: is_array($data['collections']) diff --git a/src/Appwrite/Models/Webhook.php b/src/Appwrite/Models/Webhook.php index 9f1bef97..4df57b11 100644 --- a/src/Appwrite/Models/Webhook.php +++ b/src/Appwrite/Models/Webhook.php @@ -24,7 +24,7 @@ * @param array $events webhook trigger events. * @param bool $tls indicates if ssl / tls certificate verification is enabled. * @param string $authUsername http basic authentication username. - * @param string $authPassword http basic authentication password. + * @param string $authPassword http basic authentication password. write-only: always returned empty. * @param string $secret signature key which can be used to validate incoming webhook payloads. only returned on creation and secret rotation. * @param bool $enabled indicates if this webhook is enabled. * @param string $logs webhook error logs from the most recent failure. diff --git a/src/Appwrite/Models/WebhookList.php b/src/Appwrite/Models/WebhookList.php index dafb70d4..9ff66138 100644 --- a/src/Appwrite/Models/WebhookList.php +++ b/src/Appwrite/Models/WebhookList.php @@ -32,12 +32,9 @@ public static function from(array $data): static { $data += [ 'total' => 0, + 'webhooks' => [], ]; - if (!array_key_exists('webhooks', $data)) { - throw new \InvalidArgumentException('Missing required field "webhooks" for ' . static::class . '.'); - } - return new static( total: $data['total'], webhooks: is_array($data['webhooks']) diff --git a/src/Appwrite/Query.php b/src/Appwrite/Query.php index 46ee87f2..1ef74498 100644 --- a/src/Appwrite/Query.php +++ b/src/Appwrite/Query.php @@ -4,13 +4,14 @@ namespace Appwrite; +use Appwrite\Query\Builder as QueryBuilder; + class Query implements \JsonSerializable, \Stringable { protected ?array $values; public function __construct(protected string $method, protected ?string $attribute = null, $values = null) { - if (is_null($values) || is_array($values)) { $this->values = $values; } else { @@ -34,7 +35,6 @@ public function jsonSerialize(): mixed /** * Equal - * */ public static function equal(string $attribute, mixed $value): string { @@ -43,7 +43,6 @@ public static function equal(string $attribute, mixed $value): string /** * Not Equal - * */ public static function notEqual(string $attribute, mixed $value): string { @@ -52,7 +51,6 @@ public static function notEqual(string $attribute, mixed $value): string /** * Less Than - * */ public static function lessThan(string $attribute, mixed $value): string { @@ -61,7 +59,6 @@ public static function lessThan(string $attribute, mixed $value): string /** * Less Than or Equal - * */ public static function lessThanEqual(string $attribute, mixed $value): string { @@ -70,7 +67,6 @@ public static function lessThanEqual(string $attribute, mixed $value): string /** * Greater Than - * */ public static function greaterThan(string $attribute, mixed $value): string { @@ -79,7 +75,6 @@ public static function greaterThan(string $attribute, mixed $value): string /** * Greater Than or Equal - * */ public static function greaterThanEqual(string $attribute, mixed $value): string { @@ -88,7 +83,6 @@ public static function greaterThanEqual(string $attribute, mixed $value): string /** * Search - * */ public static function search(string $attribute, string $value): string { @@ -97,7 +91,6 @@ public static function search(string $attribute, string $value): string /** * Is Null - * */ public static function isNull(string $attribute): string { @@ -106,7 +99,6 @@ public static function isNull(string $attribute): string /** * Is Not Null - * */ public static function isNotNull(string $attribute): string { @@ -115,7 +107,6 @@ public static function isNotNull(string $attribute): string /** * Between - * */ public static function between(string $attribute, mixed $start, mixed $end): string { @@ -124,7 +115,6 @@ public static function between(string $attribute, mixed $start, mixed $end): str /** * Starts With - * */ public static function startsWith(string $attribute, string $value): string { @@ -133,7 +123,6 @@ public static function startsWith(string $attribute, string $value): string /** * Ends With - * */ public static function endsWith(string $attribute, string $value): string { @@ -142,7 +131,6 @@ public static function endsWith(string $attribute, string $value): string /** * Select - * */ public static function select(array $attributes): string { @@ -151,7 +139,6 @@ public static function select(array $attributes): string /** * Cursor After - * */ public static function cursorAfter(string $documentId): string { @@ -160,7 +147,6 @@ public static function cursorAfter(string $documentId): string /** * Cursor Before - * */ public static function cursorBefore(string $documentId): string { @@ -169,7 +155,6 @@ public static function cursorBefore(string $documentId): string /** * Order Asc - * */ public static function orderAsc(string $attribute): string { @@ -178,7 +163,6 @@ public static function orderAsc(string $attribute): string /** * Order Desc - * */ public static function orderDesc(string $attribute): string { @@ -187,7 +171,6 @@ public static function orderDesc(string $attribute): string /** * Order Random - * */ public static function orderRandom(): string { @@ -196,7 +179,6 @@ public static function orderRandom(): string /** * Limit - * */ public static function limit(int $limit): string { @@ -205,7 +187,6 @@ public static function limit(int $limit): string /** * Offset - * */ public static function offset(int $offset): string { @@ -253,7 +234,6 @@ public static function containsAll(string $attribute, array $value): string /** * Not Contains - * */ public static function notContains(string $attribute, $value): string { @@ -262,7 +242,6 @@ public static function notContains(string $attribute, $value): string /** * Not Search - * */ public static function notSearch(string $attribute, string $value): string { @@ -271,7 +250,6 @@ public static function notSearch(string $attribute, string $value): string /** * Not Between - * */ public static function notBetween(string $attribute, mixed $start, mixed $end): string { @@ -280,7 +258,6 @@ public static function notBetween(string $attribute, mixed $start, mixed $end): /** * Not Starts With - * */ public static function notStartsWith(string $attribute, string $value): string { @@ -289,7 +266,6 @@ public static function notStartsWith(string $attribute, string $value): string /** * Not Ends With - * */ public static function notEndsWith(string $attribute, string $value): string { @@ -298,7 +274,6 @@ public static function notEndsWith(string $attribute, string $value): string /** * Filter resources where attribute matches a regular expression pattern. - * */ public static function regex(string $attribute, string $pattern): string { @@ -307,7 +282,6 @@ public static function regex(string $attribute, string $pattern): string /** * Filter resources where the specified attributes exist. - * */ public static function exists(array $attributes): string { @@ -316,7 +290,6 @@ public static function exists(array $attributes): string /** * Filter resources where the specified attributes do not exist. - * */ public static function notExists(array $attributes): string { @@ -325,7 +298,6 @@ public static function notExists(array $attributes): string /** * Created Before - * */ public static function createdBefore(string $value): string { @@ -334,7 +306,6 @@ public static function createdBefore(string $value): string /** * Created After - * */ public static function createdAfter(string $value): string { @@ -343,7 +314,6 @@ public static function createdAfter(string $value): string /** * Created Between - * */ public static function createdBetween(string $start, string $end): string { @@ -352,7 +322,6 @@ public static function createdBetween(string $start, string $end): string /** * Updated Before - * */ public static function updatedBefore(string $value): string { @@ -361,7 +330,6 @@ public static function updatedBefore(string $value): string /** * Updated After - * */ public static function updatedAfter(string $value): string { @@ -370,7 +338,6 @@ public static function updatedAfter(string $value): string /** * Updated Between - * */ public static function updatedBetween(string $start, string $end): string { @@ -379,7 +346,6 @@ public static function updatedBetween(string $start, string $end): string /** * Or - * */ public static function or(array $queries): string { @@ -391,7 +357,6 @@ public static function or(array $queries): string /** * And - * */ public static function and(array $queries): string { @@ -403,7 +368,6 @@ public static function and(array $queries): string /** * Filter array elements where at least one element matches all the specified queries. - * */ public static function elemMatch(string $attribute, array $queries): string { @@ -415,9 +379,21 @@ public static function elemMatch(string $attribute, array $queries): string } /** - * Distance Equal + * Constrain populated related documents on a relationship attribute. * */ + public static function relationship(string $attribute, array $queries): string + { + foreach ($queries as &$query) { + $query = \json_decode($query, true); + } + + return new Query('relationship', $attribute, $queries)->__toString(); + } + + /** + * Distance Equal + */ public static function distanceEqual(string $attribute, array $values, int|float $distance, bool $meters = true): string { return new Query('distanceEqual', $attribute, [[$values, $distance, $meters]])->__toString(); @@ -425,7 +401,6 @@ public static function distanceEqual(string $attribute, array $values, int|float /** * Distance Not Equal - * */ public static function distanceNotEqual(string $attribute, array $values, int|float $distance, bool $meters = true): string { @@ -434,7 +409,6 @@ public static function distanceNotEqual(string $attribute, array $values, int|fl /** * Distance Greater Than - * */ public static function distanceGreaterThan(string $attribute, array $values, int|float $distance, bool $meters = true): string { @@ -443,7 +417,6 @@ public static function distanceGreaterThan(string $attribute, array $values, int /** * Distance Less Than - * */ public static function distanceLessThan(string $attribute, array $values, int|float $distance, bool $meters = true): string { @@ -452,7 +425,6 @@ public static function distanceLessThan(string $attribute, array $values, int|fl /** * Vector Dot - * */ public static function vectorDot(string $attribute, array $vector): string { @@ -461,7 +433,6 @@ public static function vectorDot(string $attribute, array $vector): string /** * Vector Cosine - * */ public static function vectorCosine(string $attribute, array $vector): string { @@ -470,7 +441,6 @@ public static function vectorCosine(string $attribute, array $vector): string /** * Vector Euclidean - * */ public static function vectorEuclidean(string $attribute, array $vector): string { @@ -479,7 +449,6 @@ public static function vectorEuclidean(string $attribute, array $vector): string /** * Intersects - * */ public static function intersects(string $attribute, array $values): string { @@ -488,7 +457,6 @@ public static function intersects(string $attribute, array $values): string /** * Not Intersects - * */ public static function notIntersects(string $attribute, array $values): string { @@ -497,7 +465,6 @@ public static function notIntersects(string $attribute, array $values): string /** * Crosses - * */ public static function crosses(string $attribute, array $values): string { @@ -506,7 +473,6 @@ public static function crosses(string $attribute, array $values): string /** * Not Crosses - * */ public static function notCrosses(string $attribute, array $values): string { @@ -515,7 +481,6 @@ public static function notCrosses(string $attribute, array $values): string /** * Overlaps - * */ public static function overlaps(string $attribute, array $values): string { @@ -524,7 +489,6 @@ public static function overlaps(string $attribute, array $values): string /** * Not Overlaps - * */ public static function notOverlaps(string $attribute, array $values): string { @@ -533,7 +497,6 @@ public static function notOverlaps(string $attribute, array $values): string /** * Touches - * */ public static function touches(string $attribute, array $values): string { @@ -542,10 +505,308 @@ public static function touches(string $attribute, array $values): string /** * Not Touches - * */ public static function notTouches(string $attribute, array $values): string { return new Query('notTouches', $attribute, [$values])->__toString(); } + + /** + * Count rows of $attribute, optionally aliased. + */ + public static function count(string $attribute = '*', string $alias = ''): string + { + return new Query('count', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Count distinct values of $attribute, optionally aliased. + */ + public static function countDistinct(string $attribute, string $alias = ''): string + { + return new Query('countDistinct', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Sum values of $attribute, optionally aliased. + */ + public static function sum(string $attribute, string $alias = ''): string + { + return new Query('sum', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Average values of $attribute, optionally aliased. + */ + public static function avg(string $attribute, string $alias = ''): string + { + return new Query('avg', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Minimum value of $attribute, optionally aliased. + */ + public static function min(string $attribute, string $alias = ''): string + { + return new Query('min', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Maximum value of $attribute, optionally aliased. + */ + public static function max(string $attribute, string $alias = ''): string + { + return new Query('max', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Standard deviation of $attribute, optionally aliased. + */ + public static function stddev(string $attribute, string $alias = ''): string + { + return new Query('stddev', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Population standard deviation of $attribute, optionally aliased. + */ + public static function stddevPop(string $attribute, string $alias = ''): string + { + return new Query('stddevPop', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Sample standard deviation of $attribute, optionally aliased. + */ + public static function stddevSamp(string $attribute, string $alias = ''): string + { + return new Query('stddevSamp', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Variance of $attribute, optionally aliased. + */ + public static function variance(string $attribute, string $alias = ''): string + { + return new Query('variance', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Population variance of $attribute, optionally aliased. + */ + public static function varPop(string $attribute, string $alias = ''): string + { + return new Query('varPop', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Sample variance of $attribute, optionally aliased. + */ + public static function varSamp(string $attribute, string $alias = ''): string + { + return new Query('varSamp', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Bitwise AND of $attribute, optionally aliased. + */ + public static function bitAnd(string $attribute, string $alias = ''): string + { + return new Query('bitAnd', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Bitwise OR of $attribute, optionally aliased. + */ + public static function bitOr(string $attribute, string $alias = ''): string + { + return new Query('bitOr', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Bitwise XOR of $attribute, optionally aliased. + */ + public static function bitXor(string $attribute, string $alias = ''): string + { + return new Query('bitXor', $attribute, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Group results by attributes. + */ + public static function groupBy(array $attributes): string + { + return new Query('groupBy', null, $attributes)->__toString(); + } + + /** + * Filter grouped results. $queries are nested like and/or. + * + * @param array $queries + */ + public static function having(array $queries): string + { + foreach ($queries as &$query) { + if ($query instanceof self) { + $query = $query->__toString(); + } + $query = \json_decode($query, true); + } + unset($query); + + return new Query('having', null, $queries)->__toString(); + } + + /** + * Select distinct rows. + */ + public static function distinct(): string + { + return new Query('distinct')->__toString(); + } + + /** + * Column-to-column join ON condition. + */ + public static function on(string $left, string $right, string $operator = '='): string + { + return new Query('on', null, [$left, $operator, $right])->__toString(); + } + + /** + * Inner join. $table is the joined collection/table ID. + */ + public static function join(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): string + { + return self::createJoin('join', $table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias); + } + + /** + * Left join. $table is the joined collection/table ID. + */ + public static function leftJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): string + { + return self::createJoin('leftJoin', $table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias); + } + + /** + * Right join. $table is the joined collection/table ID. + */ + public static function rightJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): string + { + return self::createJoin('rightJoin', $table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias); + } + + /** + * Full outer join. $table is the joined collection/table ID. + */ + public static function fullOuterJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): string + { + return self::createJoin('fullOuterJoin', $table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias); + } + + /** + * Cross join. $table is the joined collection/table ID. + */ + public static function crossJoin(string $table, string $alias = ''): string + { + return new Query('crossJoin', $table, $alias !== '' ? $alias : null)->__toString(); + } + + /** + * Filter resources where $attribute covers the given geometry. + */ + public static function covers(string $attribute, array $values): string + { + return new Query('covers', $attribute, [$values])->__toString(); + } + + /** + * Filter resources where $attribute does not cover the given geometry. + */ + public static function notCovers(string $attribute, array $values): string + { + return new Query('notCovers', $attribute, [$values])->__toString(); + } + + /** + * Filter resources where $attribute is spatially equal to the given geometry. + */ + public static function spatialEquals(string $attribute, array $values): string + { + return new Query('spatialEquals', $attribute, [$values])->__toString(); + } + + /** + * Filter resources where $attribute is not spatially equal to the given geometry. + */ + public static function notSpatialEquals(string $attribute, array $values): string + { + return new Query('notSpatialEquals', $attribute, [$values])->__toString(); + } + + /** + * Return limit and offset queries for 1-based page pagination. + */ + public static function page(int $page, int $perPage = 25): array + { + if ($page < 1) { + throw new \InvalidArgumentException('Page must be >= 1, got ' . $page); + } + if ($perPage < 1) { + throw new \InvalidArgumentException('Per page must be >= 1, got ' . $perPage); + } + + return [ + self::limit($perPage), + self::offset(($page - 1) * $perPage), + ]; + } + + /** + * Start a fluent query builder. + */ + public static function builder(): QueryBuilder + { + return new QueryBuilder(); + } + + /** + */ + private static function createJoin(string $method, string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn, string $operator, string $alias): string + { + if (\is_array($leftOrAliasOrOn)) { + return self::nestedJoin($method, $table, '', $leftOrAliasOrOn); + } + if (\is_array($rightOrOn)) { + return self::nestedJoin($method, $table, $leftOrAliasOrOn, $rightOrOn); + } + + return self::joinQuery($method, $table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias); + } + + /** + */ + private static function nestedJoin(string $method, string $table, string $alias, array $on): string + { + $values = []; + if ($alias !== '') { + $values[] = $alias; + } + foreach ($on as $query) { + $values[] = \json_decode($query, true); + } + + return new Query($method, $table, $values)->__toString(); + } + + private static function joinQuery(string $method, string $table, string $left, string $right, string $operator, string $alias): string + { + $values = [$left, $operator, $right]; + if ($alias !== '') { + $values[] = $alias; + } + + return new Query($method, $table, $values)->__toString(); + } } diff --git a/src/Appwrite/Query/Builder.php b/src/Appwrite/Query/Builder.php new file mode 100644 index 00000000..c9acb455 --- /dev/null +++ b/src/Appwrite/Query/Builder.php @@ -0,0 +1,558 @@ + + */ + private array $queries = []; + + /** + * @return list + */ + public function build(): array + { + return $this->queries; + } + + public function equal(string $attribute, mixed $value): self + { + return $this->push(Query::equal($attribute, $value)); + } + + public function notEqual(string $attribute, mixed $value): self + { + return $this->push(Query::notEqual($attribute, $value)); + } + + public function lessThan(string $attribute, mixed $value): self + { + return $this->push(Query::lessThan($attribute, $value)); + } + + public function lessThanEqual(string $attribute, mixed $value): self + { + return $this->push(Query::lessThanEqual($attribute, $value)); + } + + public function greaterThan(string $attribute, mixed $value): self + { + return $this->push(Query::greaterThan($attribute, $value)); + } + + public function greaterThanEqual(string $attribute, mixed $value): self + { + return $this->push(Query::greaterThanEqual($attribute, $value)); + } + + public function search(string $attribute, string $value): self + { + return $this->push(Query::search($attribute, $value)); + } + + public function isNull(string $attribute): self + { + return $this->push(Query::isNull($attribute)); + } + + public function isNotNull(string $attribute): self + { + return $this->push(Query::isNotNull($attribute)); + } + + public function between(string $attribute, mixed $start, mixed $end): self + { + return $this->push(Query::between($attribute, $start, $end)); + } + + public function startsWith(string $attribute, string $value): self + { + return $this->push(Query::startsWith($attribute, $value)); + } + + public function endsWith(string $attribute, string $value): self + { + return $this->push(Query::endsWith($attribute, $value)); + } + + /** + * @param array $attributes + */ + public function select(array $attributes): self + { + return $this->push(Query::select($attributes)); + } + + public function cursorAfter(string $documentId): self + { + return $this->push(Query::cursorAfter($documentId)); + } + + public function cursorBefore(string $documentId): self + { + return $this->push(Query::cursorBefore($documentId)); + } + + public function orderAsc(string $attribute): self + { + return $this->push(Query::orderAsc($attribute)); + } + + public function orderDesc(string $attribute): self + { + return $this->push(Query::orderDesc($attribute)); + } + + public function orderRandom(): self + { + return $this->push(Query::orderRandom()); + } + + public function limit(int $limit): self + { + return $this->push(Query::limit($limit)); + } + + public function offset(int $offset): self + { + return $this->push(Query::offset($offset)); + } + + public function contains(string $attribute, mixed $value): self + { + return $this->push(Query::contains($attribute, $value)); + } + + /** + * @param array $value + */ + public function containsAny(string $attribute, array $value): self + { + return $this->push(Query::containsAny($attribute, $value)); + } + + /** + * @param array $value + */ + public function containsAll(string $attribute, array $value): self + { + return $this->push(Query::containsAll($attribute, $value)); + } + + public function notContains(string $attribute, mixed $value): self + { + return $this->push(Query::notContains($attribute, $value)); + } + + public function notSearch(string $attribute, string $value): self + { + return $this->push(Query::notSearch($attribute, $value)); + } + + public function notBetween(string $attribute, mixed $start, mixed $end): self + { + return $this->push(Query::notBetween($attribute, $start, $end)); + } + + public function notStartsWith(string $attribute, string $value): self + { + return $this->push(Query::notStartsWith($attribute, $value)); + } + + public function notEndsWith(string $attribute, string $value): self + { + return $this->push(Query::notEndsWith($attribute, $value)); + } + + public function regex(string $attribute, string $pattern): self + { + return $this->push(Query::regex($attribute, $pattern)); + } + + /** + * @param array $attributes + */ + public function exists(array $attributes): self + { + return $this->push(Query::exists($attributes)); + } + + /** + * @param array $attributes + */ + public function notExists(array $attributes): self + { + return $this->push(Query::notExists($attributes)); + } + + public function createdBefore(string $value): self + { + return $this->push(Query::createdBefore($value)); + } + + public function createdAfter(string $value): self + { + return $this->push(Query::createdAfter($value)); + } + + public function createdBetween(string $start, string $end): self + { + return $this->push(Query::createdBetween($start, $end)); + } + + public function updatedBefore(string $value): self + { + return $this->push(Query::updatedBefore($value)); + } + + public function updatedAfter(string $value): self + { + return $this->push(Query::updatedAfter($value)); + } + + public function updatedBetween(string $start, string $end): self + { + return $this->push(Query::updatedBetween($start, $end)); + } + + /** + * @param array $queries + */ + public function or(array $queries): self + { + return $this->push(Query::or($queries)); + } + + /** + * @param array $queries + */ + public function and(array $queries): self + { + return $this->push(Query::and($queries)); + } + + /** + * @param array $queries + */ + public function elemMatch(string $attribute, array $queries): self + { + return $this->push(Query::elemMatch($attribute, $queries)); + } + + public function relationship(string $attribute, array $queries): self + { + return $this->push(Query::relationship($attribute, $queries)); + } + + /** + * @param array $values + */ + public function distanceEqual(string $attribute, array $values, int|float $distance, bool $meters = true): self + { + return $this->push(Query::distanceEqual($attribute, $values, $distance, $meters)); + } + + /** + * @param array $values + */ + public function distanceNotEqual(string $attribute, array $values, int|float $distance, bool $meters = true): self + { + return $this->push(Query::distanceNotEqual($attribute, $values, $distance, $meters)); + } + + /** + * @param array $values + */ + public function distanceGreaterThan(string $attribute, array $values, int|float $distance, bool $meters = true): self + { + return $this->push(Query::distanceGreaterThan($attribute, $values, $distance, $meters)); + } + + /** + * @param array $values + */ + public function distanceLessThan(string $attribute, array $values, int|float $distance, bool $meters = true): self + { + return $this->push(Query::distanceLessThan($attribute, $values, $distance, $meters)); + } + + /** + * @param array $values + */ + public function intersects(string $attribute, array $values): self + { + return $this->push(Query::intersects($attribute, $values)); + } + + /** + * @param array $values + */ + public function notIntersects(string $attribute, array $values): self + { + return $this->push(Query::notIntersects($attribute, $values)); + } + + /** + * @param array $values + */ + public function crosses(string $attribute, array $values): self + { + return $this->push(Query::crosses($attribute, $values)); + } + + /** + * @param array $values + */ + public function notCrosses(string $attribute, array $values): self + { + return $this->push(Query::notCrosses($attribute, $values)); + } + + /** + * @param array $values + */ + public function overlaps(string $attribute, array $values): self + { + return $this->push(Query::overlaps($attribute, $values)); + } + + /** + * @param array $values + */ + public function notOverlaps(string $attribute, array $values): self + { + return $this->push(Query::notOverlaps($attribute, $values)); + } + + /** + * @param array $values + */ + public function touches(string $attribute, array $values): self + { + return $this->push(Query::touches($attribute, $values)); + } + + /** + * @param array $values + */ + public function notTouches(string $attribute, array $values): self + { + return $this->push(Query::notTouches($attribute, $values)); + } + + public function count(string $attribute = '*', string $alias = ''): self + { + return $this->push(Query::count($attribute, $alias)); + } + + public function countDistinct(string $attribute, string $alias = ''): self + { + return $this->push(Query::countDistinct($attribute, $alias)); + } + + public function sum(string $attribute, string $alias = ''): self + { + return $this->push(Query::sum($attribute, $alias)); + } + + public function avg(string $attribute, string $alias = ''): self + { + return $this->push(Query::avg($attribute, $alias)); + } + + public function min(string $attribute, string $alias = ''): self + { + return $this->push(Query::min($attribute, $alias)); + } + + public function max(string $attribute, string $alias = ''): self + { + return $this->push(Query::max($attribute, $alias)); + } + + public function stddev(string $attribute, string $alias = ''): self + { + return $this->push(Query::stddev($attribute, $alias)); + } + + public function stddevPop(string $attribute, string $alias = ''): self + { + return $this->push(Query::stddevPop($attribute, $alias)); + } + + public function stddevSamp(string $attribute, string $alias = ''): self + { + return $this->push(Query::stddevSamp($attribute, $alias)); + } + + public function variance(string $attribute, string $alias = ''): self + { + return $this->push(Query::variance($attribute, $alias)); + } + + public function varPop(string $attribute, string $alias = ''): self + { + return $this->push(Query::varPop($attribute, $alias)); + } + + public function varSamp(string $attribute, string $alias = ''): self + { + return $this->push(Query::varSamp($attribute, $alias)); + } + + public function bitAnd(string $attribute, string $alias = ''): self + { + return $this->push(Query::bitAnd($attribute, $alias)); + } + + public function bitOr(string $attribute, string $alias = ''): self + { + return $this->push(Query::bitOr($attribute, $alias)); + } + + public function bitXor(string $attribute, string $alias = ''): self + { + return $this->push(Query::bitXor($attribute, $alias)); + } + + /** + * @param array $attributes + */ + public function groupBy(array $attributes): self + { + return $this->push(Query::groupBy($attributes)); + } + + /** + * @param array $queries + */ + public function having(array $queries): self + { + return $this->push(Query::having($queries)); + } + + public function distinct(): self + { + return $this->push(Query::distinct()); + } + + /** + * @param string|array $leftOrAliasOrOn + * @param string|array $rightOrOn + */ + public function join(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): self + { + return $this->push(Query::join($table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias)); + } + + /** + * @param string|array $leftOrAliasOrOn + * @param string|array $rightOrOn + */ + public function leftJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): self + { + return $this->push(Query::leftJoin($table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias)); + } + + /** + * @param string|array $leftOrAliasOrOn + * @param string|array $rightOrOn + */ + public function rightJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): self + { + return $this->push(Query::rightJoin($table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias)); + } + + /** + * @param string|array $leftOrAliasOrOn + * @param string|array $rightOrOn + */ + public function fullOuterJoin(string $table, string|array $leftOrAliasOrOn, string|array $rightOrOn = '', string $operator = '=', string $alias = ''): self + { + return $this->push(Query::fullOuterJoin($table, $leftOrAliasOrOn, $rightOrOn, $operator, $alias)); + } + + public function crossJoin(string $table, string $alias = ''): self + { + return $this->push(Query::crossJoin($table, $alias)); + } + + /** + * @param array $vector + */ + public function vectorDot(string $attribute, array $vector): self + { + return $this->push(Query::vectorDot($attribute, $vector)); + } + + /** + * @param array $vector + */ + public function vectorCosine(string $attribute, array $vector): self + { + return $this->push(Query::vectorCosine($attribute, $vector)); + } + + /** + * @param array $vector + */ + public function vectorEuclidean(string $attribute, array $vector): self + { + return $this->push(Query::vectorEuclidean($attribute, $vector)); + } + + /** + * @param array $values + */ + public function covers(string $attribute, array $values): self + { + return $this->push(Query::covers($attribute, $values)); + } + + /** + * @param array $values + */ + public function notCovers(string $attribute, array $values): self + { + return $this->push(Query::notCovers($attribute, $values)); + } + + /** + * @param array $values + */ + public function spatialEquals(string $attribute, array $values): self + { + return $this->push(Query::spatialEquals($attribute, $values)); + } + + /** + * @param array $values + */ + public function notSpatialEquals(string $attribute, array $values): self + { + return $this->push(Query::notSpatialEquals($attribute, $values)); + } + + public function page(int $page, int $perPage = 25): self + { + return $this->push(Query::page($page, $perPage)); + } + + /** + * @param string|list $query + */ + private function push(string|array $query): self + { + if (\is_array($query)) { + array_push($this->queries, ...$query); + } else { + $this->queries[] = $query; + } + + return $this; + } +} diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 6caf55ff..74a1925d 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -144,6 +144,10 @@ public function listConsents(?array $queries = null, ?bool $total = null): \Appw */ public function getConsent(string $consentId): \Appwrite\Models\Oauth2Consent { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -180,6 +184,10 @@ public function getConsent(string $consentId): \Appwrite\Models\Oauth2Consent */ public function deleteConsent(string $consentId): string { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -211,6 +219,10 @@ public function deleteConsent(string $consentId): string */ public function listConsentTokens(string $consentId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\Oauth2ConsentTokenList { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + $apiPath = str_replace( ['{consentId}'], [$consentId], @@ -254,6 +266,14 @@ public function listConsentTokens(string $consentId, ?array $queries = null, ?bo */ public function getConsentToken(string $consentId, string $tokenId): \Appwrite\Models\Oauth2ConsentToken { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{consentId}', '{tokenId}'], [$consentId, $tokenId], @@ -291,6 +311,14 @@ public function getConsentToken(string $consentId, string $tokenId): \Appwrite\M */ public function deleteConsentToken(string $consentId, string $tokenId): string { + if ($consentId === '') { + throw new AppwriteException('Missing required parameter: "consentId"'); + } + + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{consentId}', '{tokenId}'], [$consentId, $tokenId], @@ -404,6 +432,10 @@ public function listIdentities(?array $queries = null, ?bool $total = null): \Ap */ public function deleteIdentity(string $identityId): string { + if ($identityId === '') { + throw new AppwriteException('Missing required parameter: "identityId"'); + } + $apiPath = str_replace( ['{identityId}'], [$identityId], @@ -416,6 +448,7 @@ public function deleteIdentity(string $identityId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -425,48 +458,6 @@ public function deleteIdentity(string $identityId): string ); } - /** - * Get the list of latest security activity logs for the currently logged in - * user. Each log returns user IP address, location and date and time of log. - * - * @throws AppwriteException - */ - public function listLogs(?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - [], - [], - '/account/logs' - ); - - $apiParams = []; - - 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); - } - /** * Enable or disable MFA on an account. * @@ -597,6 +588,7 @@ public function deleteMFAAuthenticator(AuthenticatorType $type): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1484,7 +1476,8 @@ public function listSessions(?bool $total = null): \Appwrite\Models\SessionList /** * Delete all sessions from the user account and remove any sessions cookies - * from the end client. + * from the end client. Pass `current` as false to keep the session making the + * request and sign out of every other session. * * @throws AppwriteException */ @@ -1505,6 +1498,7 @@ public function deleteSessions(?bool $current = null): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1557,6 +1551,9 @@ public function createAnonymousSession(): \Appwrite\Models\Session /** * Allow the user to login into their account by providing a valid email and * password combination. This route will create a new session for the user. + * Use the optional `duration` parameter to create a shorter session, for + * example when the user doesn't choose "remember me". It must be at least 60 + * seconds and cannot exceed the project maximum session length. * * A user is limited to 10 active sessions at a time by default. [Learn more * about session @@ -1816,6 +1813,10 @@ public function createSession(string $userId, string $secret): \Appwrite\Models\ */ public function getSession(string $sessionId): \Appwrite\Models\Session { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1852,6 +1853,10 @@ public function getSession(string $sessionId): \Appwrite\Models\Session */ public function updateSession(string $sessionId): \Appwrite\Models\Session { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1891,6 +1896,10 @@ public function updateSession(string $sessionId): \Appwrite\Models\Session */ public function deleteSession(string $sessionId): string { + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{sessionId}'], [$sessionId], @@ -1903,6 +1912,7 @@ public function deleteSession(string $sessionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2068,6 +2078,10 @@ public function createMagicURLToken(string $userId, string $email, ?string $url * session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) * endpoint. * + * If there is already an active session, the OAuth2 identity is attached to + * the logged-in account and that session stays active until the token is + * exchanged for a new one. + * * A user is limited to 10 active sessions at a time by default. [Learn more * about session * limits](https://appwrite.io/docs/authentication-security#limits). diff --git a/src/Appwrite/Services/Activities.php b/src/Appwrite/Services/Activities.php index 4cb0ebb3..c5398cf0 100644 --- a/src/Appwrite/Services/Activities.php +++ b/src/Appwrite/Services/Activities.php @@ -54,6 +54,10 @@ public function listEvents(?array $queries = null): \Appwrite\Models\ActivityEve */ public function getEvent(string $eventId): \Appwrite\Models\ActivityEvent { + if ($eventId === '') { + throw new AppwriteException('Missing required parameter: "eventId"'); + } + $apiPath = str_replace( ['{eventId}'], [$eventId], diff --git a/src/Appwrite/Services/Advisor.php b/src/Appwrite/Services/Advisor.php index c09f9170..cc99a1ea 100644 --- a/src/Appwrite/Services/Advisor.php +++ b/src/Appwrite/Services/Advisor.php @@ -60,6 +60,10 @@ public function listReports(?array $queries = null, ?bool $total = null): \Appwr */ public function getReport(string $reportId): \Appwrite\Models\Report { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -95,6 +99,10 @@ public function getReport(string $reportId): \Appwrite\Models\Report */ public function deleteReport(string $reportId): string { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -107,6 +115,7 @@ public function deleteReport(string $reportId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -124,6 +133,10 @@ public function deleteReport(string $reportId): string */ public function listInsights(string $reportId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\InsightList { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + $apiPath = str_replace( ['{reportId}'], [$reportId], @@ -166,6 +179,14 @@ public function listInsights(string $reportId, ?array $queries = null, ?bool $to */ public function getInsight(string $reportId, string $insightId): \Appwrite\Models\Insight { + if ($reportId === '') { + throw new AppwriteException('Missing required parameter: "reportId"'); + } + + if ($insightId === '') { + throw new AppwriteException('Missing required parameter: "insightId"'); + } + $apiPath = str_replace( ['{reportId}', '{insightId}'], [$reportId, $insightId], diff --git a/src/Appwrite/Services/Apps.php b/src/Appwrite/Services/Apps.php index c66741f0..64162fa7 100644 --- a/src/Appwrite/Services/Apps.php +++ b/src/Appwrite/Services/Apps.php @@ -225,6 +225,10 @@ public function listOAuth2Scopes(): \Appwrite\Models\AppScopeList */ public function get(string $appId): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -259,6 +263,10 @@ public function get(string $appId): \Appwrite\Models\App */ public function update(string $appId, string $name, ?string $description = null, ?string $clientUri = null, ?string $logoUri = null, ?string $privacyPolicyUrl = null, ?string $termsUrl = null, ?array $contacts = null, ?string $tagline = null, ?array $tags = null, ?array $images = null, ?string $supportUrl = null, ?string $dataDeletionUrl = null, ?bool $enabled = null, ?array $redirectUris = null, ?array $postLogoutRedirectUris = null, ?string $type = null, ?bool $deviceFlow = null, ?array $installationScopes = null, ?string $installationRedirectUrl = null): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -367,6 +375,10 @@ public function update(string $appId, string $name, ?string $description = null, */ public function delete(string $appId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -398,6 +410,10 @@ public function delete(string $appId): string */ public function listInstallations(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppInstallationList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -442,6 +458,14 @@ public function listInstallations(string $appId, ?array $queries = null, ?bool $ */ public function getInstallation(string $appId, string $installationId): \Appwrite\Models\AppInstallation { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -479,6 +503,14 @@ public function getInstallation(string $appId, string $installationId): \Appwrit */ public function deleteInstallation(string $appId, string $installationId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -516,6 +548,14 @@ public function deleteInstallation(string $appId, string $installationId): strin */ public function createInstallationToken(string $appId, string $installationId): \Appwrite\Models\Oauth2Token { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{appId}', '{installationId}'], [$appId, $installationId], @@ -552,6 +592,10 @@ public function createInstallationToken(string $appId, string $installationId): */ public function listKeys(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppKeyList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -596,6 +640,10 @@ public function listKeys(string $appId, ?array $queries = null, ?bool $total = n */ public function createKey(string $appId): \Appwrite\Models\AppKey { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -631,6 +679,14 @@ public function createKey(string $appId): \Appwrite\Models\AppKey */ public function getKey(string $appId, string $keyId): \Appwrite\Models\AppKey { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{appId}', '{keyId}'], [$appId, $keyId], @@ -666,6 +722,14 @@ public function getKey(string $appId, string $keyId): \Appwrite\Models\AppKey */ public function deleteKey(string $appId, string $keyId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{appId}', '{keyId}'], [$appId, $keyId], @@ -698,6 +762,10 @@ public function deleteKey(string $appId, string $keyId): string */ public function updateLabels(string $appId, array $labels): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -734,6 +802,10 @@ public function updateLabels(string $appId, array $labels): \Appwrite\Models\App */ public function listSecrets(string $appId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppSecretList { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -776,6 +848,10 @@ public function listSecrets(string $appId, ?array $queries = null, ?bool $total */ public function createSecret(string $appId): \Appwrite\Models\AppSecretPlaintext { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -811,6 +887,14 @@ public function createSecret(string $appId): \Appwrite\Models\AppSecretPlaintext */ public function getSecret(string $appId, string $secretId): \Appwrite\Models\AppSecret { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($secretId === '') { + throw new AppwriteException('Missing required parameter: "secretId"'); + } + $apiPath = str_replace( ['{appId}', '{secretId}'], [$appId, $secretId], @@ -846,6 +930,14 @@ public function getSecret(string $appId, string $secretId): \Appwrite\Models\App */ public function deleteSecret(string $appId, string $secretId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + + if ($secretId === '') { + throw new AppwriteException('Missing required parameter: "secretId"'); + } + $apiPath = str_replace( ['{appId}', '{secretId}'], [$appId, $secretId], @@ -876,6 +968,10 @@ public function deleteSecret(string $appId, string $secretId): string */ public function updateTeam(string $appId, string $teamId): \Appwrite\Models\App { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], @@ -912,6 +1008,10 @@ public function updateTeam(string $appId, string $teamId): \Appwrite\Models\App */ public function deleteTokens(string $appId): string { + if ($appId === '') { + throw new AppwriteException('Missing required parameter: "appId"'); + } + $apiPath = str_replace( ['{appId}'], [$appId], diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index ba8f5c11..eb5fa3a8 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -298,9 +298,9 @@ public function getInitials(?string $name = null, ?int $width = null, ?int $heig /** * Returns the best available profile photo for a user. The endpoint tries - * each source in priority order and returns the first successful result: - * OAuth2 identity photo, Gravatar, Libravatar, Appwrite Initials, built-in - * static fallback. + * each source in priority order and returns the first successful result: a + * custom uploaded photo (see avatars.updatePhoto), OAuth2 identity photo, + * Gravatar, Libravatar, Appwrite Initials, built-in static fallback. * * Passing `userId` — `current()` for the authenticated user — resolves * the photo from everything known about that user: identity photos, email, diff --git a/src/Appwrite/Services/Backups.php b/src/Appwrite/Services/Backups.php index b67014b4..9b22277b 100644 --- a/src/Appwrite/Services/Backups.php +++ b/src/Appwrite/Services/Backups.php @@ -90,6 +90,10 @@ public function createArchive(array $services, ?string $resourceId = null): \App */ public function getArchive(string $archiveId): \Appwrite\Models\BackupArchive { + if ($archiveId === '') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + $apiPath = str_replace( ['{archiveId}'], [$archiveId], @@ -124,6 +128,10 @@ public function getArchive(string $archiveId): \Appwrite\Models\BackupArchive */ public function deleteArchive(string $archiveId): string { + if ($archiveId === '') { + throw new AppwriteException('Missing required parameter: "archiveId"'); + } + $apiPath = str_replace( ['{archiveId}'], [$archiveId], @@ -237,6 +245,10 @@ public function createPolicy(string $policyId, array $services, int $retention, */ public function getPolicy(string $policyId): \Appwrite\Models\BackupPolicy { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -271,6 +283,10 @@ public function getPolicy(string $policyId): \Appwrite\Models\BackupPolicy */ public function updatePolicy(string $policyId, ?string $name = null, ?int $retention = null, ?string $schedule = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -313,6 +329,10 @@ public function updatePolicy(string $policyId, ?string $name = null, ?int $reten */ public function deletePolicy(string $policyId): string { + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{policyId}'], [$policyId], @@ -453,6 +473,10 @@ public function listRestorations(?array $queries = null): \Appwrite\Models\Backu */ public function getRestoration(string $restorationId): \Appwrite\Models\BackupRestoration { + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{restorationId}'], [$restorationId], diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 6dd497fe..60caec64 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -200,6 +200,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -237,6 +241,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -283,6 +291,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -295,6 +307,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -314,6 +327,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -357,6 +374,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -394,6 +415,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, ?string $name = null, ?bool $enabled = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -441,6 +466,10 @@ public function update(string $databaseId, ?string $name = null, ?bool $enabled */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -453,6 +482,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -473,6 +503,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\CollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -525,6 +559,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?array $attributes = null, ?array $indexes = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -583,6 +621,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -621,6 +667,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, ?string $name = null, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -678,6 +732,14 @@ public function updateCollection(string $databaseId, string $collectionId, ?stri */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -691,6 +753,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -710,6 +773,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listAttributes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AttributeList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -757,6 +828,14 @@ public function listAttributes(string $databaseId, string $collectionId, ?array */ public function createBigIntAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -806,6 +885,18 @@ public function createBigIntAttribute(string $databaseId, string $collectionId, */ public function updateBigIntAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\AttributeBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -851,6 +942,14 @@ public function updateBigIntAttribute(string $databaseId, string $collectionId, */ public function createBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -898,6 +997,18 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, */ public function updateBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -941,6 +1052,14 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, */ public function createDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -988,6 +1107,18 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId */ public function updateDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1031,6 +1162,14 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId */ public function createEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1078,6 +1217,18 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s */ public function updateEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1122,6 +1273,14 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s */ public function createEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1170,6 +1329,18 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st */ public function updateEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1215,6 +1386,14 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st */ public function createFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1264,6 +1443,18 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s */ public function updateFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): \Appwrite\Models\AttributeFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1310,6 +1501,14 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s */ public function createIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1359,6 +1558,18 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, */ public function updateIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\AttributeInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1404,6 +1615,14 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, */ public function createIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1451,6 +1670,18 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri */ public function updateIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1494,6 +1725,14 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri */ public function createLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributeLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1537,6 +1776,18 @@ public function createLineAttribute(string $databaseId, string $collectionId, st */ public function updateLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributeLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1580,6 +1831,14 @@ public function updateLineAttribute(string $databaseId, string $collectionId, st */ public function createLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1631,6 +1890,18 @@ public function createLongtextAttribute(string $databaseId, string $collectionId */ public function updateLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1674,6 +1945,14 @@ public function updateLongtextAttribute(string $databaseId, string $collectionId */ public function createMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1725,6 +2004,18 @@ public function createMediumtextAttribute(string $databaseId, string $collection */ public function updateMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1768,6 +2059,14 @@ public function updateMediumtextAttribute(string $databaseId, string $collection */ public function createPointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributePoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1811,6 +2110,18 @@ public function createPointAttribute(string $databaseId, string $collectionId, s */ public function updatePointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributePoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1854,6 +2165,14 @@ public function updatePointAttribute(string $databaseId, string $collectionId, s */ public function createPolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\AttributePolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1897,6 +2216,18 @@ public function createPolygonAttribute(string $databaseId, string $collectionId, */ public function updatePolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\AttributePolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1941,6 +2272,14 @@ public function updatePolygonAttribute(string $databaseId, string $collectionId, */ public function createRelationshipAttribute(string $databaseId, string $collectionId, string $relatedCollectionId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): \Appwrite\Models\AttributeRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1993,6 +2332,18 @@ public function createRelationshipAttribute(string $databaseId, string $collecti */ public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\AttributeRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2038,6 +2389,14 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti */ public function createStringAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2090,6 +2449,18 @@ public function createStringAttribute(string $databaseId, string $collectionId, */ public function updateStringAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2134,6 +2505,14 @@ public function updateStringAttribute(string $databaseId, string $collectionId, */ public function createTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\AttributeText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2185,6 +2564,18 @@ public function createTextAttribute(string $databaseId, string $collectionId, st */ public function updateTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2228,6 +2619,14 @@ public function updateTextAttribute(string $databaseId, string $collectionId, st */ public function createUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\AttributeUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2275,6 +2674,18 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str */ public function updateUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\AttributeUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2318,6 +2729,14 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str */ 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 { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2370,6 +2789,18 @@ public function createVarcharAttribute(string $databaseId, string $collectionId, */ public function updateVarcharAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\AttributeVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2412,8 +2843,20 @@ public function updateVarcharAttribute(string $databaseId, string $collectionId, * @deprecated This API has been deprecated since 1.8.0. Please use `getColumn` instead. * @see TablesDB::getColumn */ - public function getAttribute(string $databaseId, string $collectionId, string $key): \Appwrite\Models\AttributeBoolean|\Appwrite\Models\AttributeInteger|\Appwrite\Models\AttributeFloat|\Appwrite\Models\AttributeEmail|\Appwrite\Models\AttributeEnum|\Appwrite\Models\AttributeUrl|\Appwrite\Models\AttributeIp|\Appwrite\Models\AttributeDatetime|\Appwrite\Models\AttributeRelationship|\Appwrite\Models\AttributeString + public function getAttribute(string $databaseId, string $collectionId, string $key): \Appwrite\Models\AttributeBoolean|\Appwrite\Models\AttributeBigint|\Appwrite\Models\AttributeInteger|\Appwrite\Models\AttributeFloat|\Appwrite\Models\AttributeEmail|\Appwrite\Models\AttributeEnum|\Appwrite\Models\AttributeUrl|\Appwrite\Models\AttributeIp|\Appwrite\Models\AttributeDatetime|\Appwrite\Models\AttributeRelationship|\Appwrite\Models\AttributePoint|\Appwrite\Models\AttributeLine|\Appwrite\Models\AttributePolygon|\Appwrite\Models\AttributeVarchar|\Appwrite\Models\AttributeText|\Appwrite\Models\AttributeMediumtext|\Appwrite\Models\AttributeLongtext|\Appwrite\Models\AttributeString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2460,6 +2903,10 @@ public function getAttribute(string $databaseId, string $collectionId, string $k return \Appwrite\Models\AttributeBoolean::from($response); } + if (($response['type'] ?? null) === 'bigint') { + return \Appwrite\Models\AttributeBigint::from($response); + } + if (($response['type'] ?? null) === 'integer') { return \Appwrite\Models\AttributeInteger::from($response); } @@ -2476,6 +2923,34 @@ public function getAttribute(string $databaseId, string $collectionId, string $k return \Appwrite\Models\AttributeRelationship::from($response); } + if (($response['type'] ?? null) === 'point') { + return \Appwrite\Models\AttributePoint::from($response); + } + + if (($response['type'] ?? null) === 'linestring') { + return \Appwrite\Models\AttributeLine::from($response); + } + + if (($response['type'] ?? null) === 'polygon') { + return \Appwrite\Models\AttributePolygon::from($response); + } + + if (($response['type'] ?? null) === 'varchar') { + return \Appwrite\Models\AttributeVarchar::from($response); + } + + if (($response['type'] ?? null) === 'text') { + return \Appwrite\Models\AttributeText::from($response); + } + + if (($response['type'] ?? null) === 'mediumtext') { + return \Appwrite\Models\AttributeMediumtext::from($response); + } + + if (($response['type'] ?? null) === 'longtext') { + return \Appwrite\Models\AttributeLongtext::from($response); + } + if (($response['type'] ?? null) === 'string') { return \Appwrite\Models\AttributeString::from($response); } @@ -2493,6 +2968,18 @@ public function getAttribute(string $databaseId, string $collectionId, string $k */ public function deleteAttribute(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -2507,6 +2994,7 @@ public function deleteAttribute(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2527,6 +3015,14 @@ public function deleteAttribute(string $databaseId, string $collectionId, string */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2584,6 +3080,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2630,6 +3134,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2674,6 +3186,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2717,6 +3237,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2766,6 +3294,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -2814,6 +3350,18 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2864,6 +3412,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2911,6 +3471,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2957,6 +3529,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -2975,6 +3559,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2994,6 +3579,22 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -3041,6 +3642,22 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -3088,6 +3705,14 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -3127,7 +3752,9 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu /** * Creates an index on the attributes listed. Your index should include all * the attributes you will query in a single request. - * Attributes can be `key`, `fulltext`, and `unique`. + * Attributes can be `key`, `fulltext`, `unique`, `spatial`, and `trigram`. + * `trigram` is only available on PostgreSQL and lets `contains`, + * `startsWith`, and `endsWith` queries on string attributes use an index. * * @throws AppwriteException * @@ -3136,6 +3763,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, DatabasesIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -3186,6 +3821,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -3225,6 +3872,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -3239,6 +3898,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/DocumentsDB.php b/src/Appwrite/Services/DocumentsDB.php index 4e0e734f..efaef6eb 100644 --- a/src/Appwrite/Services/DocumentsDB.php +++ b/src/Appwrite/Services/DocumentsDB.php @@ -104,8 +104,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -223,6 +223,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -257,6 +261,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -300,6 +308,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -312,6 +324,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -328,6 +341,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -368,6 +385,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -402,6 +423,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, string $name, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -446,6 +471,10 @@ public function update(string $databaseId, string $name, ?bool $enabled = null, */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -458,6 +487,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -475,6 +505,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\CollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -524,6 +558,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?array $attributes = null, ?array $indexes = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -579,6 +617,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -614,6 +660,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Collection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -668,6 +722,14 @@ public function updateCollection(string $databaseId, string $collectionId, strin */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -681,6 +743,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -698,6 +761,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -752,6 +823,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -801,6 +880,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -845,6 +932,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -888,6 +983,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -937,6 +1040,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -982,6 +1093,18 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1029,6 +1152,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1079,6 +1214,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1128,6 +1275,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1146,6 +1305,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1162,6 +1322,22 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -1212,6 +1388,22 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + + if ($attribute === '') { + throw new AppwriteException('Missing required parameter: "attribute"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], [$databaseId, $collectionId, $documentId, $attribute], @@ -1262,6 +1454,14 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1307,6 +1507,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, DocumentsDBIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1354,6 +1562,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1390,6 +1610,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1404,6 +1636,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1428,6 +1661,10 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1467,6 +1704,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1514,6 +1755,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1550,6 +1795,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index d1bb5dda..7ad73978 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -268,6 +268,10 @@ public function listSpecifications(?string $type = null, ?bool $total = null): \ */ public function get(string $functionId): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -300,8 +304,12 @@ public function get(string $functionId): \Appwrite\Models\FunctionModel * * @throws AppwriteException */ - public function update(string $functionId, string $name, ?Runtime $runtime = null, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?int $interval = null): \Appwrite\Models\FunctionModel + public function update(string $functionId, string $name, ?Runtime $runtime = null, ?array $execute = null, ?array $events = null, ?string $schedule = null, ?int $timeout = null, ?bool $enabled = null, ?bool $logging = null, ?string $entrypoint = null, ?string $commands = null, ?array $scopes = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?int $interval = null, ?bool $emailEnabled = null): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -377,6 +385,7 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul $apiParams['deploymentRetention'] = $deploymentRetention; } $apiParams['interval'] = $interval; + $apiParams['emailEnabled'] = $emailEnabled; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -404,6 +413,10 @@ public function update(string $functionId, string $name, ?Runtime $runtime = nul */ public function delete(string $functionId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -416,6 +429,7 @@ public function delete(string $functionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -433,6 +447,10 @@ public function delete(string $functionId): string */ public function updateFunctionDeployment(string $functionId, string $deploymentId): \Appwrite\Models\FunctionModel { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -470,6 +488,10 @@ public function updateFunctionDeployment(string $functionId, string $deploymentI */ public function listDeployments(string $functionId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\DeploymentList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -525,6 +547,10 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str */ public function createDeployment(string $functionId, InputFile $code, bool $activate, ?string $entrypoint = null, ?string $commands = null, ?callable $onProgress = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -548,9 +574,6 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($code->getPath() ?? null)) { $size = strlen($code->getData()); $mimeType = $code->getMimeType(); @@ -704,6 +727,10 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti */ public function createDuplicateDeployment(string $functionId, string $deploymentId, ?string $buildId = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -748,6 +775,10 @@ public function createDuplicateDeployment(string $functionId, string $deployment */ public function createTemplateDeployment(string $functionId, string $repository, string $owner, string $rootDirectory, TemplateReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -794,6 +825,10 @@ public function createTemplateDeployment(string $functionId, string $repository, */ public function createVcsDeployment(string $functionId, VCSReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -835,6 +870,14 @@ public function createVcsDeployment(string $functionId, VCSReferenceType $type, */ public function getDeployment(string $functionId, string $deploymentId): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -870,6 +913,14 @@ public function getDeployment(string $functionId, string $deploymentId): \Appwri */ public function deleteDeployment(string $functionId, string $deploymentId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -883,6 +934,7 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -901,6 +953,14 @@ public function deleteDeployment(string $functionId, string $deploymentId): stri */ public function getDeploymentDownload(string $functionId, string $deploymentId, ?DeploymentDownloadType $type = null, ?string $token = null): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -942,6 +1002,14 @@ public function getDeploymentDownload(string $functionId, string $deploymentId, */ public function updateDeploymentStatus(string $functionId, string $deploymentId): \Appwrite\Models\Deployment { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{functionId}', '{deploymentId}'], [$functionId, $deploymentId], @@ -979,6 +1047,10 @@ public function updateDeploymentStatus(string $functionId, string $deploymentId) */ public function listExecutions(string $functionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ExecutionList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1024,6 +1096,10 @@ public function listExecutions(string $functionId, ?array $queries = null, ?bool */ public function createExecution(string $functionId, ?string $body = null, ?bool $async = null, ?string $xpath = null, ?ExecutionMethod $method = null, ?array $headers = null, ?string $scheduledAt = null): \Appwrite\Models\Execution { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1080,6 +1156,14 @@ public function createExecution(string $functionId, ?string $body = null, ?bool */ public function getExecution(string $functionId, string $executionId): \Appwrite\Models\Execution { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($executionId === '') { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + $apiPath = str_replace( ['{functionId}', '{executionId}'], [$functionId, $executionId], @@ -1115,6 +1199,14 @@ public function getExecution(string $functionId, string $executionId): \Appwrite */ public function deleteExecution(string $functionId, string $executionId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($executionId === '') { + throw new AppwriteException('Missing required parameter: "executionId"'); + } + $apiPath = str_replace( ['{functionId}', '{executionId}'], [$functionId, $executionId], @@ -1128,6 +1220,7 @@ public function deleteExecution(string $functionId, string $executionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1144,6 +1237,10 @@ public function deleteExecution(string $functionId, string $executionId): string */ public function listVariables(string $functionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\VariableList { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1187,6 +1284,10 @@ public function listVariables(string $functionId, ?array $queries = null, ?bool */ public function createVariable(string $functionId, string $variableId, string $key, string $value, ?bool $secret = null): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + $apiPath = str_replace( ['{functionId}'], [$functionId], @@ -1229,6 +1330,14 @@ public function createVariable(string $functionId, string $variableId, string $k */ public function getVariable(string $functionId, string $variableId): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1264,6 +1373,14 @@ public function getVariable(string $functionId, string $variableId): \Appwrite\M */ public function updateVariable(string $functionId, string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1303,6 +1420,14 @@ public function updateVariable(string $functionId, string $variableId, ?string $ */ public function deleteVariable(string $functionId, string $variableId): string { + if ($functionId === '') { + throw new AppwriteException('Missing required parameter: "functionId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{functionId}', '{variableId}'], [$functionId, $variableId], @@ -1316,6 +1441,7 @@ public function deleteVariable(string $functionId, string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Messaging.php b/src/Appwrite/Services/Messaging.php index 053d0e67..af0072de 100644 --- a/src/Appwrite/Services/Messaging.php +++ b/src/Appwrite/Services/Messaging.php @@ -94,10 +94,7 @@ public function createEmail(string $messageId, string $subject, string $content, if (!is_null($bcc)) { $apiParams['bcc'] = $bcc; } - - if (!is_null($attachments)) { - $apiParams['attachments'] = $attachments; - } + $apiParams['attachments'] = $attachments; if (!is_null($draft)) { $apiParams['draft'] = $draft; @@ -144,6 +141,10 @@ public function createEmail(string $messageId, string $subject, string $content, */ public function updateEmail(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $subject = null, ?string $content = null, ?bool $draft = null, ?bool $html = null, ?array $cc = null, ?array $bcc = null, ?string $scheduledAt = null, ?array $attachments = null, ?string $replyToEmail = null, ?string $replyToName = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -299,6 +300,10 @@ public function createPush(string $messageId, ?string $title = null, ?string $bo */ public function updatePush(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $title = null, ?string $body = null, ?array $data = null, ?string $action = null, ?string $image = null, ?string $icon = null, ?string $sound = null, ?string $color = null, ?string $tag = null, ?int $badge = null, ?bool $draft = null, ?string $scheduledAt = null, ?bool $contentAvailable = null, ?bool $critical = null, ?MessagePriority $priority = null, ?string $channelId = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -408,6 +413,10 @@ public function createSMS(string $messageId, string $content, ?array $topics = n */ public function updateSMS(string $messageId, ?array $topics = null, ?array $users = null, ?array $targets = null, ?string $content = null, ?bool $draft = null, ?string $scheduledAt = null): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -449,6 +458,10 @@ public function updateSMS(string $messageId, ?array $topics = null, ?array $user */ public function getMessage(string $messageId): \Appwrite\Models\Message { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -484,6 +497,10 @@ public function getMessage(string $messageId): \Appwrite\Models\Message */ public function delete(string $messageId): string { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -496,6 +513,7 @@ public function delete(string $messageId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -512,6 +530,10 @@ public function delete(string $messageId): string */ public function listTargets(string $messageId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\TargetList { + if ($messageId === '') { + throw new AppwriteException('Missing required parameter: "messageId"'); + } + $apiPath = str_replace( ['{messageId}'], [$messageId], @@ -656,6 +678,10 @@ public function createAPNSProvider(string $providerId, string $name, ?string $au */ public function updateAPNSProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $authKey = null, ?string $authKeyId = null, ?string $teamId = null, ?string $bundleId = null, ?bool $sandbox = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -836,6 +862,10 @@ public function createFCMProvider(string $providerId, string $name, ?array $serv */ public function updateFCMProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?array $serviceAccountJSON = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -939,6 +969,10 @@ public function createMailgunProvider(string $providerId, string $name, ?string */ public function updateMailgunProvider(string $providerId, ?string $name = null, ?string $apiKey = null, ?string $domain = null, ?bool $isEuRegion = null, ?bool $enabled = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1053,6 +1087,10 @@ public function createMsg91Provider(string $providerId, string $name, ?string $t */ public function updateMsg91Provider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $templateId = null, ?string $senderId = null, ?string $authKey = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1162,6 +1200,10 @@ public function createResendProvider(string $providerId, string $name, ?string $ */ public function updateResendProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1279,6 +1321,10 @@ public function createSendgridProvider(string $providerId, string $name, ?string */ public function updateSendgridProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1404,6 +1450,10 @@ public function createSesProvider(string $providerId, string $name, ?string $acc */ public function updateSesProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $accessKey = null, ?string $secretKey = null, ?string $region = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1550,6 +1600,10 @@ public function createSMTPProvider(string $providerId, string $name, string $hos */ public function updateSMTPProvider(string $providerId, ?string $name = null, ?string $host = null, ?int $port = null, ?string $username = null, ?string $password = null, ?SmtpEncryption $encryption = null, ?bool $autoTLS = null, ?string $mailer = null, ?string $fromName = null, ?string $fromEmail = null, ?string $replyToName = null, ?string $replyToEmail = null, ?bool $enabled = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1677,6 +1731,10 @@ public function createTelesignProvider(string $providerId, string $name, ?string */ public function updateTelesignProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $customerId = null, ?string $apiKey = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1778,6 +1836,10 @@ public function createTextmagicProvider(string $providerId, string $name, ?strin */ public function updateTextmagicProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $username = null, ?string $apiKey = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1879,6 +1941,10 @@ public function createTwilioProvider(string $providerId, string $name, ?string $ */ public function updateTwilioProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $accountSid = null, ?string $authToken = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -1980,6 +2046,10 @@ public function createVonageProvider(string $providerId, string $name, ?string $ */ public function updateVonageProvider(string $providerId, ?string $name = null, ?bool $enabled = null, ?string $apiKey = null, ?string $apiSecret = null, ?string $from = null): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2032,6 +2102,10 @@ public function updateVonageProvider(string $providerId, ?string $name = null, ? */ public function getProvider(string $providerId): \Appwrite\Models\Provider { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2066,6 +2140,10 @@ public function getProvider(string $providerId): \Appwrite\Models\Provider */ public function deleteProvider(string $providerId): string { + if ($providerId === '') { + throw new AppwriteException('Missing required parameter: "providerId"'); + } + $apiPath = str_replace( ['{providerId}'], [$providerId], @@ -2078,6 +2156,7 @@ public function deleteProvider(string $providerId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2181,6 +2260,10 @@ public function createTopic(string $topicId, string $name, ?array $subscribe = n */ public function getTopic(string $topicId): \Appwrite\Models\Topic { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2215,6 +2298,10 @@ public function getTopic(string $topicId): \Appwrite\Models\Topic */ public function updateTopic(string $topicId, ?string $name = null, ?array $subscribe = null, ?int $qos = null, ?int $expiry = null): \Appwrite\Models\Topic { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2254,6 +2341,10 @@ public function updateTopic(string $topicId, ?string $name = null, ?array $subsc */ public function deleteTopic(string $topicId): string { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2266,6 +2357,7 @@ public function deleteTopic(string $topicId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2282,6 +2374,10 @@ public function deleteTopic(string $topicId): string */ public function listSubscribers(string $topicId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\SubscriberList { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2328,6 +2424,10 @@ public function listSubscribers(string $topicId, ?array $queries = null, ?string */ public function createSubscriber(string $topicId, string $subscriberId, string $targetId): \Appwrite\Models\Subscriber { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + $apiPath = str_replace( ['{topicId}'], [$topicId], @@ -2365,6 +2465,14 @@ public function createSubscriber(string $topicId, string $subscriberId, string $ */ public function getSubscriber(string $topicId, string $subscriberId): \Appwrite\Models\Subscriber { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + if ($subscriberId === '') { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + $apiPath = str_replace( ['{topicId}', '{subscriberId}'], [$topicId, $subscriberId], @@ -2400,6 +2508,14 @@ public function getSubscriber(string $topicId, string $subscriberId): \Appwrite\ */ public function deleteSubscriber(string $topicId, string $subscriberId): string { + if ($topicId === '') { + throw new AppwriteException('Missing required parameter: "topicId"'); + } + + if ($subscriberId === '') { + throw new AppwriteException('Missing required parameter: "subscriberId"'); + } + $apiPath = str_replace( ['{topicId}', '{subscriberId}'], [$topicId, $subscriberId], @@ -2413,6 +2529,7 @@ public function deleteSubscriber(string $topicId, string $subscriberId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Mongo.php b/src/Appwrite/Services/Mongo.php index 21771ece..82e35d35 100644 --- a/src/Appwrite/Services/Mongo.php +++ b/src/Appwrite/Services/Mongo.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -849,6 +938,10 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -887,6 +980,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -927,6 +1024,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -967,6 +1068,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1014,6 +1119,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1049,6 +1158,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1084,6 +1197,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1133,10 +1250,25 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st * an ISO 8601 datetime. PITR requires the database to have PITR enabled and * is only available for enterprise databases. * + * By default the backup is replayed over the database it was taken from. Pass + * `restoreMode` as `clone` to recover it onto a second workload beside this + * database instead: this database keeps serving its own data while the clone + * is filled, and the switch happens as soon as the clone is ready, on the + * endpoint and credentials it already had. Pass `autoPromote` as false to + * hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + * to recover onto a separate database with its own endpoint, either one you + * name with `targetDatabaseId` or one provisioned as a copy of this + * database's engine, version, specification and replicas. Neither mode is + * available for a point-in-time recovery or an incremental backup. + * * @throws AppwriteException */ - public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration + public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null, ?string $restoreMode = null, ?string $targetName = null, ?bool $autoPromote = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1152,6 +1284,12 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str $apiParams['backupId'] = $backupId; $apiParams['targetDatabaseId'] = $targetDatabaseId; $apiParams['targetTime'] = $targetTime; + $apiParams['restoreMode'] = $restoreMode; + $apiParams['targetName'] = $targetName; + + if (!is_null($autoPromote)) { + $apiParams['autoPromote'] = $autoPromote; + } $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -1180,6 +1318,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1208,6 +1354,55 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw return \Appwrite\Models\DedicatedDatabaseRestoration::from($response); } + /** + * Switch the database over to the clone a restoration recovered. The database + * keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained + * briefly so + * the switch can be reversed. + * + * @throws AppwriteException + */ + public function promoteRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration + { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + + $apiPath = str_replace( + ['{databaseId}', '{restorationId}'], + [$databaseId, $restorationId], + '/mongo/{databaseId}/restorations/{restorationId}/promotions' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['restorationId'] = $restorationId; + + $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\DedicatedDatabaseRestoration::from($response); + } + /** * Get real-time health and status information for a dedicated database. * Returns health status, readiness, uptime, connection info, replica status, @@ -1217,6 +1412,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1252,6 +1451,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Mysql.php b/src/Appwrite/Services/Mysql.php index 95f4cd35..f3f089ee 100644 --- a/src/Appwrite/Services/Mysql.php +++ b/src/Appwrite/Services/Mysql.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -844,11 +933,19 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate * without a per-query cloud round-trip. The statement type must be on the * database's configured allow-list. Use bound parameters for any * user-supplied values — the API does not interpolate raw strings. + * Long-running statements (for example CREATE INDEX) can outlive the HTTP + * request: if the request ends before a result is returned, check the + * database before retrying, and prefer a direct connection for work that may + * take minutes. * * @throws AppwriteException */ public function createExecution(string $databaseId, string $sql, ?array $bindings = null, ?int $timeoutSeconds = null): \Appwrite\Models\DedicatedDatabaseExecution { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -895,6 +992,10 @@ public function createExecution(string $databaseId, string $sql, ?array $binding */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -933,6 +1034,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -973,6 +1078,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1013,6 +1122,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1060,6 +1173,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1095,6 +1212,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1130,6 +1251,10 @@ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabas */ public function updatePooler(string $databaseId, ?string $mode = null, ?int $maxConnections = null, ?int $defaultPoolSize = null, ?bool $readWriteSplitting = null, ?string $poolerCpuRequest = null, ?string $poolerCpuLimit = null, ?string $poolerMemoryRequest = null, ?string $poolerMemoryLimit = null): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1174,6 +1299,10 @@ public function updatePooler(string $databaseId, ?string $mode = null, ?int $max */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1209,6 +1338,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1258,10 +1391,25 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st * an ISO 8601 datetime. PITR requires the database to have PITR enabled and * is only available for enterprise databases. * + * By default the backup is replayed over the database it was taken from. Pass + * `restoreMode` as `clone` to recover it onto a second workload beside this + * database instead: this database keeps serving its own data while the clone + * is filled, and the switch happens as soon as the clone is ready, on the + * endpoint and credentials it already had. Pass `autoPromote` as false to + * hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + * to recover onto a separate database with its own endpoint, either one you + * name with `targetDatabaseId` or one provisioned as a copy of this + * database's engine, version, specification and replicas. Neither mode is + * available for a point-in-time recovery or an incremental backup. + * * @throws AppwriteException */ - public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration + public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null, ?string $restoreMode = null, ?string $targetName = null, ?bool $autoPromote = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1277,6 +1425,12 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str $apiParams['backupId'] = $backupId; $apiParams['targetDatabaseId'] = $targetDatabaseId; $apiParams['targetTime'] = $targetTime; + $apiParams['restoreMode'] = $restoreMode; + $apiParams['targetName'] = $targetName; + + if (!is_null($autoPromote)) { + $apiParams['autoPromote'] = $autoPromote; + } $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -1305,6 +1459,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1333,6 +1495,55 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw return \Appwrite\Models\DedicatedDatabaseRestoration::from($response); } + /** + * Switch the database over to the clone a restoration recovered. The database + * keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained + * briefly so + * the switch can be reversed. + * + * @throws AppwriteException + */ + public function promoteRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration + { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + + $apiPath = str_replace( + ['{databaseId}', '{restorationId}'], + [$databaseId, $restorationId], + '/mysql/{databaseId}/restorations/{restorationId}/promotions' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['restorationId'] = $restorationId; + + $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\DedicatedDatabaseRestoration::from($response); + } + /** * Get real-time health and status information for a dedicated database. * Returns health status, readiness, uptime, connection info, replica status, @@ -1342,6 +1553,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1377,6 +1592,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Oauth2.php b/src/Appwrite/Services/Oauth2.php index 45d4927a..e246e345 100644 --- a/src/Appwrite/Services/Oauth2.php +++ b/src/Appwrite/Services/Oauth2.php @@ -65,7 +65,7 @@ public function approve(string $grantId, ?string $authorizationDetails = null, ? * * @throws AppwriteException */ - public function authorize(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize + public function authorize(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize { $apiPath = str_replace( ['{project_id}'], @@ -157,7 +157,7 @@ public function authorize(?string $clientId = null, ?string $redirectUri = null, * * @throws AppwriteException */ - public function authorizePost(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize + public function authorizePost(?string $clientId = null, ?string $redirectUri = null, ?string $responseType = null, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null, ?string $requestUri = null): \Appwrite\Models\Oauth2Authorize { $apiPath = str_replace( ['{project_id}'], @@ -244,7 +244,7 @@ public function authorizePost(?string $clientId = null, ?string $redirectUri = n * * @throws AppwriteException */ - public function createDeviceAuthorization(?string $clientId = null, ?string $scope = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2DeviceAuthorization + public function createDeviceAuthorization(?string $clientId = null, ?string $scope = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2DeviceAuthorization { $apiPath = str_replace( ['{project_id}'], @@ -338,6 +338,10 @@ public function createGrant(string $userCode): \Appwrite\Models\Oauth2Grant */ public function getGrant(string $grantId): \Appwrite\Models\Oauth2Grant { + if ($grantId === '') { + throw new AppwriteException('Missing required parameter: "grantId"'); + } + $apiPath = str_replace( ['{project_id}', '{grant_id}'], [$this->client->getConfig('project'), $grantId], @@ -465,7 +469,7 @@ public function listOrganizations(?int $limit = null, ?int $offset = null, ?stri * * @throws AppwriteException */ - public function createPAR(string $clientId, string $redirectUri, string $responseType, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2PAR + public function createPAR(string $clientId, string $redirectUri, string $responseType, ?string $scope = null, ?string $state = null, ?string $nonce = null, ?string $codeChallenge = null, ?string $codeChallengeMethod = null, ?string $prompt = null, ?int $maxAge = null, ?string $authorizationDetails = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2PAR { $apiPath = str_replace( ['{project_id}'], @@ -662,7 +666,7 @@ public function revoke(string $token, ?string $tokenTypeHint = null, ?string $cl * * @throws AppwriteException */ - public function createToken(string $grantType, ?string $code = null, ?string $refreshToken = null, ?string $deviceCode = null, ?string $clientId = null, ?string $clientSecret = null, ?string $codeVerifier = null, ?string $redirectUri = null, ?string $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2Token + public function createToken(string $grantType, ?string $code = null, ?string $refreshToken = null, ?string $deviceCode = null, ?string $clientId = null, ?string $clientSecret = null, ?string $codeVerifier = null, ?string $redirectUri = null, ?array $resource = null, ?string $audience = null): \Appwrite\Models\Oauth2Token { $apiPath = str_replace( ['{project_id}'], diff --git a/src/Appwrite/Services/Organization.php b/src/Appwrite/Services/Organization.php index 3b572126..d8be8f07 100644 --- a/src/Appwrite/Services/Organization.php +++ b/src/Appwrite/Services/Organization.php @@ -98,6 +98,7 @@ public function delete(): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -198,6 +199,10 @@ public function createInstallation(string $appId, ?string $authorizationDetails */ public function getInstallation(string $installationId): \Appwrite\Models\AppInstallation { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -235,6 +240,10 @@ public function getInstallation(string $installationId): \Appwrite\Models\AppIns */ public function updateInstallation(string $installationId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -273,6 +282,10 @@ public function updateInstallation(string $installationId, ?string $authorizatio */ public function deleteInstallation(string $installationId): string { + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{installationId}'], [$installationId], @@ -295,188 +308,6 @@ public function deleteInstallation(string $installationId): string ); } - /** - * Get a list of all API keys from the current organization. - * - * @throws AppwriteException - */ - public function listKeys(?array $queries = null, ?bool $total = null): \Appwrite\Models\KeyList - { - $apiPath = str_replace( - [], - [], - '/organization/keys' - ); - - $apiParams = []; - - 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\KeyList::from($response); - } - - /** - * Create a new organization API key. - * - * @throws AppwriteException - */ - public function createKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key - { - $apiPath = str_replace( - [], - [], - '/organization/keys' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - $apiParams['name'] = $name; - $apiParams['scopes'] = $scopes; - $apiParams['expire'] = $expire; - - $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\Key::from($response); - } - - /** - * Get a key by its unique ID. This endpoint returns details about a specific - * API key in your organization including its scopes. - * - * @throws AppwriteException - */ - public function getKey(string $keyId): \Appwrite\Models\Key - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - - $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\Key::from($response); - } - - /** - * Update a key by its unique ID. Use this endpoint to update the name, - * scopes, or expiration time of an API key. - * - * @throws AppwriteException - */ - public function updateKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - $apiParams['name'] = $name; - $apiParams['scopes'] = $scopes; - $apiParams['expire'] = $expire; - - $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\Key::from($response); - } - - /** - * Delete a key by its unique ID. Once deleted, the key can no longer be used - * to authenticate API calls. - * - * @throws AppwriteException - */ - public function deleteKey(string $keyId): string - { - $apiPath = str_replace( - ['{keyId}'], - [$keyId], - '/organization/keys/{keyId}' - ); - - $apiParams = []; - $apiParams['keyId'] = $keyId; - - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - /** * Get a list of all memberships from the current organization. * @@ -586,6 +417,10 @@ public function createMembership(array $roles, ?string $email = null, ?string $u */ public function getMembership(string $membershipId): \Appwrite\Models\Membership { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -620,6 +455,10 @@ public function getMembership(string $membershipId): \Appwrite\Models\Membership */ public function updateMembership(string $membershipId, array $roles): \Appwrite\Models\Membership { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -658,6 +497,10 @@ public function updateMembership(string $membershipId, array $roles): \Appwrite\ */ public function deleteMembership(string $membershipId): string { + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{membershipId}'], [$membershipId], @@ -670,6 +513,7 @@ public function deleteMembership(string $membershipId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -772,6 +616,10 @@ public function createProject(string $projectId, string $name, ?Region $region = */ public function getProject(string $projectId): \Appwrite\Models\Project { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -783,6 +631,7 @@ public function getProject(string $projectId): \Appwrite\Models\Project $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; $response = $this->client->call( Client::METHOD_GET, @@ -805,6 +654,10 @@ public function getProject(string $projectId): \Appwrite\Models\Project */ public function updateProject(string $projectId, string $name): \Appwrite\Models\Project { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -841,6 +694,10 @@ public function updateProject(string $projectId, string $name): \Appwrite\Models */ public function deleteProject(string $projectId): string { + if ($projectId === '') { + throw new AppwriteException('Missing required parameter: "projectId"'); + } + $apiPath = str_replace( ['{projectId}'], [$projectId], @@ -853,6 +710,7 @@ public function deleteProject(string $projectId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Postgresql.php b/src/Appwrite/Services/Postgresql.php index 536e5730..dfc1c870 100644 --- a/src/Appwrite/Services/Postgresql.php +++ b/src/Appwrite/Services/Postgresql.php @@ -99,10 +99,7 @@ public function create(string $databaseId, string $name, ?string $version = null if (!is_null($storageAutoscalingThresholdPercent)) { $apiParams['storageAutoscalingThresholdPercent'] = $storageAutoscalingThresholdPercent; } - - if (!is_null($storageAutoscalingMaxGb)) { - $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; - } + $apiParams['storageAutoscalingMaxGb'] = $storageAutoscalingMaxGb; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -125,8 +122,8 @@ public function create(string $databaseId, string $name, ?string $version = null /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -166,6 +163,10 @@ public function listSpecifications(): \Appwrite\Models\DedicatedDatabaseSpecific */ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -203,6 +204,10 @@ public function get(string $databaseId): \Appwrite\Models\DedicatedDatabase */ public function update(string $databaseId, ?string $name = null, ?string $status = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null, ?int $networkIdleTimeoutSeconds = null, ?array $networkIPAllowlist = null, ?int $idleTimeoutMinutes = null, ?bool $pitr = null, ?int $pitrRetentionDays = null, ?bool $storageAutoscaling = null, ?int $storageAutoscalingThresholdPercent = null, ?int $storageAutoscalingMaxGb = null, ?float $metricsTraceSampleRate = null, ?int $metricsSlowQueryLogThresholdMs = null, ?bool $sqlApiEnabled = null, ?array $sqlApiAllowedStatements = null, ?int $sqlApiMaxRows = null, ?int $sqlApiMaxBytes = null, ?int $sqlApiTimeoutSeconds = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -261,6 +266,10 @@ public function update(string $databaseId, ?string $name = null, ?string $status */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -291,6 +300,10 @@ public function delete(string $databaseId): string */ public function listBackups(string $databaseId, ?array $queries = null): \Appwrite\Models\DedicatedDatabaseBackupList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -330,6 +343,10 @@ public function listBackups(string $databaseId, ?array $queries = null): \Appwri */ public function createBackup(string $databaseId, ?string $type = null): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -369,6 +386,10 @@ public function createBackup(string $databaseId, ?string $type = null): \Appwrit */ public function listBackupPolicies(string $databaseId, ?array $queries = null): \Appwrite\Models\BackupPolicyList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -407,6 +428,10 @@ public function listBackupPolicies(string $databaseId, ?array $queries = null): */ public function createBackupPolicy(string $databaseId, string $policyId, string $name, string $schedule, int $retention, ?string $type = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -454,6 +479,14 @@ public function createBackupPolicy(string $databaseId, string $policyId, string */ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -489,6 +522,14 @@ public function getBackupPolicy(string $databaseId, string $policyId): \Appwrite */ public function updateBackupPolicy(string $databaseId, string $policyId, ?string $name = null, ?string $schedule = null, ?int $retention = null, ?bool $enabled = null): \Appwrite\Models\BackupPolicy { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -533,6 +574,14 @@ public function updateBackupPolicy(string $databaseId, string $policyId, ?string */ public function deleteBackupPolicy(string $databaseId, string $policyId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($policyId === '') { + throw new AppwriteException('Missing required parameter: "policyId"'); + } + $apiPath = str_replace( ['{databaseId}', '{policyId}'], [$databaseId, $policyId], @@ -565,6 +614,10 @@ public function deleteBackupPolicy(string $databaseId, string $policyId): string */ public function updateBackupStorage(string $databaseId, string $provider, string $bucket, string $accessKey, string $secretKey, ?string $region = null, ?string $prefix = null, ?string $endpoint = null): \Appwrite\Models\DedicatedDatabaseBackupStorage { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -617,6 +670,14 @@ public function updateBackupStorage(string $databaseId, string $provider, string */ public function getBackup(string $databaseId, string $backupId): \Appwrite\Models\DedicatedDatabaseBackup { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -653,6 +714,14 @@ public function getBackup(string $databaseId, string $backupId): \Appwrite\Model */ public function deleteBackup(string $databaseId, string $backupId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($backupId === '') { + throw new AppwriteException('Missing required parameter: "backupId"'); + } + $apiPath = str_replace( ['{databaseId}', '{backupId}'], [$databaseId, $backupId], @@ -684,6 +753,10 @@ public function deleteBackup(string $databaseId, string $backupId): string */ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedDatabaseBranchList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -722,6 +795,10 @@ public function listBranches(string $databaseId): \Appwrite\Models\DedicatedData */ public function createBranch(string $databaseId, ?string $branchId = null, ?int $ttl = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -767,6 +844,14 @@ public function createBranch(string $databaseId, ?string $branchId = null, ?int */ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($branchId === '') { + throw new AppwriteException('Missing required parameter: "branchId"'); + } + $apiPath = str_replace( ['{databaseId}', '{branchId}'], [$databaseId, $branchId], @@ -806,6 +891,10 @@ public function deleteBranch(string $databaseId, string $branchId): \Appwrite\Mo */ public function updateCredentials(string $databaseId): \Appwrite\Models\DedicatedDatabaseOperation { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -844,11 +933,19 @@ public function updateCredentials(string $databaseId): \Appwrite\Models\Dedicate * without a per-query cloud round-trip. The statement type must be on the * database's configured allow-list. Use bound parameters for any * user-supplied values — the API does not interpolate raw strings. + * Long-running statements (for example CREATE INDEX) can outlive the HTTP + * request: if the request ends before a result is returned, check the + * database before retrying, and prefer a direct connection for work that may + * take minutes. * * @throws AppwriteException */ public function createExecution(string $databaseId, string $sql, ?array $bindings = null, ?int $timeoutSeconds = null): \Appwrite\Models\DedicatedDatabaseExecution { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -887,6 +984,10 @@ public function createExecution(string $databaseId, string $sql, ?array $binding */ public function listExtensions(string $databaseId): \Appwrite\Models\DedicatedDatabaseExtensions { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -922,6 +1023,10 @@ public function listExtensions(string $databaseId): \Appwrite\Models\DedicatedDa */ public function createExtension(string $databaseId, string $name): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -959,6 +1064,14 @@ public function createExtension(string $databaseId, string $name): \Appwrite\Mod */ public function deleteExtension(string $databaseId, string $extensionName): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($extensionName === '') { + throw new AppwriteException('Missing required parameter: "extensionName"'); + } + $apiPath = str_replace( ['{databaseId}', '{extensionName}'], [$databaseId, $extensionName], @@ -1003,6 +1116,10 @@ public function deleteExtension(string $databaseId, string $extensionName): \App */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1041,6 +1158,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function updateMaintenance(string $databaseId, string $day, int $hourUtc): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1081,6 +1202,10 @@ public function updateMaintenance(string $databaseId, string $day, int $hourUtc) */ public function createMigration(string $databaseId, string $targetType, ?string $specification = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1121,6 +1246,10 @@ public function createMigration(string $databaseId, string $targetType, ?string */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1168,6 +1297,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabasePITRWindows { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1203,6 +1336,10 @@ public function getPitr(string $databaseId): \Appwrite\Models\DedicatedDatabaseP */ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1238,6 +1375,10 @@ public function getPooler(string $databaseId): \Appwrite\Models\DedicatedDatabas */ public function updatePooler(string $databaseId, ?string $mode = null, ?int $maxConnections = null, ?int $defaultPoolSize = null, ?bool $readWriteSplitting = null, ?string $poolerCpuRequest = null, ?string $poolerCpuLimit = null, ?string $poolerMemoryRequest = null, ?string $poolerMemoryLimit = null): \Appwrite\Models\DedicatedDatabasePooler { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1282,6 +1423,10 @@ public function updatePooler(string $databaseId, ?string $mode = null, ?int $max */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1317,6 +1462,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function listRestorations(string $databaseId, ?string $status = null, ?string $type = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseRestorationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1366,10 +1515,25 @@ public function listRestorations(string $databaseId, ?string $status = null, ?st * an ISO 8601 datetime. PITR requires the database to have PITR enabled and * is only available for enterprise databases. * + * By default the backup is replayed over the database it was taken from. Pass + * `restoreMode` as `clone` to recover it onto a second workload beside this + * database instead: this database keeps serving its own data while the clone + * is filled, and the switch happens as soon as the clone is ready, on the + * endpoint and credentials it already had. Pass `autoPromote` as false to + * hold the clone until you promote it yourself. Pass `restoreMode` as `copy` + * to recover onto a separate database with its own endpoint, either one you + * name with `targetDatabaseId` or one provisioned as a copy of this + * database's engine, version, specification and replicas. Neither mode is + * available for a point-in-time recovery or an incremental backup. + * * @throws AppwriteException */ - public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null): \Appwrite\Models\DedicatedDatabaseRestoration + public function createRestoration(string $databaseId, ?string $type = null, ?string $backupId = null, ?string $targetDatabaseId = null, ?string $targetTime = null, ?string $restoreMode = null, ?string $targetName = null, ?bool $autoPromote = null): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1385,6 +1549,12 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str $apiParams['backupId'] = $backupId; $apiParams['targetDatabaseId'] = $targetDatabaseId; $apiParams['targetTime'] = $targetTime; + $apiParams['restoreMode'] = $restoreMode; + $apiParams['targetName'] = $targetName; + + if (!is_null($autoPromote)) { + $apiParams['autoPromote'] = $autoPromote; + } $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -1413,6 +1583,14 @@ public function createRestoration(string $databaseId, ?string $type = null, ?str */ public function getRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{restorationId}'], [$databaseId, $restorationId], @@ -1441,6 +1619,55 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw return \Appwrite\Models\DedicatedDatabaseRestoration::from($response); } + /** + * Switch the database over to the clone a restoration recovered. The database + * keeps + * its endpoint and credentials; clients reconnect once. Writes made after the + * recovery point are discarded, and the side being replaced is retained + * briefly so + * the switch can be reversed. + * + * @throws AppwriteException + */ + public function promoteRestoration(string $databaseId, string $restorationId): \Appwrite\Models\DedicatedDatabaseRestoration + { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($restorationId === '') { + throw new AppwriteException('Missing required parameter: "restorationId"'); + } + + $apiPath = str_replace( + ['{databaseId}', '{restorationId}'], + [$databaseId, $restorationId], + '/postgresql/{databaseId}/restorations/{restorationId}/promotions' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['restorationId'] = $restorationId; + + $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\DedicatedDatabaseRestoration::from($response); + } + /** * Get real-time health and status information for a dedicated database. * Returns health status, readiness, uptime, connection info, replica status, @@ -1450,6 +1677,10 @@ public function getRestoration(string $databaseId, string $restorationId): \Appw */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1485,6 +1716,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function createUpgrade(string $databaseId, string $targetVersion): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Presences.php b/src/Appwrite/Services/Presences.php index 80f429c9..5a04fc40 100644 --- a/src/Appwrite/Services/Presences.php +++ b/src/Appwrite/Services/Presences.php @@ -63,6 +63,10 @@ public function list(?array $queries = null, ?bool $total = null, ?int $ttl = nu */ public function get(string $presenceId): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -97,6 +101,10 @@ public function get(string $presenceId): \Appwrite\Models\Presence */ public function upsert(string $presenceId, string $userId, string $status, ?array $permissions = null, ?string $expiresAt = null, ?array $metadata = null): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -147,6 +155,10 @@ public function upsert(string $presenceId, string $userId, string $status, ?arra */ public function update(string $presenceId, string $userId, ?string $status = null, ?string $expiresAt = null, ?array $metadata = null, ?array $permissions = null, ?bool $purge = null): \Appwrite\Models\Presence { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -203,6 +215,10 @@ public function update(string $presenceId, string $userId, ?string $status = nul */ public function delete(string $presenceId): string { + if ($presenceId === '') { + throw new AppwriteException('Missing required parameter: "presenceId"'); + } + $apiPath = str_replace( ['{presenceId}'], [$presenceId], @@ -215,6 +231,7 @@ public function delete(string $presenceId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Project.php b/src/Appwrite/Services/Project.php index 05577731..223a6273 100644 --- a/src/Appwrite/Services/Project.php +++ b/src/Appwrite/Services/Project.php @@ -35,6 +35,7 @@ public function get(): \Appwrite\Models\Project $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); + $apiHeaders['accept'] = 'application/json'; $response = $this->client->call( Client::METHOD_GET, @@ -68,6 +69,7 @@ public function delete(): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -393,6 +395,10 @@ public function createEphemeralKey(array $scopes, int $duration): \Appwrite\Mode */ public function getKey(string $keyId): \Appwrite\Models\Key { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -428,6 +434,10 @@ public function getKey(string $keyId): \Appwrite\Models\Key */ public function updateKey(string $keyId, string $name, array $scopes, ?string $expire = null): \Appwrite\Models\Key { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -467,6 +477,10 @@ public function updateKey(string $keyId, string $name, array $scopes, ?string $e */ public function deleteKey(string $keyId): string { + if ($keyId === '') { + throw new AppwriteException('Missing required parameter: "keyId"'); + } + $apiPath = str_replace( ['{keyId}'], [$keyId], @@ -479,6 +493,7 @@ public function deleteKey(string $keyId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -611,6 +626,10 @@ public function createMockPhone(string $number, string $otp): \Appwrite\Models\M */ public function getMockPhone(string $number): \Appwrite\Models\MockNumber { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -646,6 +665,10 @@ public function getMockPhone(string $number): \Appwrite\Models\MockNumber */ public function updateMockPhone(string $number, string $otp): \Appwrite\Models\MockNumber { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -683,6 +706,10 @@ public function updateMockPhone(string $number, string $otp): \Appwrite\Models\M */ public function deleteMockPhone(string $number): string { + if ($number === '') { + throw new AppwriteException('Missing required parameter: "number"'); + } + $apiPath = str_replace( ['{number}'], [$number], @@ -695,6 +722,7 @@ public function deleteMockPhone(string $number): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1648,7 +1676,7 @@ public function updateOAuth2HuggingFace(?string $clientId = null, ?string $clien * * @throws AppwriteException */ - public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecret = null, ?array $prompt = null, ?bool $enabled = null): \Appwrite\Models\OAuth2Kakao + public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecret = null, ?bool $enabled = null, ?array $prompt = null): \Appwrite\Models\OAuth2Kakao { $apiPath = str_replace( [], @@ -1659,8 +1687,8 @@ public function updateOAuth2Kakao(?string $clientId = null, ?string $clientSecre $apiParams = []; $apiParams['clientId'] = $clientId; $apiParams['clientSecret'] = $clientSecret; - $apiParams['prompt'] = $prompt; $apiParams['enabled'] = $enabled; + $apiParams['prompt'] = $prompt; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -2964,12 +2992,16 @@ public function createAndroidPlatform(string $platformId, string $name, string $ /** * Update an Android platform by its unique ID. Use this endpoint to update - * the platform's name or application ID. + * the platform's name, application ID or signing certificate fingerprints. * * @throws AppwriteException */ public function updateAndroidPlatform(string $platformId, string $name, string $applicationId, ?array $fingerprints = null): \Appwrite\Models\PlatformAndroid { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3048,6 +3080,10 @@ public function createApplePlatform(string $platformId, string $name, string $bu */ public function updateApplePlatform(string $platformId, string $name, string $bundleIdentifier): \Appwrite\Models\PlatformApple { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3125,6 +3161,10 @@ public function createLinuxPlatform(string $platformId, string $name, string $pa */ public function updateLinuxPlatform(string $platformId, string $name, string $packageName): \Appwrite\Models\PlatformLinux { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3202,6 +3242,10 @@ public function createWebPlatform(string $platformId, string $name, string $host */ public function updateWebPlatform(string $platformId, string $name, string $hostname): \Appwrite\Models\PlatformWeb { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3279,6 +3323,10 @@ public function createWindowsPlatform(string $platformId, string $name, string $ */ public function updateWindowsPlatform(string $platformId, string $name, string $packageIdentifierName): \Appwrite\Models\PlatformWindows { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3317,6 +3365,10 @@ public function updateWindowsPlatform(string $platformId, string $name, string $ */ public function getPlatform(string $platformId): \Appwrite\Models\PlatformWeb|\Appwrite\Models\PlatformApple|\Appwrite\Models\PlatformAndroid|\Appwrite\Models\PlatformWindows|\Appwrite\Models\PlatformLinux { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3372,6 +3424,10 @@ public function getPlatform(string $platformId): \Appwrite\Models\PlatformWeb|\A */ public function deletePlatform(string $platformId): string { + if ($platformId === '') { + throw new AppwriteException('Missing required parameter: "platformId"'); + } + $apiPath = str_replace( ['{platformId}'], [$platformId], @@ -3384,6 +3440,7 @@ public function deletePlatform(string $platformId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -4432,6 +4489,7 @@ public function createSMTPTest(array $emails): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_POST, @@ -4660,6 +4718,10 @@ public function createVariable(string $variableId, string $key, string $value, ? */ public function getVariable(string $variableId): \Appwrite\Models\Variable { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4694,6 +4756,10 @@ public function getVariable(string $variableId): \Appwrite\Models\Variable */ public function updateVariable(string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4732,6 +4798,10 @@ public function updateVariable(string $variableId, ?string $key = null, ?string */ public function deleteVariable(string $variableId): string { + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{variableId}'], [$variableId], @@ -4744,6 +4814,7 @@ public function deleteVariable(string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Proxy.php b/src/Appwrite/Services/Proxy.php index 4b04c9e1..70d2d1b4 100644 --- a/src/Appwrite/Services/Proxy.php +++ b/src/Appwrite/Services/Proxy.php @@ -20,6 +20,8 @@ class Proxy extends Service * Depending on type, the invalidation purges a single cache tag, a single URL * path, or all cached content for the domain. * + * Domains that route to a function do not support cache invalidation. + * * @throws AppwriteException */ public function createInvalidation(string $domain, InvalidationType $type, ?string $reference = null): \Appwrite\Models\ProxyInvalidation @@ -266,6 +268,47 @@ public function createSiteRule(string $domain, string $siteId, ?string $branch = return \Appwrite\Models\ProxyRule::from($response); } + /** + * Create an SMTP ingress rule that asynchronously executes an Appwrite + * Function for incoming email. + * + * @throws AppwriteException + */ + public function createSMTPRule(string $domain, string $functionId, ?string $branch = null): \Appwrite\Models\ProxyRule + { + $apiPath = str_replace( + [], + [], + '/proxy/rules/smtp' + ); + + $apiParams = []; + $apiParams['domain'] = $domain; + $apiParams['functionId'] = $functionId; + + if (!is_null($branch)) { + $apiParams['branch'] = $branch; + } + + $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\ProxyRule::from($response); + } + /** * Get a proxy rule by its unique ID. * @@ -273,6 +316,10 @@ public function createSiteRule(string $domain, string $siteId, ?string $branch = */ public function getRule(string $ruleId): \Appwrite\Models\ProxyRule { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], @@ -307,6 +354,10 @@ public function getRule(string $ruleId): \Appwrite\Models\ProxyRule */ public function deleteRule(string $ruleId): string { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], @@ -319,6 +370,7 @@ public function deleteRule(string $ruleId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -338,6 +390,10 @@ public function deleteRule(string $ruleId): string */ public function updateRuleStatus(string $ruleId): \Appwrite\Models\ProxyRule { + if ($ruleId === '') { + throw new AppwriteException('Missing required parameter: "ruleId"'); + } + $apiPath = str_replace( ['{ruleId}'], [$ruleId], diff --git a/src/Appwrite/Services/Sites.php b/src/Appwrite/Services/Sites.php index 3aeb94d8..c585adaa 100644 --- a/src/Appwrite/Services/Sites.php +++ b/src/Appwrite/Services/Sites.php @@ -268,6 +268,10 @@ public function listSpecifications(?string $type = null, ?bool $total = null): \ */ public function get(string $siteId): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -302,6 +306,10 @@ public function get(string $siteId): \Appwrite\Models\Site */ public function update(string $siteId, string $name, Framework $framework, ?bool $enabled = null, ?bool $logging = null, ?int $timeout = null, ?string $installCommand = null, ?string $buildCommand = null, ?string $startCommand = null, ?string $outputDirectory = null, ?BuildRuntime $buildRuntime = null, ?Adapter $adapter = null, ?string $fallbackFile = null, ?string $installationId = null, ?string $providerRepositoryId = null, ?string $providerBranch = null, ?bool $providerSilentMode = null, ?string $providerRootDirectory = null, ?array $providerBranches = null, ?array $providerPaths = null, ?string $buildSpecification = null, ?string $runtimeSpecification = null, ?int $deploymentRetention = null, ?array $scopes = null): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -356,10 +364,7 @@ public function update(string $siteId, string $name, Framework $framework, ?bool if (!is_null($installationId)) { $apiParams['installationId'] = $installationId; } - - if (!is_null($providerRepositoryId)) { - $apiParams['providerRepositoryId'] = $providerRepositoryId; - } + $apiParams['providerRepositoryId'] = $providerRepositoryId; if (!is_null($providerBranch)) { $apiParams['providerBranch'] = $providerBranch; @@ -411,6 +416,10 @@ public function update(string $siteId, string $name, Framework $framework, ?bool */ public function delete(string $siteId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -423,6 +432,7 @@ public function delete(string $siteId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -440,6 +450,10 @@ public function delete(string $siteId): string */ public function updateSiteDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Site { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -477,6 +491,10 @@ public function updateSiteDeployment(string $siteId, string $deploymentId): \App */ public function listDeployments(string $siteId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\DeploymentList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -525,6 +543,10 @@ public function listDeployments(string $siteId, ?array $queries = null, ?string */ public function createDeployment(string $siteId, InputFile $code, ?string $installCommand = null, ?string $buildCommand = null, ?string $outputDirectory = null, ?bool $activate = null, ?callable $onProgress = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -555,9 +577,6 @@ public function createDeployment(string $siteId, InputFile $code, ?string $insta $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($code->getPath() ?? null)) { $size = strlen($code->getData()); $mimeType = $code->getMimeType(); @@ -711,6 +730,10 @@ public function createDeployment(string $siteId, InputFile $code, ?string $insta */ public function createDuplicateDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -751,6 +774,10 @@ public function createDuplicateDeployment(string $siteId, string $deploymentId): */ public function createTemplateDeployment(string $siteId, string $repository, string $owner, string $rootDirectory, TemplateReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -797,6 +824,10 @@ public function createTemplateDeployment(string $siteId, string $repository, str */ public function createVcsDeployment(string $siteId, VCSReferenceType $type, string $reference, ?bool $activate = null): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -838,6 +869,14 @@ public function createVcsDeployment(string $siteId, VCSReferenceType $type, stri */ public function getDeployment(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -873,6 +912,14 @@ public function getDeployment(string $siteId, string $deploymentId): \Appwrite\M */ public function deleteDeployment(string $siteId, string $deploymentId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -886,6 +933,7 @@ public function deleteDeployment(string $siteId, string $deploymentId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -904,6 +952,14 @@ public function deleteDeployment(string $siteId, string $deploymentId): string */ public function getDeploymentDownload(string $siteId, string $deploymentId, ?DeploymentDownloadType $type = null, ?string $token = null): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -945,6 +1001,14 @@ public function getDeploymentDownload(string $siteId, string $deploymentId, ?Dep */ public function updateDeploymentStatus(string $siteId, string $deploymentId): \Appwrite\Models\Deployment { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($deploymentId === '') { + throw new AppwriteException('Missing required parameter: "deploymentId"'); + } + $apiPath = str_replace( ['{siteId}', '{deploymentId}'], [$siteId, $deploymentId], @@ -982,6 +1046,10 @@ public function updateDeploymentStatus(string $siteId, string $deploymentId): \A */ public function listLogs(string $siteId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ExecutionList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1024,6 +1092,14 @@ public function listLogs(string $siteId, ?array $queries = null, ?bool $total = */ public function getLog(string $siteId, string $logId): \Appwrite\Models\Execution { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($logId === '') { + throw new AppwriteException('Missing required parameter: "logId"'); + } + $apiPath = str_replace( ['{siteId}', '{logId}'], [$siteId, $logId], @@ -1059,6 +1135,14 @@ public function getLog(string $siteId, string $logId): \Appwrite\Models\Executio */ public function deleteLog(string $siteId, string $logId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($logId === '') { + throw new AppwriteException('Missing required parameter: "logId"'); + } + $apiPath = str_replace( ['{siteId}', '{logId}'], [$siteId, $logId], @@ -1089,6 +1173,10 @@ public function deleteLog(string $siteId, string $logId): string */ public function listVariables(string $siteId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\VariableList { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1132,6 +1220,10 @@ public function listVariables(string $siteId, ?array $queries = null, ?bool $tot */ public function createVariable(string $siteId, string $variableId, string $key, string $value, ?bool $secret = null): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + $apiPath = str_replace( ['{siteId}'], [$siteId], @@ -1174,6 +1266,14 @@ public function createVariable(string $siteId, string $variableId, string $key, */ public function getVariable(string $siteId, string $variableId): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1209,6 +1309,14 @@ public function getVariable(string $siteId, string $variableId): \Appwrite\Model */ public function updateVariable(string $siteId, string $variableId, ?string $key = null, ?string $value = null, ?bool $secret = null): \Appwrite\Models\Variable { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1248,6 +1356,14 @@ public function updateVariable(string $siteId, string $variableId, ?string $key */ public function deleteVariable(string $siteId, string $variableId): string { + if ($siteId === '') { + throw new AppwriteException('Missing required parameter: "siteId"'); + } + + if ($variableId === '') { + throw new AppwriteException('Missing required parameter: "variableId"'); + } + $apiPath = str_replace( ['{siteId}', '{variableId}'], [$siteId, $variableId], @@ -1261,6 +1377,7 @@ public function deleteVariable(string $siteId, string $variableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index ed3a2e93..2382a1f4 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -138,6 +138,10 @@ public function createBucket(string $bucketId, string $name, ?array $permissions */ public function getBucket(string $bucketId): \Appwrite\Models\Bucket { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -172,6 +176,10 @@ public function getBucket(string $bucketId): \Appwrite\Models\Bucket */ public function updateBucket(string $bucketId, string $name, ?array $permissions = null, ?bool $fileSecurity = null, ?bool $enabled = null, ?int $maximumFileSize = null, ?array $allowedFileExtensions = null, ?Compression $compression = null, ?bool $encryption = null, ?bool $antivirus = null, ?bool $transformations = null): \Appwrite\Models\Bucket { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -190,22 +198,13 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; } - - if (!is_null($maximumFileSize)) { - $apiParams['maximumFileSize'] = $maximumFileSize; - } + $apiParams['maximumFileSize'] = $maximumFileSize; if (!is_null($allowedFileExtensions)) { $apiParams['allowedFileExtensions'] = $allowedFileExtensions; } - - if (!is_null($compression)) { - $apiParams['compression'] = $compression; - } - - if (!is_null($encryption)) { - $apiParams['encryption'] = $encryption; - } + $apiParams['compression'] = $compression; + $apiParams['encryption'] = $encryption; if (!is_null($antivirus)) { $apiParams['antivirus'] = $antivirus; @@ -241,6 +240,10 @@ public function updateBucket(string $bucketId, string $name, ?array $permissions */ public function deleteBucket(string $bucketId): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -253,6 +256,7 @@ public function deleteBucket(string $bucketId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -270,6 +274,10 @@ public function deleteBucket(string $bucketId): string */ public function listFiles(string $bucketId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\FileList { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -332,6 +340,10 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea */ public function createFile(string $bucketId, string $fileId, InputFile $file, ?array $permissions = null, ?string $folder = null, ?callable $onProgress = null): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + $apiPath = str_replace( ['{bucketId}'], [$bucketId], @@ -355,9 +367,6 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'multipart/form-data'; $apiHeaders['accept'] = 'application/json'; - $size = 0; - $mimeType = null; - $postedName = null; if (empty($file->getPath() ?? null)) { $size = strlen($file->getData()); $mimeType = $file->getMimeType(); @@ -521,6 +530,14 @@ public function createFile(string $bucketId, string $fileId, InputFile $file, ?a */ public function getFile(string $bucketId, string $fileId): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -557,6 +574,14 @@ public function getFile(string $bucketId, string $fileId): \Appwrite\Models\File */ public function updateFile(string $bucketId, string $fileId, ?string $name = null, ?array $permissions = null): \Appwrite\Models\File { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -599,6 +624,14 @@ public function updateFile(string $bucketId, string $fileId, ?string $name = nul */ public function deleteFile(string $bucketId, string $fileId): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -612,6 +645,7 @@ public function deleteFile(string $bucketId, string $fileId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -630,6 +664,14 @@ public function deleteFile(string $bucketId, string $fileId): string */ public function getFileDownload(string $bucketId, string $fileId, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -667,6 +709,14 @@ public function getFileDownload(string $bucketId, string $fileId, ?string $token */ public function getFilePreview(string $bucketId, string $fileId, ?int $width = null, ?int $height = null, ?ImageGravity $gravity = null, ?int $quality = null, ?int $borderWidth = null, ?string $borderColor = null, ?int $borderRadius = null, ?float $opacity = null, ?int $rotation = null, ?string $background = null, ?ImageFormat $output = null, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -746,6 +796,14 @@ public function getFilePreview(string $bucketId, string $fileId, ?int $width = n */ public function getFileView(string $bucketId, string $fileId, ?string $token = null): string { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], diff --git a/src/Appwrite/Services/TablesDB.php b/src/Appwrite/Services/TablesDB.php index 4ec544bd..025cc01f 100644 --- a/src/Appwrite/Services/TablesDB.php +++ b/src/Appwrite/Services/TablesDB.php @@ -110,8 +110,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -229,6 +229,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -263,6 +267,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -306,6 +314,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -318,6 +330,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -334,6 +347,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -374,6 +391,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -408,6 +429,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, ?string $name = null, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -455,6 +480,10 @@ public function update(string $databaseId, ?string $name = null, ?bool $enabled */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -467,6 +496,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -491,6 +521,10 @@ public function delete(string $databaseId): string */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -528,6 +562,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listMigrations(string $databaseId): \Appwrite\Models\DatabaseMigrationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -557,13 +595,22 @@ public function listMigrations(string $databaseId): \Appwrite\Models\DatabaseMig /** * Start migrating a serverless TablesDB database onto a dedicated MySQL - * compute. Data is copied to the target while the source stays live, with a - * brief read-only window during cutover. + * compute. Data is copied to the target while the source stays live. Reads + * continue throughout. Row writes are held for up to a few seconds while + * routing switches to the dedicated compute; a write the switch has not + * absorbed within that hold is refused with `database_migration_cutover` and + * can be retried. Schema changes (tables, columns, indexes) are refused from + * creation until the cutover completes, and resume once the migration is + * `soaking`. * * @throws AppwriteException */ public function createMigration(string $databaseId, string $specification, ?bool $autoCutover = null): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -604,6 +651,14 @@ public function createMigration(string $databaseId, string $specification, ?bool */ public function getMigration(string $databaseId, string $migrationId): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -640,6 +695,14 @@ public function getMigration(string $databaseId, string $migrationId): \Appwrite */ public function deleteMigration(string $databaseId, string $migrationId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -667,14 +730,25 @@ public function deleteMigration(string $databaseId, string $migrationId): string * Cut a verified TablesDB migration over to its dedicated compute. Only * applies to a migration created with `autoCutover` disabled, which waits at * `ready_to_cutover` until this is called. The routing flip happens shortly - * after this returns, with a brief read-only window. One call buys one - * attempt: a cutover that fails a check returns the migration to `verifying` - * and parks it again, so call this once more to retry. + * after this returns. Reads are unaffected; row writes are held for up to a + * few seconds while it lands, and a write the flip has not absorbed within + * that hold is refused with `database_migration_cutover` and can be retried. + * One call buys one attempt: a cutover that fails a check returns the + * migration to `verifying` and parks it again, so call this once more to + * retry. * * @throws AppwriteException */ public function createCutover(string $databaseId, string $migrationId): \Appwrite\Models\DatabaseMigration { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($migrationId === '') { + throw new AppwriteException('Missing required parameter: "migrationId"'); + } + $apiPath = str_replace( ['{databaseId}', '{migrationId}'], [$databaseId, $migrationId], @@ -714,6 +788,10 @@ public function createCutover(string $databaseId, string $migrationId): \Appwrit */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -761,6 +839,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -797,6 +879,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -832,6 +918,10 @@ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus */ public function listTables(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\TableList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -881,6 +971,10 @@ public function listTables(string $databaseId, ?array $queries = null, ?string $ */ public function createTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null, ?array $columns = null, ?array $indexes = null): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -936,6 +1030,14 @@ public function createTable(string $databaseId, string $tableId, string $name, ? */ public function getTable(string $databaseId, string $tableId): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -971,6 +1073,14 @@ public function getTable(string $databaseId, string $tableId): \Appwrite\Models\ */ public function updateTable(string $databaseId, string $tableId, ?string $name = null, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null, ?bool $purge = null): \Appwrite\Models\Table { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1025,6 +1135,14 @@ public function updateTable(string $databaseId, string $tableId, ?string $name = */ public function deleteTable(string $databaseId, string $tableId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1038,6 +1156,7 @@ public function deleteTable(string $databaseId, string $tableId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1054,6 +1173,14 @@ public function deleteTable(string $databaseId, string $tableId): string */ public function listColumns(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ColumnList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1098,6 +1225,14 @@ public function listColumns(string $databaseId, string $tableId, ?array $queries */ public function createBigIntColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1144,6 +1279,18 @@ public function createBigIntColumn(string $databaseId, string $tableId, string $ */ public function updateBigIntColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\ColumnBigint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1186,6 +1333,14 @@ public function updateBigIntColumn(string $databaseId, string $tableId, string $ */ public function createBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1230,6 +1385,18 @@ public function createBooleanColumn(string $databaseId, string $tableId, string */ public function updateBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnBoolean { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1270,6 +1437,14 @@ public function updateBooleanColumn(string $databaseId, string $tableId, string */ public function createDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1314,6 +1489,18 @@ public function createDatetimeColumn(string $databaseId, string $tableId, string */ public function updateDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnDatetime { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1354,6 +1541,14 @@ public function updateDatetimeColumn(string $databaseId, string $tableId, string */ public function createEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1398,6 +1593,18 @@ public function createEmailColumn(string $databaseId, string $tableId, string $k */ public function updateEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnEmail { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1439,6 +1646,14 @@ public function updateEmailColumn(string $databaseId, string $tableId, string $k */ public function createEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1484,6 +1699,18 @@ public function createEnumColumn(string $databaseId, string $tableId, string $ke */ public function updateEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnEnum { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1526,6 +1753,14 @@ public function updateEnumColumn(string $databaseId, string $tableId, string $ke */ public function createFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1572,6 +1807,18 @@ public function createFloatColumn(string $databaseId, string $tableId, string $k */ public function updateFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): \Appwrite\Models\ColumnFloat { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1615,6 +1862,14 @@ public function updateFloatColumn(string $databaseId, string $tableId, string $k */ public function createIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1661,6 +1916,18 @@ public function createIntegerColumn(string $databaseId, string $tableId, string */ public function updateIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): \Appwrite\Models\ColumnInteger { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1703,6 +1970,14 @@ public function updateIntegerColumn(string $databaseId, string $tableId, string */ public function createIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1747,6 +2022,18 @@ public function createIpColumn(string $databaseId, string $tableId, string $key, */ public function updateIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnIp { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1787,6 +2074,14 @@ public function updateIpColumn(string $databaseId, string $tableId, string $key, */ public function createLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1827,6 +2122,18 @@ public function createLineColumn(string $databaseId, string $tableId, string $ke */ public function updateLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnLine { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1867,6 +2174,14 @@ public function updateLineColumn(string $databaseId, string $tableId, string $ke */ public function createLongtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -1915,6 +2230,18 @@ public function createLongtextColumn(string $databaseId, string $tableId, string */ public function updateLongtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnLongtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -1955,6 +2282,14 @@ public function updateLongtextColumn(string $databaseId, string $tableId, string */ public function createMediumtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2003,6 +2338,18 @@ public function createMediumtextColumn(string $databaseId, string $tableId, stri */ public function updateMediumtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnMediumtext { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2043,6 +2390,14 @@ public function updateMediumtextColumn(string $databaseId, string $tableId, stri */ public function createPointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnPoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2083,6 +2438,18 @@ public function createPointColumn(string $databaseId, string $tableId, string $k */ public function updatePointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnPoint { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2123,6 +2490,14 @@ public function updatePointColumn(string $databaseId, string $tableId, string $k */ public function createPolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): \Appwrite\Models\ColumnPolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2163,6 +2538,18 @@ public function createPolygonColumn(string $databaseId, string $tableId, string */ public function updatePolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): \Appwrite\Models\ColumnPolygon { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2204,6 +2591,14 @@ public function updatePolygonColumn(string $databaseId, string $tableId, string */ public function createRelationshipColumn(string $databaseId, string $tableId, string $relatedTableId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): \Appwrite\Models\ColumnRelationship { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2245,6 +2640,58 @@ public function createRelationshipColumn(string $databaseId, string $tableId, st return \Appwrite\Models\ColumnRelationship::from($response); } + /** + * Update relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * @throws AppwriteException + */ + public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\ColumnRelationship + { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/relationship/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['onDelete'] = $onDelete; + $apiParams['newKey'] = $newKey; + + $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\ColumnRelationship::from($response); + } + /** * Create a string column. * @@ -2255,6 +2702,14 @@ public function createRelationshipColumn(string $databaseId, string $tableId, st */ public function createStringColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2307,6 +2762,18 @@ public function createStringColumn(string $databaseId, string $tableId, string $ */ public function updateStringColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2348,6 +2815,14 @@ public function updateStringColumn(string $databaseId, string $tableId, string $ */ public function createTextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2396,6 +2871,18 @@ public function createTextColumn(string $databaseId, string $tableId, string $ke */ public function updateTextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnText { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2436,6 +2923,14 @@ public function updateTextColumn(string $databaseId, string $tableId, string $ke */ public function createUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): \Appwrite\Models\ColumnUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2480,6 +2975,18 @@ public function createUrlColumn(string $databaseId, string $tableId, string $key */ public function updateUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): \Appwrite\Models\ColumnUrl { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2520,6 +3027,14 @@ public function updateUrlColumn(string $databaseId, string $tableId, string $key */ public function createVarcharColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): \Appwrite\Models\ColumnVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2569,6 +3084,18 @@ public function createVarcharColumn(string $databaseId, string $tableId, string */ public function updateVarcharColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): \Appwrite\Models\ColumnVarchar { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2608,8 +3135,20 @@ public function updateVarcharColumn(string $databaseId, string $tableId, string * * @throws AppwriteException */ - public function getColumn(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnBoolean|\Appwrite\Models\ColumnInteger|\Appwrite\Models\ColumnFloat|\Appwrite\Models\ColumnEmail|\Appwrite\Models\ColumnEnum|\Appwrite\Models\ColumnUrl|\Appwrite\Models\ColumnIp|\Appwrite\Models\ColumnDatetime|\Appwrite\Models\ColumnRelationship|\Appwrite\Models\ColumnString + public function getColumn(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnBoolean|\Appwrite\Models\ColumnBigint|\Appwrite\Models\ColumnInteger|\Appwrite\Models\ColumnFloat|\Appwrite\Models\ColumnEmail|\Appwrite\Models\ColumnEnum|\Appwrite\Models\ColumnUrl|\Appwrite\Models\ColumnIp|\Appwrite\Models\ColumnDatetime|\Appwrite\Models\ColumnRelationship|\Appwrite\Models\ColumnPoint|\Appwrite\Models\ColumnLine|\Appwrite\Models\ColumnPolygon|\Appwrite\Models\ColumnVarchar|\Appwrite\Models\ColumnText|\Appwrite\Models\ColumnMediumtext|\Appwrite\Models\ColumnLongtext|\Appwrite\Models\ColumnString { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2656,6 +3195,10 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap return \Appwrite\Models\ColumnBoolean::from($response); } + if (($response['type'] ?? null) === 'bigint') { + return \Appwrite\Models\ColumnBigint::from($response); + } + if (($response['type'] ?? null) === 'integer') { return \Appwrite\Models\ColumnInteger::from($response); } @@ -2672,6 +3215,34 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap return \Appwrite\Models\ColumnRelationship::from($response); } + if (($response['type'] ?? null) === 'point') { + return \Appwrite\Models\ColumnPoint::from($response); + } + + if (($response['type'] ?? null) === 'linestring') { + return \Appwrite\Models\ColumnLine::from($response); + } + + if (($response['type'] ?? null) === 'polygon') { + return \Appwrite\Models\ColumnPolygon::from($response); + } + + if (($response['type'] ?? null) === 'varchar') { + return \Appwrite\Models\ColumnVarchar::from($response); + } + + if (($response['type'] ?? null) === 'text') { + return \Appwrite\Models\ColumnText::from($response); + } + + if (($response['type'] ?? null) === 'mediumtext') { + return \Appwrite\Models\ColumnMediumtext::from($response); + } + + if (($response['type'] ?? null) === 'longtext') { + return \Appwrite\Models\ColumnLongtext::from($response); + } + if (($response['type'] ?? null) === 'string') { return \Appwrite\Models\ColumnString::from($response); } @@ -2686,67 +3257,40 @@ public function getColumn(string $databaseId, string $tableId, string $key): \Ap */ public function deleteColumn(string $databaseId, string $tableId, string $key): string { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } - $apiHeaders = []; - $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); - $apiHeaders['content-type'] = 'application/json'; + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } - /** - * Update relationship column. [Learn more about relationship - * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * @throws AppwriteException - */ - public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): \Appwrite\Models\ColumnRelationship - { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], - '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}/relationship' + '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' ); $apiParams = []; $apiParams['databaseId'] = $databaseId; $apiParams['tableId'] = $tableId; $apiParams['key'] = $key; - $apiParams['onDelete'] = $onDelete; - $apiParams['newKey'] = $newKey; $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, + return $this->client->call( + Client::METHOD_DELETE, $apiPath, $apiHeaders, $apiParams ); - - if (!is_array($response)) { - throw new \UnexpectedValueException('Expected array response when hydrating a response model.'); - } - - return \Appwrite\Models\ColumnRelationship::from($response); } /** @@ -2756,6 +3300,14 @@ public function updateRelationshipColumn(string $databaseId, string $tableId, st */ public function listIndexes(string $databaseId, string $tableId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ColumnIndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2795,12 +3347,22 @@ public function listIndexes(string $databaseId, string $tableId, ?array $queries /** * Creates an index on the columns listed. Your index should include all the * columns you will query in a single request. - * Type can be `key`, `fulltext`, or `unique`. + * Type can be `key`, `fulltext`, `unique`, `spatial`, or `trigram`. `trigram` + * is only available on PostgreSQL and lets `contains`, `startsWith`, and + * `endsWith` queries on string columns use an index. * * @throws AppwriteException */ public function createIndex(string $databaseId, string $tableId, string $key, TablesDBIndexType $type, array $columns, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\ColumnIndex { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2848,6 +3410,18 @@ public function createIndex(string $databaseId, string $tableId, string $key, Ta */ public function getIndex(string $databaseId, string $tableId, string $key): \Appwrite\Models\ColumnIndex { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2884,6 +3458,18 @@ public function getIndex(string $databaseId, string $tableId, string $key): \App */ public function deleteIndex(string $databaseId, string $tableId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], [$databaseId, $tableId, $key], @@ -2898,6 +3484,7 @@ public function deleteIndex(string $databaseId, string $tableId, string $key): s $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -2915,6 +3502,14 @@ public function deleteIndex(string $databaseId, string $tableId, string $key): s */ public function listRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -2969,6 +3564,14 @@ public function listRows(string $databaseId, string $tableId, ?array $queries = */ public function createRow(string $databaseId, string $tableId, string $rowId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3012,6 +3615,14 @@ public function createRow(string $databaseId, string $tableId, string $rowId, ar */ public function createRows(string $databaseId, string $tableId, array $rows, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3053,6 +3664,14 @@ public function createRows(string $databaseId, string $tableId, array $rows, ?st */ public function upsertRows(string $databaseId, string $tableId, array $rows, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3092,6 +3711,14 @@ public function upsertRows(string $databaseId, string $tableId, array $rows, ?st */ public function updateRows(string $databaseId, string $tableId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3138,6 +3765,14 @@ public function updateRows(string $databaseId, string $tableId, ?array $data = n */ public function deleteRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\RowList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}'], [$databaseId, $tableId], @@ -3183,6 +3818,18 @@ public function deleteRows(string $databaseId, string $tableId, ?array $queries */ public function getRow(string $databaseId, string $tableId, string $rowId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3230,6 +3877,18 @@ public function getRow(string $databaseId, string $tableId, string $rowId, ?arra */ public function upsertRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3274,6 +3933,18 @@ public function upsertRow(string $databaseId, string $tableId, string $rowId, ?a */ public function updateRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3317,6 +3988,18 @@ public function updateRow(string $databaseId, string $tableId, string $rowId, ?a */ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}'], [$databaseId, $tableId, $rowId], @@ -3335,6 +4018,7 @@ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?s $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -3351,6 +4035,22 @@ public function deleteRow(string $databaseId, string $tableId, string $rowId, ?s */ public function decrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $min = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if ($column === '') { + throw new AppwriteException('Missing required parameter: "column"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}', '{column}'], [$databaseId, $tableId, $rowId, $column], @@ -3395,6 +4095,22 @@ public function decrementRowColumn(string $databaseId, string $tableId, string $ */ public function incrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $max = null, ?string $transactionId = null): \Appwrite\Models\Row { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($tableId === '') { + throw new AppwriteException('Missing required parameter: "tableId"'); + } + + if ($rowId === '') { + throw new AppwriteException('Missing required parameter: "rowId"'); + } + + if ($column === '') { + throw new AppwriteException('Missing required parameter: "column"'); + } + $apiPath = str_replace( ['{databaseId}', '{tableId}', '{rowId}', '{column}'], [$databaseId, $tableId, $rowId, $column], diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index 3aad4091..e963c412 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -105,6 +105,10 @@ public function create(string $teamId, string $name, ?array $roles = null): \App */ public function get(string $teamId): \Appwrite\Models\Team { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -139,6 +143,10 @@ public function get(string $teamId): \Appwrite\Models\Team */ public function updateName(string $teamId, string $name): \Appwrite\Models\Team { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -176,6 +184,10 @@ public function updateName(string $teamId, string $name): \Appwrite\Models\Team */ public function delete(string $teamId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -188,6 +200,7 @@ public function delete(string $teamId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -204,6 +217,10 @@ public function delete(string $teamId): string */ public function listInstallations(string $teamId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\AppInstallationList { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -249,6 +266,10 @@ public function listInstallations(string $teamId, ?array $queries = null, ?bool */ public function createInstallation(string $teamId, string $appId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -290,6 +311,14 @@ public function createInstallation(string $teamId, string $appId, ?string $autho */ public function getInstallation(string $teamId, string $installationId): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -328,6 +357,14 @@ public function getInstallation(string $teamId, string $installationId): \Appwri */ public function updateInstallation(string $teamId, string $installationId, ?string $authorizationDetails = null): \Appwrite\Models\AppInstallation { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -367,6 +404,14 @@ public function updateInstallation(string $teamId, string $installationId, ?stri */ public function deleteInstallation(string $teamId, string $installationId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($installationId === '') { + throw new AppwriteException('Missing required parameter: "installationId"'); + } + $apiPath = str_replace( ['{teamId}', '{installationId}'], [$teamId, $installationId], @@ -399,6 +444,10 @@ public function deleteInstallation(string $teamId, string $installationId): stri */ public function listMemberships(string $teamId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\MembershipList { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -464,6 +513,10 @@ public function listMemberships(string $teamId, ?array $queries = null, ?string */ public function createMembership(string $teamId, array $roles, ?string $email = null, ?string $userId = null, ?string $phone = null, ?string $url = null, ?string $name = null, ?string $membershipId = null): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -526,6 +579,14 @@ public function createMembership(string $teamId, array $roles, ?string $email = */ public function getMembership(string $teamId, string $membershipId): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -563,6 +624,14 @@ public function getMembership(string $teamId, string $membershipId): \Appwrite\M */ public function updateMembership(string $teamId, string $membershipId, array $roles): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -602,6 +671,14 @@ public function updateMembership(string $teamId, string $membershipId, array $ro */ public function deleteMembership(string $teamId, string $membershipId): string { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -615,6 +692,7 @@ public function deleteMembership(string $teamId, string $membershipId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -636,6 +714,14 @@ public function deleteMembership(string $teamId, string $membershipId): string */ public function updateMembershipStatus(string $teamId, string $membershipId, string $userId, string $secret): \Appwrite\Models\Membership { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + + if ($membershipId === '') { + throw new AppwriteException('Missing required parameter: "membershipId"'); + } + $apiPath = str_replace( ['{teamId}', '{membershipId}'], [$teamId, $membershipId], @@ -676,6 +762,10 @@ public function updateMembershipStatus(string $teamId, string $membershipId, str */ public function getPrefs(string $teamId): \Appwrite\Models\Preferences { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], @@ -712,6 +802,10 @@ public function getPrefs(string $teamId): \Appwrite\Models\Preferences */ public function updatePrefs(string $teamId, array $prefs): \Appwrite\Models\Preferences { + if ($teamId === '') { + throw new AppwriteException('Missing required parameter: "teamId"'); + } + $apiPath = str_replace( ['{teamId}'], [$teamId], diff --git a/src/Appwrite/Services/Tokens.php b/src/Appwrite/Services/Tokens.php index 1d2b5137..a5d3bc40 100644 --- a/src/Appwrite/Services/Tokens.php +++ b/src/Appwrite/Services/Tokens.php @@ -18,6 +18,14 @@ class Tokens extends Service */ public function list(string $bucketId, string $fileId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\ResourceTokenList { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -62,6 +70,14 @@ public function list(string $bucketId, string $fileId, ?array $queries = null, ? */ public function createFileToken(string $bucketId, string $fileId, ?string $expire = null): \Appwrite\Models\ResourceToken { + if ($bucketId === '') { + throw new AppwriteException('Missing required parameter: "bucketId"'); + } + + if ($fileId === '') { + throw new AppwriteException('Missing required parameter: "fileId"'); + } + $apiPath = str_replace( ['{bucketId}', '{fileId}'], [$bucketId, $fileId], @@ -99,6 +115,10 @@ public function createFileToken(string $bucketId, string $fileId, ?string $expir */ public function get(string $tokenId): \Appwrite\Models\ResourceToken { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -134,6 +154,10 @@ public function get(string $tokenId): \Appwrite\Models\ResourceToken */ public function update(string $tokenId, ?string $expire = null): \Appwrite\Models\ResourceToken { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -170,6 +194,10 @@ public function update(string $tokenId, ?string $expire = null): \Appwrite\Model */ public function delete(string $tokenId): string { + if ($tokenId === '') { + throw new AppwriteException('Missing required parameter: "tokenId"'); + } + $apiPath = str_replace( ['{tokenId}'], [$tokenId], @@ -182,6 +210,7 @@ public function delete(string $tokenId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, diff --git a/src/Appwrite/Services/Users.php b/src/Appwrite/Services/Users.php index b0333df3..cbd44020 100644 --- a/src/Appwrite/Services/Users.php +++ b/src/Appwrite/Services/Users.php @@ -76,10 +76,7 @@ public function create(string $userId, ?string $email = null, ?string $phone = n $apiParams['userId'] = $userId; $apiParams['email'] = $email; $apiParams['phone'] = $phone; - - if (!is_null($password)) { - $apiParams['password'] = $password; - } + $apiParams['password'] = $password; if (!is_null($name)) { $apiParams['name'] = $name; @@ -244,6 +241,10 @@ public function listIdentities(?array $queries = null, ?string $search = null, ? */ public function deleteIdentity(string $identityId): string { + if ($identityId === '') { + throw new AppwriteException('Missing required parameter: "identityId"'); + } + $apiPath = str_replace( ['{identityId}'], [$identityId], @@ -256,6 +257,7 @@ public function deleteIdentity(string $identityId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -505,6 +507,10 @@ public function createSHAUser(string $userId, string $email, string $password, ? */ public function get(string $userId): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -544,6 +550,10 @@ public function get(string $userId): \Appwrite\Models\User */ public function delete(string $userId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -556,6 +566,7 @@ public function delete(string $userId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -572,6 +583,10 @@ public function delete(string $userId): string */ public function updateEmail(string $userId, string $email): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -606,12 +621,19 @@ public function updateEmail(string $userId, string $email): \Appwrite\Models\Use * impersonation headers are used, the request runs as the target user for API * behavior, while internal audit logs still attribute the action to the * original impersonator and store the impersonated target details only in - * internal audit payload data. + * internal audit payload data. Account endpoints are read-only while + * impersonating: they report the target's account, and anything that would + * change it is refused, so an impersonator cannot alter the target's + * credentials or delete their account. * * @throws AppwriteException */ public function updateImpersonator(string $userId, bool $impersonator): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -650,6 +672,10 @@ public function updateImpersonator(string $userId, bool $impersonator): \Appwrit */ public function createJWT(string $userId, ?string $sessionId = null, ?int $duration = null): \Appwrite\Models\Jwt { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -698,6 +724,10 @@ public function createJWT(string $userId, ?string $sessionId = null, ?int $durat */ public function updateLabels(string $userId, array $labels): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -727,48 +757,6 @@ public function updateLabels(string $userId, array $labels): \Appwrite\Models\Us return \Appwrite\Models\User::from($response); } - /** - * Get the user activity logs list by its unique ID. - * - * @throws AppwriteException - */ - public function listLogs(string $userId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\LogList - { - $apiPath = str_replace( - ['{userId}'], - [$userId], - '/users/{userId}/logs' - ); - - $apiParams = []; - $apiParams['userId'] = $userId; - - 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 user membership list by its unique ID. * @@ -776,6 +764,10 @@ public function listLogs(string $userId, ?array $queries = null, ?bool $total = */ public function listMemberships(string $userId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\MembershipList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -822,6 +814,10 @@ public function listMemberships(string $userId, ?array $queries = null, ?string */ public function updateMFA(string $userId, bool $mfa): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -858,6 +854,10 @@ public function updateMFA(string $userId, bool $mfa): \Appwrite\Models\User */ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}', '{type}'], [$userId, (string) $type], @@ -871,6 +871,7 @@ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -888,6 +889,14 @@ public function deleteMFAAuthenticator(string $userId, AuthenticatorType $type): */ public function getMFAChallenge(string $userId, string $challengeId): \Appwrite\Models\MfaChallengeSecret { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($challengeId === '') { + throw new AppwriteException('Missing required parameter: "challengeId"'); + } + $apiPath = str_replace( ['{userId}', '{challengeId}'], [$userId, $challengeId], @@ -923,6 +932,10 @@ public function getMFAChallenge(string $userId, string $challengeId): \Appwrite\ */ public function listMFAFactors(string $userId): \Appwrite\Models\MfaFactors { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -960,6 +973,10 @@ public function listMFAFactors(string $userId): \Appwrite\Models\MfaFactors */ public function getMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -997,6 +1014,10 @@ public function getMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecover */ public function updateMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1035,6 +1056,10 @@ public function updateMFARecoveryCodes(string $userId): \Appwrite\Models\MfaReco */ public function createMFARecoveryCodes(string $userId): \Appwrite\Models\MfaRecoveryCodes { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1070,6 +1095,10 @@ public function createMFARecoveryCodes(string $userId): \Appwrite\Models\MfaReco */ public function updateName(string $userId, string $name): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1279,6 +1308,10 @@ public function deletePasskey(string $userId, string $passkeyId): string */ public function updatePassword(string $userId, string $password): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1315,6 +1348,10 @@ public function updatePassword(string $userId, string $password): \Appwrite\Mode */ public function updatePhone(string $userId, string $number): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1351,6 +1388,10 @@ public function updatePhone(string $userId, string $number): \Appwrite\Models\Us */ public function getPrefs(string $userId): \Appwrite\Models\Preferences { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1387,6 +1428,10 @@ public function getPrefs(string $userId): \Appwrite\Models\Preferences */ public function updatePrefs(string $userId, array $prefs): \Appwrite\Models\Preferences { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1423,6 +1468,10 @@ public function updatePrefs(string $userId, array $prefs): \Appwrite\Models\Pref */ public function listSessions(string $userId, ?bool $total = null): \Appwrite\Models\SessionList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1466,6 +1515,10 @@ public function listSessions(string $userId, ?bool $total = null): \Appwrite\Mod */ public function createSession(string $userId): \Appwrite\Models\Session { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1501,6 +1554,10 @@ public function createSession(string $userId): \Appwrite\Models\Session */ public function deleteSessions(string $userId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1513,6 +1570,7 @@ public function deleteSessions(string $userId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1529,6 +1587,14 @@ public function deleteSessions(string $userId): string */ public function deleteSession(string $userId, string $sessionId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($sessionId === '') { + throw new AppwriteException('Missing required parameter: "sessionId"'); + } + $apiPath = str_replace( ['{userId}', '{sessionId}'], [$userId, $sessionId], @@ -1542,6 +1608,7 @@ public function deleteSession(string $userId, string $sessionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1559,6 +1626,10 @@ public function deleteSession(string $userId, string $sessionId): string */ public function updateStatus(string $userId, bool $status): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1595,6 +1666,10 @@ public function updateStatus(string $userId, bool $status): \Appwrite\Models\Use */ public function listTargets(string $userId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\TargetList { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1637,6 +1712,10 @@ public function listTargets(string $userId, ?array $queries = null, ?bool $total */ public function createTarget(string $userId, string $targetId, MessagingProviderType $providerType, string $identifier, ?string $providerId = null, ?string $name = null): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1683,6 +1762,14 @@ public function createTarget(string $userId, string $targetId, MessagingProvider */ public function getTarget(string $userId, string $targetId): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1718,6 +1805,14 @@ public function getTarget(string $userId, string $targetId): \Appwrite\Models\Ta */ public function updateTarget(string $userId, string $targetId, ?string $identifier = null, ?string $providerId = null, ?string $name = null): \Appwrite\Models\Target { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1766,6 +1861,14 @@ public function updateTarget(string $userId, string $targetId, ?string $identifi */ public function deleteTarget(string $userId, string $targetId): string { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + + if ($targetId === '') { + throw new AppwriteException('Missing required parameter: "targetId"'); + } + $apiPath = str_replace( ['{userId}', '{targetId}'], [$userId, $targetId], @@ -1779,6 +1882,7 @@ public function deleteTarget(string $userId, string $targetId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1798,6 +1902,10 @@ public function deleteTarget(string $userId, string $targetId): string */ public function createToken(string $userId, ?int $length = null, ?int $expire = null): \Appwrite\Models\Token { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1841,6 +1949,10 @@ public function createToken(string $userId, ?int $length = null, ?int $expire = */ public function updateEmailVerification(string $userId, bool $emailVerification): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], @@ -1877,6 +1989,10 @@ public function updateEmailVerification(string $userId, bool $emailVerification) */ public function updatePhoneVerification(string $userId, bool $phoneVerification): \Appwrite\Models\User { + if ($userId === '') { + throw new AppwriteException('Missing required parameter: "userId"'); + } + $apiPath = str_replace( ['{userId}'], [$userId], diff --git a/src/Appwrite/Services/VectorsDB.php b/src/Appwrite/Services/VectorsDB.php index c2a5c12a..053efccb 100644 --- a/src/Appwrite/Services/VectorsDB.php +++ b/src/Appwrite/Services/VectorsDB.php @@ -104,8 +104,8 @@ public function create(string $databaseId, string $name, ?bool $enabled = null, /** * List the dedicated database specifications available on the current plan. - * Each specification reports its resource limits, pricing, and whether it is - * enabled for the organization. + * Each specification reports its resource limits, its own prices and overage + * rates, and whether it is enabled for the organization. * * @throws AppwriteException */ @@ -223,6 +223,10 @@ public function createTransaction(?int $ttl = null): \Appwrite\Models\Transactio */ public function getTransaction(string $transactionId): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -257,6 +261,10 @@ public function getTransaction(string $transactionId): \Appwrite\Models\Transact */ public function updateTransaction(string $transactionId, ?bool $commit = null, ?bool $rollback = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -300,6 +308,10 @@ public function updateTransaction(string $transactionId, ?bool $commit = null, ? */ public function deleteTransaction(string $transactionId): string { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -312,6 +324,7 @@ public function deleteTransaction(string $transactionId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -328,6 +341,10 @@ public function deleteTransaction(string $transactionId): string */ public function createOperations(string $transactionId, ?array $operations = null): \Appwrite\Models\Transaction { + if ($transactionId === '') { + throw new AppwriteException('Missing required parameter: "transactionId"'); + } + $apiPath = str_replace( ['{transactionId}'], [$transactionId], @@ -368,6 +385,10 @@ public function createOperations(string $transactionId, ?array $operations = nul */ public function get(string $databaseId): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -402,6 +423,10 @@ public function get(string $databaseId): \Appwrite\Models\Database */ public function update(string $databaseId, string $name, ?bool $enabled = null, ?string $specification = null, ?int $replicas = null, ?string $syncMode = null): \Appwrite\Models\Database { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -446,6 +471,10 @@ public function update(string $databaseId, string $name, ?bool $enabled = null, */ public function delete(string $databaseId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -458,6 +487,7 @@ public function delete(string $databaseId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -475,6 +505,10 @@ public function delete(string $databaseId): string */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null, ?bool $total = null): \Appwrite\Models\VectorsdbCollectionList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -524,6 +558,10 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str */ public function createCollection(string $databaseId, string $collectionId, string $name, int $dimension, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -575,6 +613,14 @@ public function createCollection(string $databaseId, string $collectionId, strin */ public function getCollection(string $databaseId, string $collectionId): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -610,6 +656,14 @@ public function getCollection(string $databaseId, string $collectionId): \Appwri */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?int $dimension = null, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): \Appwrite\Models\VectorsdbCollection { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -632,10 +686,7 @@ public function updateCollection(string $databaseId, string $collectionId, strin if (!is_null($documentSecurity)) { $apiParams['documentSecurity'] = $documentSecurity; } - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } + $apiParams['enabled'] = $enabled; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -664,6 +715,14 @@ public function updateCollection(string $databaseId, string $collectionId, strin */ public function deleteCollection(string $databaseId, string $collectionId): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -677,6 +736,7 @@ public function deleteCollection(string $databaseId, string $collectionId): stri $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -694,6 +754,14 @@ public function deleteCollection(string $databaseId, string $collectionId): stri */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -748,6 +816,14 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -797,6 +873,14 @@ public function createDocument(string $databaseId, string $collectionId, string */ public function createDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -841,6 +925,14 @@ public function createDocuments(string $databaseId, string $collectionId, array */ public function upsertDocuments(string $databaseId, string $collectionId, array $documents, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -884,6 +976,14 @@ public function upsertDocuments(string $databaseId, string $collectionId, array */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -933,6 +1033,14 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -980,6 +1088,14 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array */ public function createQuery(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): \Appwrite\Models\DocumentList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1033,6 +1149,18 @@ public function createQuery(string $databaseId, string $collectionId, ?array $qu */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1080,6 +1208,18 @@ public function getDocument(string $databaseId, string $collectionId, string $do */ public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1130,6 +1270,18 @@ public function upsertDocument(string $databaseId, string $collectionId, string */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): \Appwrite\Models\Document { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1179,6 +1331,18 @@ public function updateDocument(string $databaseId, string $collectionId, string */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId, ?string $transactionId = null): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($documentId === '') { + throw new AppwriteException('Missing required parameter: "documentId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], [$databaseId, $collectionId, $documentId], @@ -1197,6 +1361,7 @@ public function deleteDocument(string $databaseId, string $collectionId, string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1213,6 +1378,14 @@ public function deleteDocument(string $databaseId, string $collectionId, string */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null, ?bool $total = null): \Appwrite\Models\IndexList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1258,6 +1431,14 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu */ public function createIndex(string $databaseId, string $collectionId, string $key, VectorsDBIndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}'], [$databaseId, $collectionId], @@ -1305,6 +1486,18 @@ public function createIndex(string $databaseId, string $collectionId, string $ke */ public function getIndex(string $databaseId, string $collectionId, string $key): \Appwrite\Models\Index { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1341,6 +1534,18 @@ public function getIndex(string $databaseId, string $collectionId, string $key): */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + + if ($collectionId === '') { + throw new AppwriteException('Missing required parameter: "collectionId"'); + } + + if ($key === '') { + throw new AppwriteException('Missing required parameter: "key"'); + } + $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], [$databaseId, $collectionId, $key], @@ -1355,6 +1560,7 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -1379,6 +1585,10 @@ public function deleteIndex(string $databaseId, string $collectionId, string $ke */ public function createFailover(string $databaseId, ?string $targetReplicaId = null): \Appwrite\Models\DedicatedDatabase { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1418,6 +1628,10 @@ public function createFailover(string $databaseId, ?string $targetReplicaId = nu */ public function listOperations(string $databaseId, ?string $status = null, ?int $limit = null, ?int $offset = null): \Appwrite\Models\DedicatedDatabaseOperationList { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1465,6 +1679,10 @@ public function listOperations(string $databaseId, ?string $status = null, ?int */ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatabaseReplicas { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], @@ -1501,6 +1719,10 @@ public function getReplicas(string $databaseId): \Appwrite\Models\DedicatedDatab */ public function getStatus(string $databaseId): \Appwrite\Models\DatabaseStatus { + if ($databaseId === '') { + throw new AppwriteException('Missing required parameter: "databaseId"'); + } + $apiPath = str_replace( ['{databaseId}'], [$databaseId], diff --git a/src/Appwrite/Services/Webhooks.php b/src/Appwrite/Services/Webhooks.php index 2694980a..7563d2ff 100644 --- a/src/Appwrite/Services/Webhooks.php +++ b/src/Appwrite/Services/Webhooks.php @@ -116,6 +116,10 @@ public function create(string $webhookId, string $url, string $name, array $even */ public function get(string $webhookId): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -151,6 +155,10 @@ public function get(string $webhookId): \Appwrite\Models\Webhook */ public function update(string $webhookId, string $name, string $url, array $events, ?bool $enabled = null, ?bool $tls = null, ?string $authUsername = null, ?string $authPassword = null): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -174,10 +182,7 @@ public function update(string $webhookId, string $name, string $url, array $even if (!is_null($authUsername)) { $apiParams['authUsername'] = $authUsername; } - - if (!is_null($authPassword)) { - $apiParams['authPassword'] = $authPassword; - } + $apiParams['authPassword'] = $authPassword; $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); @@ -206,6 +211,10 @@ public function update(string $webhookId, string $name, string $url, array $even */ public function delete(string $webhookId): string { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], @@ -218,6 +227,7 @@ public function delete(string $webhookId): string $apiHeaders = []; $apiHeaders['X-Appwrite-Project'] = $this->client->getConfig('project'); $apiHeaders['content-type'] = 'application/json'; + $apiHeaders['accept'] = 'application/json'; return $this->client->call( Client::METHOD_DELETE, @@ -236,6 +246,10 @@ public function delete(string $webhookId): string */ public function updateSecret(string $webhookId, ?string $secret = null): \Appwrite\Models\Webhook { + if ($webhookId === '') { + throw new AppwriteException('Missing required parameter: "webhookId"'); + } + $apiPath = str_replace( ['{webhookId}'], [$webhookId], diff --git a/src/Appwrite/Topic.php b/src/Appwrite/Topic.php new file mode 100644 index 00000000..2ca43660 --- /dev/null +++ b/src/Appwrite/Topic.php @@ -0,0 +1,115 @@ +path(['logs']); // "org/42/logs" + * + * The same name starts a topic (`Topic::path()`) and extends one (`$topic->path()`); both are + * routed through `__callStatic()` and `__call()` to the protected implementation below. + * + * @method static Topic path(array $levels) Start a topic with the given levels, or append them. + */ +final readonly class Topic implements \Stringable +{ + /** + * @param list $levels + */ + private function __construct(private array $levels) + { + } + + /** + * @param array $arguments + */ + public static function __callStatic(string $name, array $arguments): self + { + return new self([])->dispatch($name, $arguments); + } + + /** + * @param array $arguments + */ + public function __call(string $name, array $arguments): self + { + return $this->dispatch($name, $arguments); + } + + /** + * Append the given levels. + */ + protected function appendPath(mixed $levels): self + { + return new self([...$this->levels, ...$this->levelsOf($levels)]); + } + + public function __toString(): string + { + return \implode('/', $this->levels); + } + + /** + * @param array $arguments + */ + private function dispatch(string $name, array $arguments): self + { + return match ($name) { + 'path' => $this->appendPath($arguments[0] ?? null), + default => throw new \BadMethodCallException('Call to undefined method ' . self::class . '::' . $name . '()'), + }; + } + + /** + * Validate the levels passed to `path()`: a non-empty array of non-empty strings, none holding + * the level separator `/` or the MQTT wildcards `+` and `#`. + * + * @return list + */ + private function levelsOf(mixed $levels): array + { + if (!\is_array($levels)) { + throw new \InvalidArgumentException("path() expects an array, e.g. path(['user'])"); + } + + if ($levels === []) { + throw new \InvalidArgumentException('path() needs at least one level'); + } + + $result = []; + foreach (\array_values($levels) as $index => $level) { + if (!\is_string($level)) { + $type = $level === null ? 'null' : \get_debug_type($level); + throw new \InvalidArgumentException(\sprintf('level at index %d must be a string, got %s', $index, $type)); + } + + if ($level === '') { + throw new \InvalidArgumentException(\sprintf('empty level at index %d', $index)); + } + + if (\str_contains($level, '/')) { + $parts = \implode(', ', \array_map(static fn (string $part): string => "'" . $part . "'", \explode('/', $level))); + throw new \InvalidArgumentException(\sprintf('"%s" contains "/", split it: path([%s])', $level, $parts)); + } + + if (\str_contains($level, '+')) { + throw new \InvalidArgumentException(\sprintf('"%s" contains "+", not allowed in a topic', $level)); + } + + if (\str_contains($level, '#')) { + throw new \InvalidArgumentException(\sprintf('"%s" contains "#", not allowed in a topic', $level)); + } + if (\str_contains($level, "\0")) { + throw new \InvalidArgumentException(\sprintf('level at index %d contains a NUL character', $index)); + } + + $result[] = $level; + } + + return $result; + } +} diff --git a/tests/Appwrite/ClientTest.php b/tests/Appwrite/ClientTest.php index 46678475..c25ac462 100644 --- a/tests/Appwrite/ClientTest.php +++ b/tests/Appwrite/ClientTest.php @@ -5,9 +5,14 @@ namespace Appwrite; use PHPUnit\Framework\TestCase; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; use ReflectionMethod; use ReflectionProperty; use Utopia\Client\Client as HttpClient; +use Utopia\Psr7\Response; +use Utopia\Psr7\Stream; final class ClientTest extends TestCase { @@ -61,6 +66,49 @@ public function testAddHeaderReturnsClient(): void $this->assertSame($client, $result); } + public function testFlattenSpreadsWrappedBuilder(): void + { + $this->assertSame( + [Query::limit(1)], + array_values((array) Client::flatten([Query::builder()->limit(1)])) + ); + } + + public function testFlattenKeepsNestedNumericArrays(): void + { + $geometry = [[1, 2], [3, 4]]; + $this->assertSame($geometry, Client::flatten($geometry)); + } + + public function testFlattenKeepsQueryStringList(): void + { + $this->assertSame( + [Query::limit(1)], + array_values((array) Client::flatten([Query::limit(1)])) + ); + } + + public function testFlattenKeepsNestedStringArrays(): void + { + $this->assertSame([['a', 'b']], Client::flatten([['a', 'b']])); + } + + public function testFlattenBuilderParamBecomesQueryStrings(): void + { + $this->assertSame( + [Query::equal('status', ['active']), Query::limit(1)], + Client::flatten(Query::builder()->equal('status', ['active'])->limit(1)) + ); + } + + public function testFlattenSplicesBuildersBesideNestedStringArrays(): void + { + $this->assertSame( + [Query::limit(1), Query::offset(2), ['a', 'b']], + Client::flatten([Query::builder()->limit(1)->offset(2), ['a', 'b']]) + ); + } + public function testSetProjectReturnsClient(): void { $client = new Client(); @@ -117,13 +165,6 @@ public function testSetForwardedUserAgentReturnsClient(): void $this->assertSame($client, $result); } - public function testSetDevKeyReturnsClient(): void - { - $client = new Client(); - $result = $client->setDevKey('test-value'); - $this->assertSame($client, $result); - } - public function testSetCookieReturnsClient(): void { $client = new Client(); @@ -185,7 +226,109 @@ public function testSelfSignedAndConnectTimeoutResetHttpClient(): void $this->assertNotSame($afterSelfSigned, $this->httpClient($client, true)); } - private function httpClient(Client $client, bool $followRedirects): HttpClient + public function testInjectedTransportReceivesEncodedRequests(): void + { + $received = []; + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->once())->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request) use (&$received): ResponseInterface { + $received[] = $request; + + return new Response(body: new Stream('{"received":true}')) + ->withHeader('content-type', 'application/json'); + }); + + $client = new Client($transport) + ->setEndpoint('https://example.com/v1') + ->addHeader('x-test', 'injected'); + + $this->assertSame(['received' => true], $client->call(Client::METHOD_POST, '/items', ['content-type' => 'application/json'], ['name' => 'item'])); + $this->assertCount(1, $received); + $this->assertSame('POST', $received[0]->getMethod()); + $this->assertSame('https://example.com/v1/items', (string) $received[0]->getUri()); + $this->assertSame(['name' => 'item'], json_decode((string) $received[0]->getBody(), true)); + $this->assertSame('injected', $received[0]->getHeaderLine('x-test')); + } + + public function testInjectedTransportReceivesFlattenedParams(): void + { + $received = []; + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->exactly(2))->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request) use (&$received): ResponseInterface { + $received[] = $request; + + return new Response(body: new Stream('{}')) + ->withHeader('content-type', 'application/json'); + }); + + $client = new Client($transport)->setEndpoint('https://example.com/v1'); + $params = [ + 'queries' => Query::builder()->limit(1)->offset(2), + 'tags' => [['a', 'b']], + ]; + + $client->call(Client::METHOD_POST, '/items', ['content-type' => 'application/json'], $params); + $client->call(Client::METHOD_GET, '/items', [], $params); + + $this->assertCount(2, $received); + $this->assertSame( + ['queries' => [Query::limit(1), Query::offset(2)], 'tags' => [['a', 'b']]], + json_decode((string) $received[0]->getBody(), true) + ); + parse_str($received[1]->getUri()->getQuery(), $query); + $this->assertSame( + ['queries' => [Query::limit(1), Query::offset(2)], 'tags' => [['a', 'b']]], + $query + ); + } + + public function testInjectedTransportSurvivesFailureAndConfigurationChanges(): void + { + $received = []; + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->exactly(2))->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request) use (&$received): ResponseInterface { + $received[] = (string) $request->getUri(); + + return count($received) === 1 + ? new Response(503, body: new Stream('{"message":"Unavailable","type":"unavailable"}'))->withHeader('content-type', 'application/json') + : new Response(body: new Stream('null'))->withHeader('content-type', 'application/json'); + }); + $client = new Client($transport)->setEndpoint('https://first.example'); + + $failure = null; + try { + $client->call(Client::METHOD_GET, '/fail'); + } catch (AppwriteException $error) { + $failure = $error; + } + + $client->setEndpoint('https://second.example')->setTimeout(5)->setConnectTimeout(2)->setSelfSigned(true); + $this->assertNull($client->call(Client::METHOD_GET, '/next', params: ['project' => 'project-1'])); + $this->assertInstanceOf(AppwriteException::class, $failure); + $this->assertSame(503, $failure->getCode()); + $this->assertSame(['https://first.example/fail', 'https://second.example/next?project=project-1'], $received); + $this->assertSame($transport, $this->httpClient($client, true)); + $this->assertSame($transport, $this->httpClient($client, false)); + } + + public function testLocationResponseUsesInjectedTransport(): void + { + $transport = $this->createMock(ClientInterface::class); + $transport->expects($this->once())->method('sendRequest') + ->willReturnCallback(function (RequestInterface $request): ResponseInterface { + $this->assertSame('GET', $request->getMethod()); + $this->assertSame('https://example.com/redirect', (string) $request->getUri()); + + return new Response(302)->withHeader('location', 'https://storage.example/file'); + }); + + $client = new Client($transport)->setEndpoint('https://example.com'); + $this->assertSame('https://storage.example/file', $client->call(Client::METHOD_GET, '/redirect', responseType: 'location')); + } + + private function httpClient(Client $client, bool $followRedirects): ClientInterface { $method = new ReflectionMethod(Client::class, 'getHttpClient'); diff --git a/tests/Appwrite/QueryTest.php b/tests/Appwrite/QueryTest.php index d25e1910..cf4f85ad 100644 --- a/tests/Appwrite/QueryTest.php +++ b/tests/Appwrite/QueryTest.php @@ -8,11 +8,8 @@ final class BasicFilterQueryTest { - public function __construct( - public string $description, - public mixed $value, - public string $expectedValues, - ) { + public function __construct(public string $description, public mixed $value, public string $expectedValues) + { } } @@ -314,6 +311,25 @@ public function testElemMatch(): void $this->assertSame([18], $query['values'][1]['values']); } + public function testRelationship(): void + { + $inner1 = Query::equal('approved', true); + $inner2 = Query::limit(2); + + $query = json_decode(Query::relationship('comments', [$inner1, $inner2]), true); + + $this->assertSame('comments', $query['attribute']); + $this->assertSame('relationship', $query['method']); + $this->assertCount(2, $query['values']); + + $this->assertSame('equal', $query['values'][0]['method']); + $this->assertSame('approved', $query['values'][0]['attribute']); + $this->assertSame([true], $query['values'][0]['values']); + + $this->assertSame('limit', $query['values'][1]['method']); + $this->assertSame([2], $query['values'][1]['values']); + } + public function testCreatedBefore(): void { $query = json_decode(Query::createdBefore('2023-01-01'), true); @@ -361,4 +377,263 @@ public function testUpdatedBetween(): void $this->assertSame(['2023-01-01', '2023-12-31'], $query['values']); $this->assertSame('between', $query['method']); } + + public function testCountWithAlias(): void + { + $query = json_decode(Query::count('*', 'total'), true); + $this->assertSame('count', $query['method']); + $this->assertSame('*', $query['attribute']); + $this->assertSame(['total'], $query['values']); + } + + public function testCountWithoutAlias(): void + { + $query = json_decode(Query::count(), true); + $this->assertSame('count', $query['method']); + $this->assertSame('*', $query['attribute']); + $this->assertArrayNotHasKey('values', $query); + } + + public function testCountDistinct(): void + { + $query = json_decode(Query::countDistinct('year', 'uniqueYears'), true); + $this->assertSame('countDistinct', $query['method']); + $this->assertSame('year', $query['attribute']); + $this->assertSame(['uniqueYears'], $query['values']); + } + + public function testSumAvgMinMax(): void + { + $this->assertSame('sum', json_decode(Query::sum('price', 'total'), true)['method']); + $this->assertSame('avg', json_decode(Query::avg('price', 'avgPrice'), true)['method']); + $this->assertSame('min', json_decode(Query::min('price', 'lowest'), true)['method']); + $this->assertSame('max', json_decode(Query::max('price', 'highest'), true)['method']); + } + + public function testStddev(): void + { + $this->assertSame('stddev', json_decode(Query::stddev('price', 'sd'), true)['method']); + } + + public function testStddevPop(): void + { + $this->assertSame('stddevPop', json_decode(Query::stddevPop('price', 'sdp'), true)['method']); + } + + public function testStddevSamp(): void + { + $this->assertSame('stddevSamp', json_decode(Query::stddevSamp('price', 'sds'), true)['method']); + } + + public function testVariance(): void + { + $this->assertSame('variance', json_decode(Query::variance('price', 'var'), true)['method']); + } + + public function testVarPop(): void + { + $this->assertSame('varPop', json_decode(Query::varPop('price', 'vp'), true)['method']); + } + + public function testVarSamp(): void + { + $this->assertSame('varSamp', json_decode(Query::varSamp('price', 'vs'), true)['method']); + } + + public function testBitAnd(): void + { + $this->assertSame('bitAnd', json_decode(Query::bitAnd('flags', 'band'), true)['method']); + } + + public function testBitOr(): void + { + $this->assertSame('bitOr', json_decode(Query::bitOr('flags', 'bor'), true)['method']); + } + + public function testBitXor(): void + { + $this->assertSame('bitXor', json_decode(Query::bitXor('flags', 'bxor'), true)['method']); + } + + public function testGroupBy(): void + { + $query = json_decode(Query::groupBy(['status', 'year']), true); + $this->assertSame('groupBy', $query['method']); + $this->assertSame(['status', 'year'], $query['values']); + $this->assertArrayNotHasKey('attribute', $query); + } + + public function testHaving(): void + { + $query = json_decode(Query::having([Query::greaterThan('total', 1)]), true); + $this->assertSame('having', $query['method']); + $this->assertSame('greaterThan', $query['values'][0]['method']); + $this->assertSame('total', $query['values'][0]['attribute']); + $this->assertSame([1], $query['values'][0]['values']); + } + + public function testDistinct(): void + { + $query = json_decode(Query::distinct(), true); + $this->assertSame('distinct', $query['method']); + $this->assertArrayNotHasKey('attribute', $query); + $this->assertArrayNotHasKey('values', $query); + } + + public function testJoin(): void + { + $query = json_decode(Query::join('orders', '$id', 'customerId'), true); + $this->assertSame('join', $query['method']); + $this->assertSame('orders', $query['attribute']); + $this->assertSame(['$id', '=', 'customerId'], $query['values']); + } + + public function testJoinWithAlias(): void + { + $query = json_decode(Query::leftJoin('orders', '$id', 'customerId', '=', 'ord'), true); + $this->assertSame('leftJoin', $query['method']); + $this->assertSame('orders', $query['attribute']); + $this->assertSame(['$id', '=', 'customerId', 'ord'], $query['values']); + } + + public function testOn(): void + { + $query = json_decode(Query::on('$id', 'customerId'), true); + $this->assertSame('on', $query['method']); + $this->assertSame(['$id', '=', 'customerId'], $query['values']); + } + + public function testNestedLeftJoin(): void + { + $query = json_decode(Query::leftJoin('orders', 'ord', [ + Query::on('$id', 'customerId'), + Query::equal('ord.status', 'paid'), + ]), true); + $this->assertSame('leftJoin', $query['method']); + $this->assertSame('orders', $query['attribute']); + $this->assertSame('ord', $query['values'][0]); + $this->assertSame('on', $query['values'][1]['method']); + $this->assertSame(['$id', '=', 'customerId'], $query['values'][1]['values']); + $this->assertSame('equal', $query['values'][2]['method']); + $this->assertSame('ord.status', $query['values'][2]['attribute']); + } + + public function testRightJoin(): void + { + $query = json_decode(Query::rightJoin('orders', '$id', 'customerId'), true); + $this->assertSame('rightJoin', $query['method']); + $this->assertSame(['$id', '=', 'customerId'], $query['values']); + } + + public function testFullOuterJoin(): void + { + $query = json_decode(Query::fullOuterJoin('orders', '$id', 'customerId'), true); + $this->assertSame('fullOuterJoin', $query['method']); + $this->assertSame(['$id', '=', 'customerId'], $query['values']); + } + + public function testCrossJoin(): void + { + $query = json_decode(Query::crossJoin('orders', 'ord'), true); + $this->assertSame('crossJoin', $query['method']); + $this->assertSame('orders', $query['attribute']); + $this->assertSame(['ord'], $query['values']); + } + + public function testNotCovers(): void + { + $query = json_decode(Query::notCovers('location', [1, 2]), true); + $this->assertSame('notCovers', $query['method']); + $this->assertSame([[1, 2]], $query['values']); + } + + public function testSpatialEquals(): void + { + $query = json_decode(Query::spatialEquals('location', [1, 2]), true); + $this->assertSame('spatialEquals', $query['method']); + $this->assertSame([[1, 2]], $query['values']); + } + + public function testNotSpatialEquals(): void + { + $query = json_decode(Query::notSpatialEquals('location', [1, 2]), true); + $this->assertSame('notSpatialEquals', $query['method']); + $this->assertSame([[1, 2]], $query['values']); + } + + public function testVectorDot(): void + { + $query = json_decode(Query::vectorDot('embedding', [0.1, 0.2]), true); + $this->assertSame('vectorDot', $query['method']); + $this->assertSame('embedding', $query['attribute']); + $this->assertSame([[0.1, 0.2]], $query['values']); + } + + public function testCovers(): void + { + $query = json_decode(Query::covers('location', [0, 0]), true); + $this->assertSame('covers', $query['method']); + $this->assertSame([[0, 0]], $query['values']); + } + + public function testPage(): void + { + $queries = Query::page(2, 10); + $this->assertCount(2, $queries); + $limit = json_decode($queries[0], true); + $offset = json_decode($queries[1], true); + $this->assertSame('limit', $limit['method']); + $this->assertSame([10], $limit['values']); + $this->assertSame('offset', $offset['method']); + $this->assertSame([10], $offset['values']); + } + + public function testPageRejectsInvalid(): void + { + $this->expectException(\InvalidArgumentException::class); + Query::page(0, 10); + } + + public function testBuilderBuild(): void + { + $expected = [ + Query::equal('status', 'published'), + Query::leftJoin('orders', '$id', 'customerId', '=', 'ord'), + Query::count('*', 'total'), + Query::groupBy(['status']), + Query::limit(25), + ]; + + $built = Query::builder() + ->equal('status', 'published') + ->leftJoin('orders', '$id', 'customerId', '=', 'ord') + ->count('*', 'total') + ->groupBy(['status']) + ->limit(25) + ->build(); + + $this->assertSame($expected, $built); + } + + public function testFlattenSpreadsWrappedBuilder(): void + { + $this->assertSame( + [Query::limit(1)], + array_values((array) Client::flatten([Query::builder()->limit(1)])) + ); + } + + public function testFlattenKeepsNestedNumericArrays(): void + { + $geometry = [[1, 2], [3, 4]]; + $this->assertSame($geometry, Client::flatten($geometry)); + } + + public function testFlattenKeepsQueryStringList(): void + { + $this->assertSame( + [Query::limit(1)], + array_values((array) Client::flatten([Query::limit(1)])) + ); + } } diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php index c4a20ad2..eed55b62 100644 --- a/tests/Appwrite/Services/AccountTest.php +++ b/tests/Appwrite/Services/AccountTest.php @@ -333,7 +333,8 @@ public function testMethodListIdentities(): void "providerEmail" => "user@example.com", "providerAccessToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", "providerAccessTokenExpiry" => "2020-10-15T06:38:00.000+00:00", - "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3" + "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerIdToken" => "eyJhbGciOiJSUzI1NiIsImtpZCI6IjBhYzNmMWQwNWExYjhlN2YifQ.eyJzdWIiOiIxMTAxNjk0ODQ0NzQzODYyNzYzMzQifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ] ] ]; @@ -366,49 +367,6 @@ public function testMethodDeleteIdentity(): void $this->assertSame($data, $response); } - public function testMethodListLogs(): void - { - $data = [ - "total" => 5, - "logs" => [ - [ - "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->account->listLogs(); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } public function testMethodUpdateMFA(): void { $data = [ diff --git a/tests/Appwrite/Services/BackupsTest.php b/tests/Appwrite/Services/BackupsTest.php index 353bd0d7..11782077 100644 --- a/tests/Appwrite/Services/BackupsTest.php +++ b/tests/Appwrite/Services/BackupsTest.php @@ -31,9 +31,7 @@ public function testMethodListArchives(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -59,9 +57,7 @@ public function testMethodCreateArchive(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -87,9 +83,7 @@ public function testMethodGetArchive(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "policyId" => "did8jx6ws45jana098ab7", - "size" => 100000, "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [] @@ -182,7 +176,7 @@ public function testMethodCreatePolicy(): void "", [BackupServices::DATABASES()], 1, - "" + "schedule" ); $this->assertInstanceOf(\Appwrite\Models\BackupPolicy::class, $response); @@ -269,11 +263,10 @@ public function testMethodCreateRestoration(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ]; $this->client @@ -302,11 +295,10 @@ public function testMethodListRestorations(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ] ] ]; @@ -331,11 +323,10 @@ public function testMethodGetRestoration(): void "archiveId" => "did8jx6ws45jana098ab7", "policyId" => "did8jx6ws45jana098ab7", "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", "migrationId" => "did8jx6ws45jana098ab7", "services" => [], "resources" => [], - "options" => "{databases.database[{oldId, newId, newName}]}" + "options" => [] ]; $this->client diff --git a/tests/Appwrite/Services/DocumentsDBTest.php b/tests/Appwrite/Services/DocumentsDBTest.php index 183fdefc..9f51a063 100644 --- a/tests/Appwrite/Services/DocumentsDBTest.php +++ b/tests/Appwrite/Services/DocumentsDBTest.php @@ -81,6 +81,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -89,13 +93,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -970,16 +968,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -989,6 +983,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1002,7 +998,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1096,10 +1092,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, diff --git a/tests/Appwrite/Services/FunctionsTest.php b/tests/Appwrite/Services/FunctionsTest.php index 0e950d3a..f229cb11 100644 --- a/tests/Appwrite/Services/FunctionsTest.php +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -72,7 +72,8 @@ public function testMethodList(): void "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", - "runtimeSpecification" => "s-1vcpu-512mb" + "runtimeSpecification" => "s-1vcpu-512mb", + "emailEnabled" => true ] ] ]; @@ -133,7 +134,8 @@ public function testMethodCreate(): void "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", - "runtimeSpecification" => "s-1vcpu-512mb" + "runtimeSpecification" => "s-1vcpu-512mb", + "emailEnabled" => true ]; $this->client @@ -250,7 +252,8 @@ public function testMethodGet(): void "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", - "runtimeSpecification" => "s-1vcpu-512mb" + "runtimeSpecification" => "s-1vcpu-512mb", + "emailEnabled" => true ]; $this->client @@ -311,7 +314,8 @@ public function testMethodUpdate(): void "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", - "runtimeSpecification" => "s-1vcpu-512mb" + "runtimeSpecification" => "s-1vcpu-512mb", + "emailEnabled" => true ]; $this->client @@ -390,7 +394,8 @@ public function testMethodUpdateFunctionDeployment(): void "providerBranches" => [], "providerPaths" => [], "buildSpecification" => "s-1vcpu-512mb", - "runtimeSpecification" => "s-1vcpu-512mb" + "runtimeSpecification" => "s-1vcpu-512mb", + "emailEnabled" => true ]; $this->client @@ -808,7 +813,7 @@ public function testMethodListExecutions(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ] ] ]; @@ -856,7 +861,7 @@ public function testMethodCreateExecution(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client @@ -902,7 +907,7 @@ public function testMethodGetExecution(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client diff --git a/tests/Appwrite/Services/MongoTest.php b/tests/Appwrite/Services/MongoTest.php index aaa2b0ea..3c162eca 100644 --- a/tests/Appwrite/Services/MongoTest.php +++ b/tests/Appwrite/Services/MongoTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -819,16 +804,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -838,6 +819,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -851,7 +834,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -884,16 +867,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -903,6 +882,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -916,7 +897,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -951,16 +932,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -970,6 +947,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -983,7 +962,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1099,14 +1078,10 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1131,14 +1106,10 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1161,14 +1132,10 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1186,6 +1153,33 @@ public function testMethodGetRestoration(): void $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); } + public function testMethodPromoteRestoration(): void + { + $data = [ + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "databaseId" => "5e5ea5c16897e", + "projectId" => "5e5ea5c16897e", + "type" => "backup", + "restoreMode" => "clone", + "status" => "completed", + "error" => "[ERROR]" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->mongo->promoteRestoration( + "", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); + } public function testMethodGetStatus(): void { $data = [ @@ -1194,10 +1188,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1240,16 +1230,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1259,6 +1245,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1272,7 +1260,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/MysqlTest.php b/tests/Appwrite/Services/MysqlTest.php index 85f067a6..9bfd1c2d 100644 --- a/tests/Appwrite/Services/MysqlTest.php +++ b/tests/Appwrite/Services/MysqlTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -849,16 +834,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -868,6 +849,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -881,7 +864,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -914,16 +897,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -933,6 +912,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -946,7 +927,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -981,16 +962,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1000,6 +977,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1013,7 +992,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1185,14 +1164,10 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1217,14 +1192,10 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1247,14 +1218,10 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1272,6 +1239,33 @@ public function testMethodGetRestoration(): void $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); } + public function testMethodPromoteRestoration(): void + { + $data = [ + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "databaseId" => "5e5ea5c16897e", + "projectId" => "5e5ea5c16897e", + "type" => "backup", + "restoreMode" => "clone", + "status" => "completed", + "error" => "[ERROR]" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->mysql->promoteRestoration( + "", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); + } public function testMethodGetStatus(): void { $data = [ @@ -1280,10 +1274,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1326,16 +1316,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1345,6 +1331,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1358,7 +1346,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/Oauth2Test.php b/tests/Appwrite/Services/Oauth2Test.php index 3196d5e8..ed0c9360 100644 --- a/tests/Appwrite/Services/Oauth2Test.php +++ b/tests/Appwrite/Services/Oauth2Test.php @@ -80,8 +80,8 @@ public function testMethodCreateDeviceAuthorization(): void $data = [ "device_code" => "5f3c8d2a1b9e4f7a6c8b2d1e9f4a7b3c5d8e1f2a9b4c7d6e3f5a8b1c4d7e2f9a", "user_code" => "ABCD-EFGH", - "verification_uri" => "https://cloud.appwrite.io/console/oauth2/device", - "verification_uri_complete" => "https://cloud.appwrite.io/console/oauth2/device?user_code=ABCD-EFGH", + "verification_uri" => "https://appwrite.io/oauth2/device", + "verification_uri_complete" => "https://appwrite.io/oauth2/device?user_code=ABCD-EFGH", "expires_in" => 900, "interval" => 5 ]; diff --git a/tests/Appwrite/Services/OrganizationTest.php b/tests/Appwrite/Services/OrganizationTest.php index 1132dac0..7fa0c08a 100644 --- a/tests/Appwrite/Services/OrganizationTest.php +++ b/tests/Appwrite/Services/OrganizationTest.php @@ -8,7 +8,6 @@ use Mockery; use Mockery\MockInterface; use PHPUnit\Framework\TestCase; -use Appwrite\Enums\OrganizationKeyScopes; use Appwrite\Enums\ProjectKeyScopes; final class OrganizationTest extends TestCase @@ -47,6 +46,7 @@ public function testMethodGet(): void "screenshotsGenerated" => 50, "webhooks" => 25, "wafRules" => 2, + "environments" => 5, "projects" => 2, "platforms" => 3, "users" => 25, @@ -71,72 +71,6 @@ public function testMethodGet(): void "usageLogs" => 30, "projectInactivityDays" => 7, "alertLimit" => 80, - "usage" => [ - "bandwidth" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "executions" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtime" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtimeMessages" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "storage" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "users" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "GBHours" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "imageTransformations" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ] - ], "addons" => [], "budgetCapEnabled" => true, "customSmtp" => true, @@ -166,17 +100,10 @@ public function testMethodGet(): void "buildSize" => 2000, "functionsIntervalMinimum" => 60, "databasesAllowEncrypt" => true, - "group" => "starter", + "group" => "free", "databaseComputeCredit" => 10 ], "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", - "billingTrialDays" => 14, - "billingAggregationId" => "adbc3de4rddfsd", - "billingInvoiceId" => "adbc3de4rddfsd", - "paymentMethodId" => "adbc3de4rddfsd", "status" => "active", "markedForDeletion" => true, "platform" => "imagine", @@ -219,6 +146,7 @@ public function testMethodUpdate(): void "screenshotsGenerated" => 50, "webhooks" => 25, "wafRules" => 2, + "environments" => 5, "projects" => 2, "platforms" => 3, "users" => 25, @@ -243,72 +171,6 @@ public function testMethodUpdate(): void "usageLogs" => 30, "projectInactivityDays" => 7, "alertLimit" => 80, - "usage" => [ - "bandwidth" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "executions" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtime" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "realtimeMessages" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "storage" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "users" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "GBHours" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ], - "imageTransformations" => [ - "name" => "[NAME]", - "unit" => "GB", - "currency" => "USD", - "price" => 5, - "value" => 25, - "invoiceDesc" => "[INVOICEDESC]" - ] - ], "addons" => [], "budgetCapEnabled" => true, "customSmtp" => true, @@ -338,17 +200,10 @@ public function testMethodUpdate(): void "buildSize" => 2000, "functionsIntervalMinimum" => 60, "databasesAllowEncrypt" => true, - "group" => "starter", + "group" => "free", "databaseComputeCredit" => 10 ], "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", - "billingTrialDays" => 14, - "billingAggregationId" => "adbc3de4rddfsd", - "billingInvoiceId" => "adbc3de4rddfsd", - "paymentMethodId" => "adbc3de4rddfsd", "status" => "active", "markedForDeletion" => true, "platform" => "imagine", @@ -511,138 +366,6 @@ public function testMethodDeleteInstallation(): void $this->assertSame($data, $response); } - public function testMethodListKeys(): void - { - $data = [ - "total" => 5, - "keys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->listKeys(); - - $this->assertInstanceOf(\Appwrite\Models\KeyList::class, $response); - } - public function testMethodCreateKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->createKey( - "", - "", - [OrganizationKeyScopes::PROJECTSREAD()] - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodGetKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->getKey( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodUpdateKey(): void - { - $data = [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "My API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "scopes" => [], - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->organization->updateKey( - "", - "", - [OrganizationKeyScopes::PROJECTSREAD()] - ); - - $this->assertInstanceOf(\Appwrite\Models\Key::class, $response); - } - public function testMethodDeleteKey(): 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->deleteKey( - "" - ); - - $this->assertSame($data, $response); - } public function testMethodListMemberships(): void { $data = [ @@ -808,18 +531,6 @@ public function testMethodListProjects(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -858,12 +569,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -891,18 +597,6 @@ public function testMethodCreateProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -941,12 +635,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -975,18 +664,6 @@ public function testMethodGetProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -1025,12 +702,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -1058,18 +730,6 @@ public function testMethodUpdateProject(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -1108,12 +768,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" diff --git a/tests/Appwrite/Services/PostgresqlTest.php b/tests/Appwrite/Services/PostgresqlTest.php index f4204910..c09437c8 100644 --- a/tests/Appwrite/Services/PostgresqlTest.php +++ b/tests/Appwrite/Services/PostgresqlTest.php @@ -31,16 +31,12 @@ public function testMethodList(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -50,6 +46,8 @@ public function testMethodList(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -63,7 +61,7 @@ public function testMethodList(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -96,16 +94,12 @@ public function testMethodCreate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -115,6 +109,8 @@ public function testMethodCreate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -128,7 +124,7 @@ public function testMethodCreate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -162,6 +158,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -170,13 +170,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -198,16 +192,12 @@ public function testMethodGet(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -217,6 +207,8 @@ public function testMethodGet(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -230,7 +222,7 @@ public function testMethodGet(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -263,16 +255,12 @@ public function testMethodUpdate(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -282,6 +270,8 @@ public function testMethodUpdate(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -295,7 +285,7 @@ public function testMethodUpdate(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -461,7 +451,7 @@ public function testMethodCreateBackupPolicy(): void "", "", "", - "", + "schedule", 1 ); @@ -630,7 +620,6 @@ public function testMethodListBranches(): void "namespace" => "db-myproject-mydb-branch-a1b2c3d4", "expiresAt" => 1711411200, "host" => "db-myproject-mydb-a1b2c3d4.fra.appwrite.center", - "port" => 5432, "database" => "db-myproject-mydb-a1b2c3d4", "username" => "appwrite", "password" => "********", @@ -662,16 +651,12 @@ public function testMethodCreateBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -681,6 +666,8 @@ public function testMethodCreateBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -694,7 +681,7 @@ public function testMethodCreateBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -727,16 +714,12 @@ public function testMethodDeleteBranch(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -746,6 +729,8 @@ public function testMethodDeleteBranch(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -759,7 +744,7 @@ public function testMethodDeleteBranch(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -877,16 +862,12 @@ public function testMethodCreateExtension(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -896,6 +877,8 @@ public function testMethodCreateExtension(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -909,7 +892,7 @@ public function testMethodCreateExtension(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -943,16 +926,12 @@ public function testMethodDeleteExtension(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -962,6 +941,8 @@ public function testMethodDeleteExtension(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -975,7 +956,7 @@ public function testMethodDeleteExtension(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1009,16 +990,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1028,6 +1005,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1041,7 +1020,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1074,16 +1053,12 @@ public function testMethodUpdateMaintenance(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1093,6 +1068,8 @@ public function testMethodUpdateMaintenance(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1106,7 +1083,7 @@ public function testMethodUpdateMaintenance(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1141,16 +1118,12 @@ public function testMethodCreateMigration(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1160,6 +1133,8 @@ public function testMethodCreateMigration(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1173,7 +1148,7 @@ public function testMethodCreateMigration(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1345,14 +1320,10 @@ public function testMethodListRestorations(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ] ] @@ -1377,14 +1348,10 @@ public function testMethodCreateRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1407,14 +1374,10 @@ public function testMethodGetRestoration(): void "\$id" => "5e5ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "databaseId" => "5e5ea5c16897e", - "sourceDatabaseId" => "5e5ea5c16897e", "projectId" => "5e5ea5c16897e", - "backupId" => "5e5ea5c16897e", "type" => "backup", + "restoreMode" => "clone", "status" => "completed", - "targetTime" => "2020-10-15T06:38:00.000+00:00", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "completedAt" => "2020-10-15T06:38:00.000+00:00", "error" => "[ERROR]" ]; @@ -1432,6 +1395,33 @@ public function testMethodGetRestoration(): void $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); } + public function testMethodPromoteRestoration(): void + { + $data = [ + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "databaseId" => "5e5ea5c16897e", + "projectId" => "5e5ea5c16897e", + "type" => "backup", + "restoreMode" => "clone", + "status" => "completed", + "error" => "[ERROR]" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->postgresql->promoteRestoration( + "", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\DedicatedDatabaseRestoration::class, $response); + } public function testMethodGetStatus(): void { $data = [ @@ -1440,10 +1430,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1486,16 +1472,12 @@ public function testMethodCreateUpgrade(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -1505,6 +1487,8 @@ public function testMethodCreateUpgrade(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -1518,7 +1502,7 @@ public function testMethodCreateUpgrade(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, diff --git a/tests/Appwrite/Services/ProjectTest.php b/tests/Appwrite/Services/ProjectTest.php index ca05b4f6..5d9b3983 100644 --- a/tests/Appwrite/Services/ProjectTest.php +++ b/tests/Appwrite/Services/ProjectTest.php @@ -36,18 +36,6 @@ public function testMethodGet(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -86,12 +74,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -132,18 +115,6 @@ public function testMethodUpdateAuthMethod(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -182,12 +153,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -219,7 +185,6 @@ public function testMethodListEnvironments(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -258,12 +223,7 @@ public function testMethodListEnvironments(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -291,7 +251,6 @@ public function testMethodCreateEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -330,12 +289,7 @@ public function testMethodCreateEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -364,7 +318,6 @@ public function testMethodGetEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -403,12 +356,7 @@ public function testMethodGetEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -436,7 +384,6 @@ public function testMethodUpdateEnvironment(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -475,12 +422,7 @@ public function testMethodUpdateEnvironment(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -657,18 +599,6 @@ public function testMethodUpdateLabels(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -707,12 +637,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -868,18 +793,6 @@ public function testMethodUpdateOAuth2Server(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -918,12 +831,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -971,7 +879,9 @@ public function testMethodUpdateOAuth2Apple(): void "serviceId" => "ip.appwrite.app.web", "keyId" => "P4000000N8", "teamId" => "D4000000R6", - "p8File" => "-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----" + "p8File" => "-----BEGIN PRIVATE KEY-----MIGTAg...jy2Xbna-----END PRIVATE KEY-----", + "nativeEnabled" => true, + "nativeClientIds" => [] ]; $this->client @@ -1012,6 +922,7 @@ public function testMethodUpdateOAuth2Auth0(): void "enabled" => true, "clientId" => "OaOkIA000000000000000000005KLSYq", "clientSecret" => "zXz0000-00000000000000000000000000000-00000000000000000000PJafnF", + "prompt" => ["none"], "endpoint" => "example.us.auth0.com" ]; @@ -1173,7 +1084,8 @@ public function testMethodUpdateOAuth2Discord(): void "\$id" => "github", "enabled" => true, "clientId" => "950722000000343754", - "clientSecret" => "YmPXnM000000000000000000002zFg5D" + "clientSecret" => "YmPXnM000000000000000000002zFg5D", + "prompt" => ["none"] ]; $this->client @@ -1314,7 +1226,8 @@ public function testMethodUpdateOAuth2GitHub(): void "\$id" => "github", "enabled" => true, "clientId" => "e4d87900000000540733", - "clientSecret" => "5e07c00000000000000000000000000000198bcc" + "clientSecret" => "5e07c00000000000000000000000000000198bcc", + "prompt" => ["select_account"] ]; $this->client @@ -1356,7 +1269,9 @@ public function testMethodUpdateOAuth2Google(): void "enabled" => true, "clientId" => "120000000095-92ifjb00000000000000000000g7ijfb.apps.googleusercontent.com", "clientSecret" => "GOCSPX-2k8gsR0000000000000000VNahJj", - "prompt" => ["none"] + "prompt" => ["none"], + "nativeEnabled" => true, + "nativeClientIds" => [] ]; $this->client @@ -1480,6 +1395,7 @@ public function testMethodUpdateOAuth2Microsoft(): void "enabled" => true, "applicationId" => "00001111-aaaa-2222-bbbb-3333cccc4444", "applicationSecret" => "A1bC2dE3fH4iJ5kL6mN7oP8qR9sT0u", + "prompt" => ["none"], "tenant" => "common" ]; @@ -1521,11 +1437,11 @@ public function testMethodUpdateOAuth2Oidc(): void "enabled" => true, "clientId" => "qibI2x0000000000000000000000000006L2YFoG", "clientSecret" => "Ah68ed000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003qpcHV", + "prompt" => ["none"], "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", - "prompt" => ["none"] + "userInfoURL" => "https://myoauth.com/oauth2/userinfo" ]; $this->client @@ -1546,6 +1462,7 @@ public function testMethodUpdateOAuth2Okta(): void "enabled" => true, "clientId" => "0oa00000000000000698", "clientSecret" => "Kiq0000000000000000000000000000000000000-00000000000H2L5-3SJ-vRV", + "prompt" => ["none"], "domain" => "trial-6400025.okta.com", "authorizationServerId" => "aus000000000000000h7z" ]; @@ -1647,7 +1564,8 @@ public function testMethodUpdateOAuth2Salesforce(): void "\$id" => "github", "enabled" => true, "customerKey" => "3MVG9I0000000000000000000000000000000000000000000000000000000000000000000000000C5Aejq", - "customerSecret" => "3w000000000000e2" + "customerSecret" => "3w000000000000e2", + "prompt" => ["login"] ]; $this->client @@ -1907,7 +1825,8 @@ public function testMethodUpdateOAuth2Zoho(): void "\$id" => "github", "enabled" => true, "clientId" => "1000.83C178000000000000000000RPNX0B", - "clientSecret" => "fb5cac000000000000000000000000000000a68f6e" + "clientSecret" => "fb5cac000000000000000000000000000000a68f6e", + "prompt" => ["consent"] ]; $this->client @@ -1995,7 +1914,8 @@ public function testMethodCreateAndroidPlatform(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "My Web App", "type" => "windows", - "applicationId" => "com.company.appname" + "applicationId" => "com.company.appname", + "fingerprints" => [] ]; $this->client @@ -2021,7 +1941,8 @@ public function testMethodUpdateAndroidPlatform(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "My Web App", "type" => "windows", - "applicationId" => "com.company.appname" + "applicationId" => "com.company.appname", + "fingerprints" => [] ]; $this->client @@ -2320,18 +2241,6 @@ public function testMethodUpdateDenyAliasedEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2370,12 +2279,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2403,18 +2307,6 @@ public function testMethodUpdateDenyCorporateEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2453,12 +2345,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2486,18 +2373,6 @@ public function testMethodUpdateDenyDisposableEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2536,12 +2411,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2569,18 +2439,6 @@ public function testMethodUpdateDenyFreeEmailPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2619,12 +2477,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2652,18 +2505,6 @@ public function testMethodUpdateMembershipPrivacyPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2702,12 +2543,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2733,18 +2569,6 @@ public function testMethodUpdateMFAFactorsPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2783,12 +2607,7 @@ public function testMethodUpdateMFAFactorsPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2814,18 +2633,6 @@ public function testMethodUpdatePasskeyPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2864,12 +2671,7 @@ public function testMethodUpdatePasskeyPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2897,18 +2699,6 @@ public function testMethodUpdatePasswordDictionaryPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -2947,12 +2737,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -2980,18 +2765,6 @@ public function testMethodUpdatePasswordHistoryPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3030,12 +2803,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3063,18 +2831,6 @@ public function testMethodUpdatePasswordPersonalDataPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3113,12 +2869,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3146,7 +2897,6 @@ public function testMethodUpdatePasswordPwnedPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3185,12 +2935,7 @@ public function testMethodUpdatePasswordPwnedPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3216,7 +2961,6 @@ public function testMethodUpdatePasswordRotationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3255,12 +2999,7 @@ public function testMethodUpdatePasswordRotationPolicy(): void "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "resourceType" => "project", "resourceId" => "5e5ea5c16897e", - "mode" => "readOnly", - "projectName" => "My Project", - "region" => "fra", - "organizationName" => "Acme Inc.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3308,18 +3047,6 @@ public function testMethodUpdateSessionAlertPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3358,12 +3085,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3391,18 +3113,6 @@ public function testMethodUpdateSessionDurationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3441,12 +3151,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3474,18 +3179,6 @@ public function testMethodUpdateSessionInvalidationPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3524,12 +3217,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3557,18 +3245,6 @@ public function testMethodUpdateSessionLimitPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3607,12 +3283,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3640,18 +3311,6 @@ public function testMethodUpdateUserLimitPolicy(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3690,12 +3349,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3749,18 +3403,6 @@ public function testMethodUpdateProtocol(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3799,12 +3441,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3833,18 +3470,6 @@ public function testMethodUpdateService(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3883,12 +3508,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" @@ -3917,18 +3537,6 @@ public function testMethodUpdateSMTP(): void "name" => "New Project", "teamId" => "1592981250", "region" => "fra", - "devKeys" => [ - [ - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "name" => "Dev API Key", - "expire" => "2020-10-15T06:38:00.000+00:00", - "secret" => "919c2d18fb5d4...a2ae413da83346ad2", - "accessedAt" => "2020-10-15T06:38:00.000+00:00", - "sdks" => [] - ] - ], "smtpEnabled" => true, "smtpSenderName" => "John Appwrite", "smtpSenderEmail" => "john@appwrite.io", @@ -3967,12 +3575,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.", - "organizationId" => "5e5ea5c16897e", - "billingPlan" => "pro" + "mode" => "readOnly" ] ], "consoleAccessedAt" => "2020-10-15T06:38:00.000+00:00" diff --git a/tests/Appwrite/Services/ProxyTest.php b/tests/Appwrite/Services/ProxyTest.php index df5e0217..209b4f20 100644 --- a/tests/Appwrite/Services/ProxyTest.php +++ b/tests/Appwrite/Services/ProxyTest.php @@ -65,7 +65,8 @@ public function testMethodListRules(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ] ] ]; @@ -97,7 +98,8 @@ public function testMethodCreateAPIRule(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client @@ -129,7 +131,8 @@ public function testMethodCreateFunctionRule(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client @@ -162,7 +165,8 @@ public function testMethodCreateRedirectRule(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client @@ -198,7 +202,8 @@ public function testMethodCreateSiteRule(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client @@ -215,6 +220,40 @@ public function testMethodCreateSiteRule(): void $this->assertInstanceOf(\Appwrite\Models\ProxyRule::class, $response); } + public function testMethodCreateSMTPRule(): void + { + $data = [ + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "domain" => "appwrite.company.com", + "type" => "deployment", + "trigger" => "manual", + "redirectUrl" => "https://appwrite.io/docs", + "redirectStatusCode" => 301, + "deploymentId" => "n3u9feiwmf", + "deploymentResourceId" => "n3u9feiwmf", + "deploymentVcsProviderBranch" => "main", + "status" => "unverified", + "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", + "renewAt" => "datetime", + "protocol" => "http" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->proxy->createSMTPRule( + "example.com", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\ProxyRule::class, $response); + } public function testMethodGetRule(): void { $data = [ @@ -231,7 +270,8 @@ public function testMethodGetRule(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client @@ -280,7 +320,8 @@ public function testMethodUpdateRuleStatus(): void "deploymentVcsProviderBranch" => "main", "status" => "unverified", "logs" => "Verification of DNS records failed with DNS resolver 8.8.8.8. Domain stage.myapp.com does not have DNS record.", - "renewAt" => "datetime" + "renewAt" => "datetime", + "protocol" => "http" ]; $this->client diff --git a/tests/Appwrite/Services/SitesTest.php b/tests/Appwrite/Services/SitesTest.php index 1dd5e5aa..0b0f8581 100644 --- a/tests/Appwrite/Services/SitesTest.php +++ b/tests/Appwrite/Services/SitesTest.php @@ -829,7 +829,7 @@ public function testMethodListLogs(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ] ] ]; @@ -877,7 +877,7 @@ public function testMethodGetLog(): void ], "logs" => "[LOGS]", "errors" => "[ERRORS]", - "duration" => 0.4 + "duration" => 1.23 ]; $this->client diff --git a/tests/Appwrite/Services/TablesDBTest.php b/tests/Appwrite/Services/TablesDBTest.php index 51b883a9..5ef55c32 100644 --- a/tests/Appwrite/Services/TablesDBTest.php +++ b/tests/Appwrite/Services/TablesDBTest.php @@ -82,6 +82,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -90,13 +94,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -321,16 +319,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -340,6 +334,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -353,7 +349,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -613,10 +609,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, @@ -1651,6 +1643,39 @@ public function testMethodCreateRelationshipColumn(): void $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); } + public function testMethodUpdateRelationshipColumn(): void + { + $data = [ + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "relatedTable" => "table", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child" + ]; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + $this->client + ->allows()->getConfig(Mockery::any()) + ->andReturn(''); + + $response = $this->tablesDB->updateRelationshipColumn( + "", + "", + "" + ); + + $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); + } public function testMethodCreateStringColumn(): void { $data = [ @@ -1939,39 +1964,6 @@ public function testMethodDeleteColumn(): void $this->assertSame($data, $response); } - public function testMethodUpdateRelationshipColumn(): void - { - $data = [ - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "relatedTable" => "table", - "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", - "twoWay" => true, - "twoWayKey" => "string", - "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child" - ]; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - $this->client - ->allows()->getConfig(Mockery::any()) - ->andReturn(''); - - $response = $this->tablesDB->updateRelationshipColumn( - "", - "", - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\ColumnRelationship::class, $response); - } public function testMethodListIndexes(): void { $data = [ diff --git a/tests/Appwrite/Services/UsersTest.php b/tests/Appwrite/Services/UsersTest.php index 4179bae7..34677d39 100644 --- a/tests/Appwrite/Services/UsersTest.php +++ b/tests/Appwrite/Services/UsersTest.php @@ -224,7 +224,8 @@ public function testMethodListIdentities(): void "providerEmail" => "user@example.com", "providerAccessToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", "providerAccessTokenExpiry" => "2020-10-15T06:38:00.000+00:00", - "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3" + "providerRefreshToken" => "MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3", + "providerIdToken" => "eyJhbGciOiJSUzI1NiIsImtpZCI6IjBhYzNmMWQwNWExYjhlN2YifQ.eyJzdWIiOiIxMTAxNjk0ODQ0NzQzODYyNzYzMzQifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" ] ] ]; @@ -719,51 +720,6 @@ public function testMethodUpdateLabels(): void $this->assertInstanceOf(\Appwrite\Models\User::class, $response); } - public function testMethodListLogs(): void - { - $data = [ - "total" => 5, - "logs" => [ - [ - "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->users->listLogs( - "" - ); - - $this->assertInstanceOf(\Appwrite\Models\LogList::class, $response); - } public function testMethodListMemberships(): void { $data = [ diff --git a/tests/Appwrite/Services/VectorsDBTest.php b/tests/Appwrite/Services/VectorsDBTest.php index fdb22e76..70fb88c4 100644 --- a/tests/Appwrite/Services/VectorsDBTest.php +++ b/tests/Appwrite/Services/VectorsDBTest.php @@ -81,6 +81,10 @@ public function testMethodListSpecifications(): void "slug" => "s-2vcpu-2gb", "name" => "Standard", "price" => 20, + "storageOverageRate" => 0.125, + "bandwidthOverageRate" => 0.08, + "replicaRate" => 1, + "pitrRate" => 0.2, "cpu" => 2000, "memory" => 2048, "maxConnections" => 200, @@ -89,13 +93,7 @@ public function testMethodListSpecifications(): void "enabled" => true ] ], - "total" => 9, - "pricing" => [ - "storageOverageRate" => 0.125, - "bandwidthOverageRate" => 0.08, - "replicaRate" => 1, - "pitrRate" => 0.2 - ] + "total" => 9 ]; $this->client @@ -950,16 +948,12 @@ public function testMethodCreateFailover(): void "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "projectId" => "5e5ea5c16897e", "name" => "My Production Database", - "api" => "postgresql", - "engine" => "postgresql", "version" => "16", "specification" => "s-2vcpu-2gb", "backend" => "edge", "hostname" => "db-myproject-mydb.fra.appwrite.center", - "connectionPort" => 5432, "connectionUser" => "appwrite_user", "connectionPassword" => "••••••••", - "credentialGeneration" => 1, "connectionString" => "postgresql://user:pass@db-myproject-mydb.fra.appwrite.center:5432/postgres?sslmode=require", "ssl" => true, "status" => "ready", @@ -969,6 +963,8 @@ public function testMethodCreateFailover(): void "cpu" => 2000, "memory" => 4096, "storage" => 100, + "storageStatus" => "resizing", + "storageTargetGb" => 120, "storageClass" => "ssd", "storageMaxGb" => 100, "nodePool" => "db-pool-4vcpu-8gb", @@ -982,7 +978,7 @@ public function testMethodCreateFailover(): void "pitrRetentionDays" => 14, "storageAutoscaling" => true, "storageAutoscalingThresholdPercent" => 85, - "storageAutoscalingMaxGb" => 500, + "storageAutoscalingMaxGb" => 30, "maintenanceWindowDay" => "sun", "maintenanceWindowHourUtc" => 3, "metricsEnabled" => true, @@ -1076,10 +1072,6 @@ public function testMethodGetStatus(): void "engine" => "postgresql", "version" => "17", "uptime" => 86400, - "connections" => [ - "current" => 12, - "max" => 100 - ], "syncMode" => "async", "syncDegraded" => true, "syncAcknowledgements" => 1, diff --git a/tests/Appwrite/TopicTest.php b/tests/Appwrite/TopicTest.php new file mode 100644 index 00000000..5760174b --- /dev/null +++ b/tests/Appwrite/TopicTest.php @@ -0,0 +1,51 @@ +assertSame('user', (string) Topic::path(['user'])); + $this->assertSame('user/notification', (string) Topic::path(['user', 'notification'])); + $this->assertSame('user/notification', (string) Topic::path(['user'])->path(['notification'])); + $this->assertSame('org/42/logs', (string) Topic::path(['org', '42'])->path(['logs'])); + } + + /** + * @return \Iterator + */ + public static function invalidLevels(): \Iterator + { + yield 'not an array' => ['user']; + yield 'empty path' => [[]]; + yield 'not a string' => [['user', 42]]; + yield 'null' => [['user', null]]; + yield 'empty level' => [['user', '']]; + yield 'slash' => [['user/123']]; + yield 'plus' => [['user', '+']]; + yield 'contains plus' => [['user', 'a+b']]; + yield 'hash' => [['user', '#']]; + yield 'contains hash' => [['user', 'a#b']]; + yield 'contains NUL' => [['user', "a\0b"]]; + } + + #[DataProvider('invalidLevels')] + public function testInvalidLevels(mixed $levels): void + { + $this->expectException(\InvalidArgumentException::class); + Topic::path($levels); + } + + #[DataProvider('invalidLevels')] + public function testInvalidLevelsWhenAppending(mixed $levels): void + { + $this->expectException(\InvalidArgumentException::class); + Topic::path(['user'])->path($levels); + } +}