From 67c30a89683c96bba3989168d38b1186346beceb Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Mar 2026 08:42:51 +0000 Subject: [PATCH 1/3] updated sdk --- CHANGELOG.md | 9 +- README.md | 2 +- docs/activities.md | 29 -- docs/backups.md | 172 -------- docs/databases.md | 39 +- docs/examples/activities/get-event.md | 16 - docs/examples/activities/list-events.md | 16 - docs/examples/backups/create-archive.md | 18 - docs/examples/backups/create-policy.md | 23 -- docs/examples/backups/create-restoration.md | 20 - docs/examples/backups/delete-archive.md | 16 - docs/examples/backups/delete-policy.md | 16 - docs/examples/backups/get-archive.md | 16 - docs/examples/backups/get-policy.md | 16 - docs/examples/backups/get-restoration.md | 16 - docs/examples/backups/list-archives.md | 16 - docs/examples/backups/list-policies.md | 16 - docs/examples/backups/list-restorations.md | 16 - docs/examples/backups/update-policy.md | 20 - docs/examples/databases/list-documents.md | 3 +- docs/examples/sites/create-deployment.md | 4 +- docs/examples/tablesdb/list-rows.md | 3 +- docs/health.md | 65 ---- docs/messaging.md | 2 +- docs/storage.md | 4 +- docs/tablesdb.md | 1 + docs/teams.md | 4 +- src/Appwrite/Client.php | 4 +- src/Appwrite/Enums/BackupServices.php | 51 --- src/Appwrite/Enums/BuildRuntime.php | 24 ++ src/Appwrite/Enums/Runtime.php | 24 ++ src/Appwrite/Enums/Scopes.php | 72 ---- src/Appwrite/Services/Activities.php | 76 ---- src/Appwrite/Services/Backups.php | 411 -------------------- src/Appwrite/Services/Databases.php | 94 +++-- src/Appwrite/Services/Health.php | 155 -------- src/Appwrite/Services/Sites.php | 9 +- src/Appwrite/Services/TablesDB.php | 7 +- tests/Appwrite/Services/ActivitiesTest.php | 82 ---- tests/Appwrite/Services/BackupsTest.php | 276 ------------- tests/Appwrite/Services/DatabasesTest.php | 72 ++-- tests/Appwrite/Services/HealthTest.php | 75 ---- tests/Appwrite/Services/SitesTest.php | 3 +- tests/Appwrite/Services/TablesDBTest.php | 12 +- 44 files changed, 184 insertions(+), 1841 deletions(-) delete mode 100644 docs/activities.md delete mode 100644 docs/backups.md delete mode 100644 docs/examples/activities/get-event.md delete mode 100644 docs/examples/activities/list-events.md delete mode 100644 docs/examples/backups/create-archive.md delete mode 100644 docs/examples/backups/create-policy.md delete mode 100644 docs/examples/backups/create-restoration.md delete mode 100644 docs/examples/backups/delete-archive.md delete mode 100644 docs/examples/backups/delete-policy.md delete mode 100644 docs/examples/backups/get-archive.md delete mode 100644 docs/examples/backups/get-policy.md delete mode 100644 docs/examples/backups/get-restoration.md delete mode 100644 docs/examples/backups/list-archives.md delete mode 100644 docs/examples/backups/list-policies.md delete mode 100644 docs/examples/backups/list-restorations.md delete mode 100644 docs/examples/backups/update-policy.md delete mode 100644 src/Appwrite/Enums/BackupServices.php delete mode 100644 src/Appwrite/Services/Activities.php delete mode 100644 src/Appwrite/Services/Backups.php delete mode 100644 tests/Appwrite/Services/ActivitiesTest.php delete mode 100644 tests/Appwrite/Services/BackupsTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index b8d0be4..6538fa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,5 @@ # Change Log -## 20.2.0 - -* Added optional encrypt parameter for database attributes (Text, Longtext, Mediumtext, Varchar) and corresponding column creation methods to enable encryption at rest. Encrypted attributes/columns cannot be queried. -* Updated API docs and code examples to include the new encrypt option (defaulting to false) across databases and TablesDB sections. -* Updated README compatibility note to reflect Appwrite server version 1.8.x. -* Add support for the new `Backups` service - ## 20.0.1 * Fix doc examples with proper formatting @@ -59,4 +52,4 @@ * Add `dart38` and `flutter332` support to runtime models * Add `gif` support to `ImageFormat` enum * Add `upsertDocument` support to `Databases` service -* Add `sequence` support to `Document` model +* Add `sequence` support to `Document` model \ No newline at end of file diff --git a/README.md b/README.md index 9713e5d..6f4db85 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![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 is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** +**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** 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) diff --git a/docs/activities.md b/docs/activities.md deleted file mode 100644 index 06b40cb..0000000 --- a/docs/activities.md +++ /dev/null @@ -1,29 +0,0 @@ -# Activities Service - - -```http request -GET https://cloud.appwrite.io/v1/activities/events -``` - -** List all events for selected filters. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| queries | string | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc. | [] | - - -```http request -GET https://cloud.appwrite.io/v1/activities/events/{eventId} -``` - -** Get event by ID. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| eventId | string | **Required** Event ID. | | - diff --git a/docs/backups.md b/docs/backups.md deleted file mode 100644 index 36a4ee9..0000000 --- a/docs/backups.md +++ /dev/null @@ -1,172 +0,0 @@ -# Backups Service - - -```http request -GET https://cloud.appwrite.io/v1/backups/archives -``` - -** List all archives for a project. ** - -### 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. | [] | - - -```http request -POST https://cloud.appwrite.io/v1/backups/archives -``` - -** Create a new archive asynchronously for a project. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| services | array | Array of services to backup | | -| resourceId | string | Resource ID. When set, only this single resource will be backed up. | | - - -```http request -GET https://cloud.appwrite.io/v1/backups/archives/{archiveId} -``` - -** Get a backup archive using it's ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| archiveId | string | **Required** Archive ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | - - -```http request -DELETE https://cloud.appwrite.io/v1/backups/archives/{archiveId} -``` - -** Delete an existing archive for a project. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| archiveId | string | **Required** Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | - - -```http request -GET https://cloud.appwrite.io/v1/backups/policies -``` - -** List all policies for a project. ** - -### 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. | [] | - - -```http request -POST https://cloud.appwrite.io/v1/backups/policies -``` - -** Create a new backup policy. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| policyId | string | Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | -| name | string | Policy name. Max length: 128 chars. | | -| services | array | Array of services to backup | | -| resourceId | string | Resource ID. When set, only this single resource will be backed up. | | -| enabled | boolean | Is policy enabled? When set to 'disabled', no backups will be taken | 1 | -| retention | integer | Days to keep backups before deletion | | -| schedule | string | Schedule CRON syntax. | | - - -```http request -GET https://cloud.appwrite.io/v1/backups/policies/{policyId} -``` - -** Get a backup policy using it's ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| policyId | string | **Required** Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | - - -```http request -PATCH https://cloud.appwrite.io/v1/backups/policies/{policyId} -``` - -** Update an existing policy using it's ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| policyId | string | **Required** Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | -| name | string | Policy name. Max length: 128 chars. | | -| retention | integer | Days to keep backups before deletion | | -| schedule | string | Cron expression | | -| enabled | boolean | Is Backup enabled? When set to 'disabled', No backup will be taken | | - - -```http request -DELETE https://cloud.appwrite.io/v1/backups/policies/{policyId} -``` - -** Delete a policy using it's ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| policyId | string | **Required** Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | - - -```http request -POST https://cloud.appwrite.io/v1/backups/restoration -``` - -** Create and trigger a new restoration for a backup on a project. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| archiveId | string | Backup archive ID to restore | | -| services | array | Array of services to restore | | -| newResourceId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | -| newResourceName | string | Database name. Max length: 128 chars. | | - - -```http request -GET https://cloud.appwrite.io/v1/backups/restorations -``` - -** List all backup restorations for a project. ** - -### 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. | [] | - - -```http request -GET https://cloud.appwrite.io/v1/backups/restorations/{restorationId} -``` - -** Get the current status of a backup restoration. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| restorationId | string | **Required** Restoration ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | - diff --git a/docs/databases.md b/docs/databases.md index f677835..6adfc45 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -264,7 +264,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | boolean | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -729,6 +729,24 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | onDelete | string | Constraints option | restrict | +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key} +``` + +** Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. | | +| key | string | **Required** Attribute Key. | | +| onDelete | string | Constraints option | | +| newKey | string | New Attribute Key. | | + + ```http request POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/string ``` @@ -918,24 +936,6 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti | key | string | **Required** Attribute Key. | | -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship -``` - -** Update relationship attribute. [Learn more about relationship attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | -| key | string | **Required** Attribute Key. | | -| onDelete | string | Constraints option | | -| newKey | string | New Attribute Key. | | - - ```http request GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` @@ -951,6 +951,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | 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. | [] | | transactionId | string | Transaction ID to read uncommitted changes within the transaction. | | | total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | +| ttl | integer | TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). | 0 | ```http request diff --git a/docs/examples/activities/get-event.md b/docs/examples/activities/get-event.md deleted file mode 100644 index 6b8f542..0000000 --- a/docs/examples/activities/get-event.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$activities = new Activities($client); - -$result = $activities->getEvent( - eventId: '' -);``` diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md deleted file mode 100644 index ef9a9d7..0000000 --- a/docs/examples/activities/list-events.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$activities = new Activities($client); - -$result = $activities->listEvents( - queries: '' // optional -);``` diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md deleted file mode 100644 index d73db2e..0000000 --- a/docs/examples/backups/create-archive.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 - -$backups = new Backups($client); - -$result = $backups->createArchive( - services: [BackupServices::DATABASES()], - resourceId: '' // optional -);``` diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md deleted file mode 100644 index ea87f28..0000000 --- a/docs/examples/backups/create-policy.md +++ /dev/null @@ -1,23 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->createPolicy( - policyId: '', - services: [BackupServices::DATABASES()], - retention: 1, - schedule: '', - name: '', // optional - resourceId: '', // optional - enabled: false // optional -);``` diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md deleted file mode 100644 index 61d9e0b..0000000 --- a/docs/examples/backups/create-restoration.md +++ /dev/null @@ -1,20 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->createRestoration( - archiveId: '', - services: [BackupServices::DATABASES()], - newResourceId: '', // optional - newResourceName: '' // optional -);``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md deleted file mode 100644 index a6c3d33..0000000 --- a/docs/examples/backups/delete-archive.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->deleteArchive( - archiveId: '' -);``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md deleted file mode 100644 index 3c6df8f..0000000 --- a/docs/examples/backups/delete-policy.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->deletePolicy( - policyId: '' -);``` diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md deleted file mode 100644 index 6fa9ea9..0000000 --- a/docs/examples/backups/get-archive.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->getArchive( - archiveId: '' -);``` diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md deleted file mode 100644 index e8ce5c8..0000000 --- a/docs/examples/backups/get-policy.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->getPolicy( - policyId: '' -);``` diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md deleted file mode 100644 index ed3e94a..0000000 --- a/docs/examples/backups/get-restoration.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->getRestoration( - restorationId: '' -);``` diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md deleted file mode 100644 index 4060e3c..0000000 --- a/docs/examples/backups/list-archives.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->listArchives( - queries: [] // optional -);``` diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md deleted file mode 100644 index a8b0331..0000000 --- a/docs/examples/backups/list-policies.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->listPolicies( - queries: [] // optional -);``` diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md deleted file mode 100644 index 2c7132b..0000000 --- a/docs/examples/backups/list-restorations.md +++ /dev/null @@ -1,16 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->listRestorations( - queries: [] // optional -);``` diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md deleted file mode 100644 index fe53fa2..0000000 --- a/docs/examples/backups/update-policy.md +++ /dev/null @@ -1,20 +0,0 @@ -```php -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$backups = new Backups($client); - -$result = $backups->updatePolicy( - policyId: '', - name: '', // optional - retention: 1, // optional - schedule: '', // optional - enabled: false // optional -);``` diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md index 1ff2692..8e31858 100644 --- a/docs/examples/databases/list-documents.md +++ b/docs/examples/databases/list-documents.md @@ -16,5 +16,6 @@ $result = $databases->listDocuments( collectionId: '', queries: [], // optional transactionId: '', // optional - total: false // optional + total: false, // optional + ttl: 0 // optional );``` diff --git a/docs/examples/sites/create-deployment.md b/docs/examples/sites/create-deployment.md index c890f11..536300d 100644 --- a/docs/examples/sites/create-deployment.md +++ b/docs/examples/sites/create-deployment.md @@ -15,8 +15,8 @@ $sites = new Sites($client); $result = $sites->createDeployment( siteId: '', code: InputFile::withPath('file.png'), - activate: false, installCommand: '', // optional buildCommand: '', // optional - outputDirectory: '' // optional + outputDirectory: '', // optional + activate: false // optional );``` diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md index 710c791..b70a759 100644 --- a/docs/examples/tablesdb/list-rows.md +++ b/docs/examples/tablesdb/list-rows.md @@ -16,5 +16,6 @@ $result = $tablesDB->listRows( tableId: '', queries: [], // optional transactionId: '', // optional - total: false // optional + total: false, // optional + ttl: 0 // optional );``` diff --git a/docs/health.md b/docs/health.md index 4532a8c..a381890 100644 --- a/docs/health.md +++ b/docs/health.md @@ -62,32 +62,6 @@ GET https://cloud.appwrite.io/v1/health/queue/audits | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | -```http request -GET https://cloud.appwrite.io/v1/health/queue/billing-project-aggregation -``` - -** Get billing project aggregation queue. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 10000 | - - -```http request -GET https://cloud.appwrite.io/v1/health/queue/billing-team-aggregation -``` - -** Get billing team aggregation queue. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 10000 | - - ```http request GET https://cloud.appwrite.io/v1/health/queue/builds ``` @@ -101,19 +75,6 @@ GET https://cloud.appwrite.io/v1/health/queue/builds | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | -```http request -GET https://cloud.appwrite.io/v1/health/queue/builds-priority -``` - -** Get the priority builds queue size. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 500. | 500 | - - ```http request GET https://cloud.appwrite.io/v1/health/queue/certificates ``` @@ -234,19 +195,6 @@ GET https://cloud.appwrite.io/v1/health/queue/migrations | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | -```http request -GET https://cloud.appwrite.io/v1/health/queue/region-manager -``` - -** Get region manager queue. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. | 100 | - - ```http request GET https://cloud.appwrite.io/v1/health/queue/stats-resources ``` @@ -273,19 +221,6 @@ GET https://cloud.appwrite.io/v1/health/queue/stats-usage | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | -```http request -GET https://cloud.appwrite.io/v1/health/queue/threats -``` - -** Get threats queue. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. | 100 | - - ```http request GET https://cloud.appwrite.io/v1/health/queue/webhooks ``` diff --git a/docs/messaging.md b/docs/messaging.md index fa1be09..507e64b 100644 --- a/docs/messaging.md +++ b/docs/messaging.md @@ -986,7 +986,7 @@ GET https://cloud.appwrite.io/v1/messaging/topics/{topicId}/subscribers | Field Name | Type | Description | Default | | --- | --- | --- | --- | | topicId | string | **Required** Topic ID. The topic ID subscribed to. | | -| 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, provider, type, enabled | [] | +| 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: targetId, topicId, userId, providerType | [] | | search | string | Search term to filter your list results. Max length: 256 chars. | | | total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | diff --git a/docs/storage.md b/docs/storage.md index c051c9b..74960e3 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -31,7 +31,7 @@ POST https://cloud.appwrite.io/v1/storage/buckets | permissions | array | An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | fileSecurity | boolean | Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. | 1 | -| maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 5GB. | [] | +| maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 30MB. | [] | | allowedFileExtensions | array | Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. | [] | | compression | string | Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled | none | | encryption | boolean | Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled | 1 | @@ -67,7 +67,7 @@ PUT https://cloud.appwrite.io/v1/storage/buckets/{bucketId} | permissions | array | An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | fileSecurity | boolean | Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. | 1 | -| maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 5GB. | [] | +| maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 30MB. | [] | | allowedFileExtensions | array | Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. | [] | | compression | string | Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled | none | | encryption | boolean | Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled | 1 | diff --git a/docs/tablesdb.md b/docs/tablesdb.md index f2eb6b0..326752c 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -1016,6 +1016,7 @@ GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows | 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. | [] | | transactionId | string | Transaction ID to read uncommitted changes within the transaction. | | | total | boolean | When set to false, the total count returned will be 0 and will not be calculated. | 1 | +| ttl | integer | TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). | 0 | ```http request diff --git a/docs/teams.md b/docs/teams.md index 8d98f24..7874cf5 100644 --- a/docs/teams.md +++ b/docs/teams.md @@ -108,7 +108,7 @@ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatShee | email | string | Email of the new team member. | | | userId | string | ID of the user to be added to a team. | | | phone | string | Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. | | -| roles | array | Array of strings. Use this param to set the user roles in the team. 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. | | +| roles | array | Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. | | | url | string | URL to redirect the user back to your app from the invitation email. This parameter is not required when an API key is supplied. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. | | | name | string | Name of the new team member. Max length: 128 chars. | | @@ -140,7 +140,7 @@ PATCH https://cloud.appwrite.io/v1/teams/{teamId}/memberships/{membershipId} | --- | --- | --- | --- | | teamId | string | **Required** Team ID. | | | membershipId | string | **Required** Membership ID. | | -| roles | array | An array of strings. Use this param to set the user's roles in the team. 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. | | +| roles | array | An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 81 characters long. | | ```http request diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 0a744c8..5a21121 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,11 +37,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/20.2.0 ()', + 'user-agent' => 'AppwritePHPSDK/20.0.1 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '20.2.0', + 'x-sdk-version'=> '20.0.1', ]; /** diff --git a/src/Appwrite/Enums/BackupServices.php b/src/Appwrite/Enums/BackupServices.php deleted file mode 100644 index 8eb096d..0000000 --- a/src/Appwrite/Enums/BackupServices.php +++ /dev/null @@ -1,51 +0,0 @@ -value = $value; - } - - public function __toString(): string - { - return $this->value; - } - - public function jsonSerialize(): string - { - return $this->value; - } - - public static function DATABASES(): BackupServices - { - if (!isset(self::$DATABASES)) { - self::$DATABASES = new BackupServices('databases'); - } - return self::$DATABASES; - } - public static function FUNCTIONS(): BackupServices - { - if (!isset(self::$FUNCTIONS)) { - self::$FUNCTIONS = new BackupServices('functions'); - } - return self::$FUNCTIONS; - } - public static function STORAGE(): BackupServices - { - if (!isset(self::$STORAGE)) { - self::$STORAGE = new BackupServices('storage'); - } - return self::$STORAGE; - } -} \ No newline at end of file diff --git a/src/Appwrite/Enums/BuildRuntime.php b/src/Appwrite/Enums/BuildRuntime.php index f0d01a0..636db5a 100644 --- a/src/Appwrite/Enums/BuildRuntime.php +++ b/src/Appwrite/Enums/BuildRuntime.php @@ -37,6 +37,9 @@ class BuildRuntime implements JsonSerializable private static BuildRuntime $PYTHONML311; private static BuildRuntime $PYTHONML312; private static BuildRuntime $PYTHONML313; + private static BuildRuntime $DENO121; + private static BuildRuntime $DENO124; + private static BuildRuntime $DENO135; private static BuildRuntime $DENO140; private static BuildRuntime $DENO146; private static BuildRuntime $DENO20; @@ -327,6 +330,27 @@ public static function PYTHONML313(): BuildRuntime } return self::$PYTHONML313; } + public static function DENO121(): BuildRuntime + { + if (!isset(self::$DENO121)) { + self::$DENO121 = new BuildRuntime('deno-1.21'); + } + return self::$DENO121; + } + public static function DENO124(): BuildRuntime + { + if (!isset(self::$DENO124)) { + self::$DENO124 = new BuildRuntime('deno-1.24'); + } + return self::$DENO124; + } + public static function DENO135(): BuildRuntime + { + if (!isset(self::$DENO135)) { + self::$DENO135 = new BuildRuntime('deno-1.35'); + } + return self::$DENO135; + } public static function DENO140(): BuildRuntime { if (!isset(self::$DENO140)) { diff --git a/src/Appwrite/Enums/Runtime.php b/src/Appwrite/Enums/Runtime.php index 2388a96..a0a8355 100644 --- a/src/Appwrite/Enums/Runtime.php +++ b/src/Appwrite/Enums/Runtime.php @@ -37,6 +37,9 @@ class Runtime implements JsonSerializable private static Runtime $PYTHONML311; private static Runtime $PYTHONML312; private static Runtime $PYTHONML313; + private static Runtime $DENO121; + private static Runtime $DENO124; + private static Runtime $DENO135; private static Runtime $DENO140; private static Runtime $DENO146; private static Runtime $DENO20; @@ -327,6 +330,27 @@ public static function PYTHONML313(): Runtime } return self::$PYTHONML313; } + public static function DENO121(): Runtime + { + if (!isset(self::$DENO121)) { + self::$DENO121 = new Runtime('deno-1.21'); + } + return self::$DENO121; + } + public static function DENO124(): Runtime + { + if (!isset(self::$DENO124)) { + self::$DENO124 = new Runtime('deno-1.24'); + } + return self::$DENO124; + } + public static function DENO135(): Runtime + { + if (!isset(self::$DENO135)) { + self::$DENO135 = new Runtime('deno-1.35'); + } + return self::$DENO135; + } public static function DENO140(): Runtime { if (!isset(self::$DENO140)) { diff --git a/src/Appwrite/Enums/Scopes.php b/src/Appwrite/Enums/Scopes.php index e9478f1..0516c7b 100644 --- a/src/Appwrite/Enums/Scopes.php +++ b/src/Appwrite/Enums/Scopes.php @@ -63,15 +63,6 @@ class Scopes implements JsonSerializable private static Scopes $ASSISTANTREAD; private static Scopes $TOKENSREAD; private static Scopes $TOKENSWRITE; - private static Scopes $POLICIESWRITE; - private static Scopes $POLICIESREAD; - private static Scopes $ARCHIVESREAD; - private static Scopes $ARCHIVESWRITE; - private static Scopes $RESTORATIONSREAD; - private static Scopes $RESTORATIONSWRITE; - private static Scopes $DOMAINSREAD; - private static Scopes $DOMAINSWRITE; - private static Scopes $EVENTSREAD; private string $value; @@ -489,67 +480,4 @@ public static function TOKENSWRITE(): Scopes } return self::$TOKENSWRITE; } - public static function POLICIESWRITE(): Scopes - { - if (!isset(self::$POLICIESWRITE)) { - self::$POLICIESWRITE = new Scopes('policies.write'); - } - return self::$POLICIESWRITE; - } - public static function POLICIESREAD(): Scopes - { - if (!isset(self::$POLICIESREAD)) { - self::$POLICIESREAD = new Scopes('policies.read'); - } - return self::$POLICIESREAD; - } - public static function ARCHIVESREAD(): Scopes - { - if (!isset(self::$ARCHIVESREAD)) { - self::$ARCHIVESREAD = new Scopes('archives.read'); - } - return self::$ARCHIVESREAD; - } - public static function ARCHIVESWRITE(): Scopes - { - if (!isset(self::$ARCHIVESWRITE)) { - self::$ARCHIVESWRITE = new Scopes('archives.write'); - } - return self::$ARCHIVESWRITE; - } - public static function RESTORATIONSREAD(): Scopes - { - if (!isset(self::$RESTORATIONSREAD)) { - self::$RESTORATIONSREAD = new Scopes('restorations.read'); - } - return self::$RESTORATIONSREAD; - } - public static function RESTORATIONSWRITE(): Scopes - { - if (!isset(self::$RESTORATIONSWRITE)) { - self::$RESTORATIONSWRITE = new Scopes('restorations.write'); - } - return self::$RESTORATIONSWRITE; - } - public static function DOMAINSREAD(): Scopes - { - if (!isset(self::$DOMAINSREAD)) { - self::$DOMAINSREAD = new Scopes('domains.read'); - } - return self::$DOMAINSREAD; - } - public static function DOMAINSWRITE(): Scopes - { - if (!isset(self::$DOMAINSWRITE)) { - self::$DOMAINSWRITE = new Scopes('domains.write'); - } - return self::$DOMAINSWRITE; - } - public static function EVENTSREAD(): Scopes - { - if (!isset(self::$EVENTSREAD)) { - self::$EVENTSREAD = new Scopes('events.read'); - } - return self::$EVENTSREAD; - } } \ No newline at end of file diff --git a/src/Appwrite/Services/Activities.php b/src/Appwrite/Services/Activities.php deleted file mode 100644 index b8c0e83..0000000 --- a/src/Appwrite/Services/Activities.php +++ /dev/null @@ -1,76 +0,0 @@ -client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get event by ID. - * - * - * @param string $eventId - * @throws AppwriteException - * @return array - */ - public function getEvent(string $eventId): array - { - $apiPath = str_replace( - ['{eventId}'], - [$eventId], - '/activities/events/{eventId}' - ); - - $apiParams = []; - $apiParams['eventId'] = $eventId; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } -} \ No newline at end of file diff --git a/src/Appwrite/Services/Backups.php b/src/Appwrite/Services/Backups.php deleted file mode 100644 index bca41ac..0000000 --- a/src/Appwrite/Services/Backups.php +++ /dev/null @@ -1,411 +0,0 @@ -client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a new archive asynchronously for a project. - * - * @param array $services - * @param ?string $resourceId - * @throws AppwriteException - * @return array - */ - public function createArchive(array $services, ?string $resourceId = null): array - { - $apiPath = str_replace( - [], - [], - '/backups/archives' - ); - - $apiParams = []; - $apiParams['services'] = $services; - $apiParams['resourceId'] = $resourceId; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get a backup archive using it's ID. - * - * @param string $archiveId - * @throws AppwriteException - * @return array - */ - public function getArchive(string $archiveId): array - { - $apiPath = str_replace( - ['{archiveId}'], - [$archiveId], - '/backups/archives/{archiveId}' - ); - - $apiParams = []; - $apiParams['archiveId'] = $archiveId; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Delete an existing archive for a project. - * - * @param string $archiveId - * @throws AppwriteException - * @return string - */ - public function deleteArchive(string $archiveId): string - { - $apiPath = str_replace( - ['{archiveId}'], - [$archiveId], - '/backups/archives/{archiveId}' - ); - - $apiParams = []; - $apiParams['archiveId'] = $archiveId; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * List all policies for a project. - * - * @param ?array $queries - * @throws AppwriteException - * @return array - */ - public function listPolicies(?array $queries = null): array - { - $apiPath = str_replace( - [], - [], - '/backups/policies' - ); - - $apiParams = []; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a new backup policy. - * - * @param string $policyId - * @param array $services - * @param int $retention - * @param string $schedule - * @param ?string $name - * @param ?string $resourceId - * @param ?bool $enabled - * @throws AppwriteException - * @return array - */ - public function createPolicy(string $policyId, array $services, int $retention, string $schedule, ?string $name = null, ?string $resourceId = null, ?bool $enabled = null): array - { - $apiPath = str_replace( - [], - [], - '/backups/policies' - ); - - $apiParams = []; - $apiParams['policyId'] = $policyId; - $apiParams['services'] = $services; - $apiParams['retention'] = $retention; - $apiParams['schedule'] = $schedule; - - if (!is_null($name)) { - $apiParams['name'] = $name; - } - $apiParams['resourceId'] = $resourceId; - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get a backup policy using it's ID. - * - * @param string $policyId - * @throws AppwriteException - * @return array - */ - public function getPolicy(string $policyId): array - { - $apiPath = str_replace( - ['{policyId}'], - [$policyId], - '/backups/policies/{policyId}' - ); - - $apiParams = []; - $apiParams['policyId'] = $policyId; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an existing policy using it's ID. - * - * @param string $policyId - * @param ?string $name - * @param ?int $retention - * @param ?string $schedule - * @param ?bool $enabled - * @throws AppwriteException - * @return array - */ - public function updatePolicy(string $policyId, ?string $name = null, ?int $retention = null, ?string $schedule = null, ?bool $enabled = null): array - { - $apiPath = str_replace( - ['{policyId}'], - [$policyId], - '/backups/policies/{policyId}' - ); - - $apiParams = []; - $apiParams['policyId'] = $policyId; - $apiParams['name'] = $name; - $apiParams['retention'] = $retention; - - if (!is_null($schedule)) { - $apiParams['schedule'] = $schedule; - } - $apiParams['enabled'] = $enabled; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Delete a policy using it's ID. - * - * @param string $policyId - * @throws AppwriteException - * @return string - */ - public function deletePolicy(string $policyId): string - { - $apiPath = str_replace( - ['{policyId}'], - [$policyId], - '/backups/policies/{policyId}' - ); - - $apiParams = []; - $apiParams['policyId'] = $policyId; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create and trigger a new restoration for a backup on a project. - * - * @param string $archiveId - * @param array $services - * @param ?string $newResourceId - * @param ?string $newResourceName - * @throws AppwriteException - * @return array - */ - public function createRestoration(string $archiveId, array $services, ?string $newResourceId = null, ?string $newResourceName = null): array - { - $apiPath = str_replace( - [], - [], - '/backups/restoration' - ); - - $apiParams = []; - $apiParams['archiveId'] = $archiveId; - $apiParams['services'] = $services; - - if (!is_null($newResourceId)) { - $apiParams['newResourceId'] = $newResourceId; - } - - if (!is_null($newResourceName)) { - $apiParams['newResourceName'] = $newResourceName; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * List all backup restorations for a project. - * - * @param ?array $queries - * @throws AppwriteException - * @return array - */ - public function listRestorations(?array $queries = null): array - { - $apiPath = str_replace( - [], - [], - '/backups/restorations' - ); - - $apiParams = []; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get the current status of a backup restoration. - * - * @param string $restorationId - * @throws AppwriteException - * @return array - */ - public function getRestoration(string $restorationId): array - { - $apiPath = str_replace( - ['{restorationId}'], - [$restorationId], - '/backups/restorations/{restorationId}' - ); - - $apiParams = []; - $apiParams['restorationId'] = $restorationId; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } -} \ No newline at end of file diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 4354e07..4fcf0cc 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -1805,6 +1805,51 @@ public function createRelationshipAttribute(string $databaseId, string $collecti ); } + /** + * Update relationship attribute. [Learn more about relationship + * attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). + * + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param ?RelationMutate $onDelete + * @param ?string $newKey + * @throws AppwriteException + * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateRelationshipColumn` instead. + * @see TablesDB::updateRelationshipColumn + */ + public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{key}'], + [$databaseId, $collectionId, $key], + '/databases/{databaseId}/collections/{collectionId}/attributes/relationship/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + + if (!is_null($onDelete)) { + $apiParams['onDelete'] = $onDelete; + } + $apiParams['newKey'] = $newKey; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Create a string attribute. * @@ -2247,48 +2292,6 @@ public function deleteAttribute(string $databaseId, string $collectionId, string ); } - /** - * Update relationship attribute. [Learn more about relationship - * attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). - * - * - * @param string $databaseId - * @param string $collectionId - * @param string $key - * @param ?RelationMutate $onDelete - * @param ?string $newKey - * @throws AppwriteException - * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateRelationshipColumn` instead. - * @see TablesDB::updateRelationshipColumn - */ - public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{collectionId}', '{key}'], - [$databaseId, $collectionId, $key], - '/databases/{databaseId}/collections/{collectionId}/attributes/{key}/relationship' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['collectionId'] = $collectionId; - $apiParams['key'] = $key; - $apiParams['onDelete'] = $onDelete; - $apiParams['newKey'] = $newKey; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - /** * Get a list of all the user's documents in a given collection. You can use * the query params to filter your results. @@ -2298,13 +2301,14 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti * @param ?array $queries * @param ?string $transactionId * @param ?bool $total + * @param ?int $ttl * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `listRows` instead. * @see TablesDB::listRows */ - public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null): array + public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -2328,6 +2332,10 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ $apiParams['total'] = $total; } + if (!is_null($ttl)) { + $apiParams['ttl'] = $ttl; + } + $apiHeaders = []; return $this->client->call( diff --git a/src/Appwrite/Services/Health.php b/src/Appwrite/Services/Health.php index 0644a0f..c4a694b 100644 --- a/src/Appwrite/Services/Health.php +++ b/src/Appwrite/Services/Health.php @@ -209,68 +209,6 @@ public function getQueueAudits(?int $threshold = null): array ); } - /** - * Get billing project aggregation queue. - * - * @param ?int $threshold - * @throws AppwriteException - * @return array - */ - public function getQueueBillingProjectAggregation(?int $threshold = null): array - { - $apiPath = str_replace( - [], - [], - '/health/queue/billing-project-aggregation' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get billing team aggregation queue. - * - * @param ?int $threshold - * @throws AppwriteException - * @return array - */ - public function getQueueBillingTeamAggregation(?int $threshold = null): array - { - $apiPath = str_replace( - [], - [], - '/health/queue/billing-team-aggregation' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - /** * Get the number of builds that are waiting to be processed in the Appwrite * internal queue server. @@ -303,37 +241,6 @@ public function getQueueBuilds(?int $threshold = null): array ); } - /** - * Get the priority builds queue size. - * - * @param ?int $threshold - * @throws AppwriteException - * @return array - */ - public function getQueuePriorityBuilds(?int $threshold = null): array - { - $apiPath = str_replace( - [], - [], - '/health/queue/builds-priority' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - /** * Get the number of certificates that are waiting to be issued against * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue @@ -630,37 +537,6 @@ public function getQueueMigrations(?int $threshold = null): array ); } - /** - * Get region manager queue. - * - * @param ?int $threshold - * @throws AppwriteException - * @return array - */ - public function getQueueRegionManager(?int $threshold = null): array - { - $apiPath = str_replace( - [], - [], - '/health/queue/region-manager' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - /** * Get the number of metrics that are waiting to be processed in the Appwrite * stats resources queue. @@ -725,37 +601,6 @@ public function getQueueUsage(?int $threshold = null): array ); } - /** - * Get threats queue. - * - * @param ?int $threshold - * @throws AppwriteException - * @return array - */ - public function getQueueThreats(?int $threshold = null): array - { - $apiPath = str_replace( - [], - [], - '/health/queue/threats' - ); - - $apiParams = []; - - if (!is_null($threshold)) { - $apiParams['threshold'] = $threshold; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - /** * Get the number of webhooks that are waiting to be processed in the Appwrite * internal queue server. diff --git a/src/Appwrite/Services/Sites.php b/src/Appwrite/Services/Sites.php index 50788f9..3dcdc1f 100644 --- a/src/Appwrite/Services/Sites.php +++ b/src/Appwrite/Services/Sites.php @@ -468,14 +468,14 @@ public function listDeployments(string $siteId, ?array $queries = null, ?string * * @param string $siteId * @param InputFile $code - * @param bool $activate * @param ?string $installCommand * @param ?string $buildCommand * @param ?string $outputDirectory + * @param ?bool $activate * @throws AppwriteException * @return array */ - public function createDeployment(string $siteId, InputFile $code, bool $activate, ?string $installCommand = null, ?string $buildCommand = null, ?string $outputDirectory = null, ?callable $onProgress = null): array + public function createDeployment(string $siteId, InputFile $code, ?string $installCommand = null, ?string $buildCommand = null, ?string $outputDirectory = null, ?bool $activate = null, ?callable $onProgress = null): array { $apiPath = str_replace( ['{siteId}'], @@ -486,7 +486,6 @@ public function createDeployment(string $siteId, InputFile $code, bool $activate $apiParams = []; $apiParams['siteId'] = $siteId; $apiParams['code'] = $code; - $apiParams['activate'] = $activate; if (!is_null($installCommand)) { $apiParams['installCommand'] = $installCommand; @@ -500,6 +499,10 @@ public function createDeployment(string $siteId, InputFile $code, bool $activate $apiParams['outputDirectory'] = $outputDirectory; } + if (!is_null($activate)) { + $apiParams['activate'] = $activate; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'multipart/form-data'; $size = 0; diff --git a/src/Appwrite/Services/TablesDB.php b/src/Appwrite/Services/TablesDB.php index 01d1a45..c8edce6 100644 --- a/src/Appwrite/Services/TablesDB.php +++ b/src/Appwrite/Services/TablesDB.php @@ -2340,10 +2340,11 @@ public function deleteIndex(string $databaseId, string $tableId, string $key): s * @param ?array $queries * @param ?string $transactionId * @param ?bool $total + * @param ?int $ttl * @throws AppwriteException * @return array */ - public function listRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null): array + public function listRows(string $databaseId, string $tableId, ?array $queries = null, ?string $transactionId = null, ?bool $total = null, ?int $ttl = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -2367,6 +2368,10 @@ public function listRows(string $databaseId, string $tableId, ?array $queries = $apiParams['total'] = $total; } + if (!is_null($ttl)) { + $apiParams['ttl'] = $ttl; + } + $apiHeaders = []; return $this->client->call( diff --git a/tests/Appwrite/Services/ActivitiesTest.php b/tests/Appwrite/Services/ActivitiesTest.php deleted file mode 100644 index caaf39e..0000000 --- a/tests/Appwrite/Services/ActivitiesTest.php +++ /dev/null @@ -1,82 +0,0 @@ -client = Mockery::mock(Client::class); - $this->activities = new Activities($this->client); - } - - public function testMethodListEvents(): void { - - $data = array( - "total" => 5, - "events" => array()); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->activities->listEvents( - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetEvent(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "userType" => "user", - "userId" => "610fc2f985ee0", - "userEmail" => "john@appwrite.io", - "userName" => "John Doe", - "resourceParent" => "database/ID", - "resourceType" => "collection", - "resourceId" => "610fc2f985ee0", - "resource" => "collections/610fc2f985ee0", - "event" => "account.sessions.create", - "userAgent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36", - "ip" => "127.0.0.1", - "mode" => "admin", - "country" => "US", - "time" => "2020-10-15T06:38:00.000+00:00", - "projectId" => "610fc2f985ee0", - "teamId" => "610fc2f985ee0", - "hostname" => "appwrite.io", - "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); - - $response = $this->activities->getEvent( - "" - ); - - $this->assertSame($data, $response); - } - -} diff --git a/tests/Appwrite/Services/BackupsTest.php b/tests/Appwrite/Services/BackupsTest.php deleted file mode 100644 index c485ef7..0000000 --- a/tests/Appwrite/Services/BackupsTest.php +++ /dev/null @@ -1,276 +0,0 @@ -client = Mockery::mock(Client::class); - $this->backups = new Backups($this->client); - } - - public function testMethodListArchives(): void { - - $data = array( - "total" => 5, - "archives" => array()); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->listArchives( - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateArchive(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$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" => array(), - "resources" => array()); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->createArchive( - array(BackupServices::DATABASES()) - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetArchive(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$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" => array(), - "resources" => array()); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->getArchive( - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeleteArchive(): void { - - $data = ''; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->deleteArchive( - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodListPolicies(): void { - - $data = array( - "total" => 5, - "policies" => array()); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->listPolicies( - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreatePolicy(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "name" => "Hourly backups", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "services" => array(), - "resources" => array(), - "retention" => 7, - "schedule" => "0 * * * *", - "enabled" => true); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->createPolicy( - "", - array(BackupServices::DATABASES()), - 1, - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetPolicy(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "name" => "Hourly backups", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "services" => array(), - "resources" => array(), - "retention" => 7, - "schedule" => "0 * * * *", - "enabled" => true); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->getPolicy( - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdatePolicy(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "name" => "Hourly backups", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "services" => array(), - "resources" => array(), - "retention" => 7, - "schedule" => "0 * * * *", - "enabled" => true); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->updatePolicy( - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeletePolicy(): void { - - $data = ''; - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->deletePolicy( - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateRestoration(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "archiveId" => "did8jx6ws45jana098ab7", - "policyId" => "did8jx6ws45jana098ab7", - "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "migrationId" => "did8jx6ws45jana098ab7", - "services" => array(), - "resources" => array(), - "options" => "{databases.database[{oldId, newId, newName}]}"); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->createRestoration( - "", - array(BackupServices::DATABASES()) - ); - - $this->assertSame($data, $response); - } - - public function testMethodListRestorations(): void { - - $data = array( - "total" => 5, - "restorations" => array()); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->listRestorations( - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetRestoration(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "archiveId" => "did8jx6ws45jana098ab7", - "policyId" => "did8jx6ws45jana098ab7", - "status" => "completed", - "startedAt" => "2020-10-15T06:38:00.000+00:00", - "migrationId" => "did8jx6ws45jana098ab7", - "services" => array(), - "resources" => array(), - "options" => "{databases.database[{oldId, newId, newName}]}"); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->backups->getRestoration( - "" - ); - - $this->assertSame($data, $response); - } - -} diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index 551944c..a6e87b6 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -44,9 +44,7 @@ public function testMethodCreate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy", - "policies" => array(), - "archives" => array()); + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -182,9 +180,7 @@ public function testMethodGet(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy", - "policies" => array(), - "archives" => array()); + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -205,9 +201,7 @@ public function testMethodUpdate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy", - "policies" => array(), - "archives" => array()); + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1023,6 +1017,36 @@ public function testMethodCreateRelationshipAttribute(): void { $this->assertSame($data, $response); } + public function testMethodUpdateRelationshipAttribute(): void { + + $data = array( + "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", + "relatedCollection" => "collection", + "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); + + $response = $this->databases->updateRelationshipAttribute( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateStringAttribute(): void { $data = array( @@ -1276,36 +1300,6 @@ public function testMethodDeleteAttribute(): void { $this->assertSame($data, $response); } - public function testMethodUpdateRelationshipAttribute(): void { - - $data = array( - "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", - "relatedCollection" => "collection", - "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); - - $response = $this->databases->updateRelationshipAttribute( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - public function testMethodListDocuments(): void { $data = array( diff --git a/tests/Appwrite/Services/HealthTest.php b/tests/Appwrite/Services/HealthTest.php index bf501d9..28c637c 100644 --- a/tests/Appwrite/Services/HealthTest.php +++ b/tests/Appwrite/Services/HealthTest.php @@ -133,36 +133,6 @@ public function testMethodGetQueueAudits(): void { $this->assertSame($data, $response); } - public function testMethodGetQueueBillingProjectAggregation(): void { - - $data = array( - "size" => 8); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->health->getQueueBillingProjectAggregation( - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetQueueBillingTeamAggregation(): void { - - $data = array( - "size" => 8); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->health->getQueueBillingTeamAggregation( - ); - - $this->assertSame($data, $response); - } - public function testMethodGetQueueBuilds(): void { $data = array( @@ -178,21 +148,6 @@ public function testMethodGetQueueBuilds(): void { $this->assertSame($data, $response); } - public function testMethodGetQueuePriorityBuilds(): void { - - $data = array( - "size" => 8); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->health->getQueuePriorityBuilds( - ); - - $this->assertSame($data, $response); - } - public function testMethodGetQueueCertificates(): void { $data = array( @@ -329,21 +284,6 @@ public function testMethodGetQueueMigrations(): void { $this->assertSame($data, $response); } - public function testMethodGetQueueRegionManager(): void { - - $data = array( - "size" => 8); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->health->getQueueRegionManager( - ); - - $this->assertSame($data, $response); - } - public function testMethodGetQueueStatsResources(): void { $data = array( @@ -374,21 +314,6 @@ public function testMethodGetQueueUsage(): void { $this->assertSame($data, $response); } - public function testMethodGetQueueThreats(): void { - - $data = array( - "size" => 8); - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->health->getQueueThreats( - ); - - $this->assertSame($data, $response); - } - public function testMethodGetQueueWebhooks(): void { $data = array( diff --git a/tests/Appwrite/Services/SitesTest.php b/tests/Appwrite/Services/SitesTest.php index 2d3a2bc..6408740 100644 --- a/tests/Appwrite/Services/SitesTest.php +++ b/tests/Appwrite/Services/SitesTest.php @@ -321,8 +321,7 @@ public function testMethodCreateDeployment(): void { $response = $this->sites->createDeployment( "", - InputFile::withData('', "image/png"), - true + InputFile::withData('', "image/png") ); $this->assertSame($data, $response); diff --git a/tests/Appwrite/Services/TablesDBTest.php b/tests/Appwrite/Services/TablesDBTest.php index fb91185..970871c 100644 --- a/tests/Appwrite/Services/TablesDBTest.php +++ b/tests/Appwrite/Services/TablesDBTest.php @@ -44,9 +44,7 @@ public function testMethodCreate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy", - "policies" => array(), - "archives" => array()); + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -182,9 +180,7 @@ public function testMethodGet(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy", - "policies" => array(), - "archives" => array()); + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -205,9 +201,7 @@ public function testMethodUpdate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy", - "policies" => array(), - "archives" => array()); + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) From a815b26b23ee42a40f1c1dfe4afa36f28d8b8eaf Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Mar 2026 10:13:11 +0000 Subject: [PATCH 2/3] regen --- CHANGELOG.md | 9 +- README.md | 2 +- docs/activities.md | 29 ++ docs/backups.md | 172 ++++++++ docs/examples/activities/get-event.md | 16 + docs/examples/activities/list-events.md | 16 + docs/examples/backups/create-archive.md | 18 + docs/examples/backups/create-policy.md | 23 ++ docs/examples/backups/create-restoration.md | 20 + docs/examples/backups/delete-archive.md | 16 + docs/examples/backups/delete-policy.md | 16 + docs/examples/backups/get-archive.md | 16 + docs/examples/backups/get-policy.md | 16 + docs/examples/backups/get-restoration.md | 16 + docs/examples/backups/list-archives.md | 16 + docs/examples/backups/list-policies.md | 16 + docs/examples/backups/list-restorations.md | 16 + docs/examples/backups/update-policy.md | 20 + docs/examples/health/get-console-pausing.md | 17 + docs/health.md | 80 ++++ docs/storage.md | 4 +- src/Appwrite/Client.php | 4 +- src/Appwrite/Enums/BackupServices.php | 51 +++ src/Appwrite/Enums/BuildRuntime.php | 24 -- src/Appwrite/Enums/Runtime.php | 24 -- src/Appwrite/Enums/Scopes.php | 72 ++++ src/Appwrite/Services/Activities.php | 76 ++++ src/Appwrite/Services/Backups.php | 411 ++++++++++++++++++++ src/Appwrite/Services/Health.php | 193 +++++++++ tests/Appwrite/Services/ActivitiesTest.php | 82 ++++ tests/Appwrite/Services/BackupsTest.php | 276 +++++++++++++ tests/Appwrite/Services/DatabasesTest.php | 12 +- tests/Appwrite/Services/HealthTest.php | 92 +++++ tests/Appwrite/Services/TablesDBTest.php | 12 +- 34 files changed, 1823 insertions(+), 60 deletions(-) create mode 100644 docs/activities.md create mode 100644 docs/backups.md create mode 100644 docs/examples/activities/get-event.md create mode 100644 docs/examples/activities/list-events.md create mode 100644 docs/examples/backups/create-archive.md create mode 100644 docs/examples/backups/create-policy.md create mode 100644 docs/examples/backups/create-restoration.md create mode 100644 docs/examples/backups/delete-archive.md create mode 100644 docs/examples/backups/delete-policy.md create mode 100644 docs/examples/backups/get-archive.md create mode 100644 docs/examples/backups/get-policy.md create mode 100644 docs/examples/backups/get-restoration.md create mode 100644 docs/examples/backups/list-archives.md create mode 100644 docs/examples/backups/list-policies.md create mode 100644 docs/examples/backups/list-restorations.md create mode 100644 docs/examples/backups/update-policy.md create mode 100644 docs/examples/health/get-console-pausing.md create mode 100644 src/Appwrite/Enums/BackupServices.php create mode 100644 src/Appwrite/Services/Activities.php create mode 100644 src/Appwrite/Services/Backups.php create mode 100644 tests/Appwrite/Services/ActivitiesTest.php create mode 100644 tests/Appwrite/Services/BackupsTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 6538fa5..b8d0be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 20.2.0 + +* Added optional encrypt parameter for database attributes (Text, Longtext, Mediumtext, Varchar) and corresponding column creation methods to enable encryption at rest. Encrypted attributes/columns cannot be queried. +* Updated API docs and code examples to include the new encrypt option (defaulting to false) across databases and TablesDB sections. +* Updated README compatibility note to reflect Appwrite server version 1.8.x. +* Add support for the new `Backups` service + ## 20.0.1 * Fix doc examples with proper formatting @@ -52,4 +59,4 @@ * Add `dart38` and `flutter332` support to runtime models * Add `gif` support to `ImageFormat` enum * Add `upsertDocument` support to `Databases` service -* Add `sequence` support to `Document` model \ No newline at end of file +* Add `sequence` support to `Document` model diff --git a/README.md b/README.md index 6f4db85..9713e5d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![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 is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** 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) diff --git a/docs/activities.md b/docs/activities.md new file mode 100644 index 0000000..06b40cb --- /dev/null +++ b/docs/activities.md @@ -0,0 +1,29 @@ +# Activities Service + + +```http request +GET https://cloud.appwrite.io/v1/activities/events +``` + +** List all events for selected filters. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| queries | string | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on attributes such as userId, teamId, etc. | [] | + + +```http request +GET https://cloud.appwrite.io/v1/activities/events/{eventId} +``` + +** Get event by ID. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| eventId | string | **Required** Event ID. | | + diff --git a/docs/backups.md b/docs/backups.md new file mode 100644 index 0000000..36a4ee9 --- /dev/null +++ b/docs/backups.md @@ -0,0 +1,172 @@ +# Backups Service + + +```http request +GET https://cloud.appwrite.io/v1/backups/archives +``` + +** List all archives for a project. ** + +### 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. | [] | + + +```http request +POST https://cloud.appwrite.io/v1/backups/archives +``` + +** Create a new archive asynchronously for a project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| services | array | Array of services to backup | | +| resourceId | string | Resource ID. When set, only this single resource will be backed up. | | + + +```http request +GET https://cloud.appwrite.io/v1/backups/archives/{archiveId} +``` + +** Get a backup archive using it's ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| archiveId | string | **Required** Archive ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + + +```http request +DELETE https://cloud.appwrite.io/v1/backups/archives/{archiveId} +``` + +** Delete an existing archive for a project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| archiveId | string | **Required** Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + + +```http request +GET https://cloud.appwrite.io/v1/backups/policies +``` + +** List all policies for a project. ** + +### 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. | [] | + + +```http request +POST https://cloud.appwrite.io/v1/backups/policies +``` + +** Create a new backup policy. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| policyId | string | Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Policy name. Max length: 128 chars. | | +| services | array | Array of services to backup | | +| resourceId | string | Resource ID. When set, only this single resource will be backed up. | | +| enabled | boolean | Is policy enabled? When set to 'disabled', no backups will be taken | 1 | +| retention | integer | Days to keep backups before deletion | | +| schedule | string | Schedule CRON syntax. | | + + +```http request +GET https://cloud.appwrite.io/v1/backups/policies/{policyId} +``` + +** Get a backup policy using it's ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| policyId | string | **Required** Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/backups/policies/{policyId} +``` + +** Update an existing policy using it's ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| policyId | string | **Required** Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Policy name. Max length: 128 chars. | | +| retention | integer | Days to keep backups before deletion | | +| schedule | string | Cron expression | | +| enabled | boolean | Is Backup enabled? When set to 'disabled', No backup will be taken | | + + +```http request +DELETE https://cloud.appwrite.io/v1/backups/policies/{policyId} +``` + +** Delete a policy using it's ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| policyId | string | **Required** Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + + +```http request +POST https://cloud.appwrite.io/v1/backups/restoration +``` + +** Create and trigger a new restoration for a backup on a project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| archiveId | string | Backup archive ID to restore | | +| services | array | Array of services to restore | | +| newResourceId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| newResourceName | string | Database name. Max length: 128 chars. | | + + +```http request +GET https://cloud.appwrite.io/v1/backups/restorations +``` + +** List all backup restorations for a project. ** + +### 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. | [] | + + +```http request +GET https://cloud.appwrite.io/v1/backups/restorations/{restorationId} +``` + +** Get the current status of a backup restoration. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| restorationId | string | **Required** Restoration ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + diff --git a/docs/examples/activities/get-event.md b/docs/examples/activities/get-event.md new file mode 100644 index 0000000..6b8f542 --- /dev/null +++ b/docs/examples/activities/get-event.md @@ -0,0 +1,16 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$activities = new Activities($client); + +$result = $activities->getEvent( + eventId: '' +);``` diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md new file mode 100644 index 0000000..ef9a9d7 --- /dev/null +++ b/docs/examples/activities/list-events.md @@ -0,0 +1,16 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$activities = new Activities($client); + +$result = $activities->listEvents( + queries: '' // optional +);``` diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md new file mode 100644 index 0000000..d73db2e --- /dev/null +++ b/docs/examples/backups/create-archive.md @@ -0,0 +1,18 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->createArchive( + services: [BackupServices::DATABASES()], + resourceId: '' // optional +);``` diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md new file mode 100644 index 0000000..ea87f28 --- /dev/null +++ b/docs/examples/backups/create-policy.md @@ -0,0 +1,23 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->createPolicy( + policyId: '', + services: [BackupServices::DATABASES()], + retention: 1, + schedule: '', + name: '', // optional + resourceId: '', // optional + enabled: false // optional +);``` diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md new file mode 100644 index 0000000..61d9e0b --- /dev/null +++ b/docs/examples/backups/create-restoration.md @@ -0,0 +1,20 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->createRestoration( + archiveId: '', + services: [BackupServices::DATABASES()], + newResourceId: '', // optional + newResourceName: '' // optional +);``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md new file mode 100644 index 0000000..a6c3d33 --- /dev/null +++ b/docs/examples/backups/delete-archive.md @@ -0,0 +1,16 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->deleteArchive( + archiveId: '' +);``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md new file mode 100644 index 0000000..3c6df8f --- /dev/null +++ b/docs/examples/backups/delete-policy.md @@ -0,0 +1,16 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->deletePolicy( + policyId: '' +);``` diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md new file mode 100644 index 0000000..6fa9ea9 --- /dev/null +++ b/docs/examples/backups/get-archive.md @@ -0,0 +1,16 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->getArchive( + archiveId: '' +);``` diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md new file mode 100644 index 0000000..e8ce5c8 --- /dev/null +++ b/docs/examples/backups/get-policy.md @@ -0,0 +1,16 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->getPolicy( + policyId: '' +);``` diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md new file mode 100644 index 0000000..ed3e94a --- /dev/null +++ b/docs/examples/backups/get-restoration.md @@ -0,0 +1,16 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->getRestoration( + restorationId: '' +);``` diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md new file mode 100644 index 0000000..4060e3c --- /dev/null +++ b/docs/examples/backups/list-archives.md @@ -0,0 +1,16 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->listArchives( + queries: [] // optional +);``` diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md new file mode 100644 index 0000000..a8b0331 --- /dev/null +++ b/docs/examples/backups/list-policies.md @@ -0,0 +1,16 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->listPolicies( + queries: [] // optional +);``` diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md new file mode 100644 index 0000000..2c7132b --- /dev/null +++ b/docs/examples/backups/list-restorations.md @@ -0,0 +1,16 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->listRestorations( + queries: [] // optional +);``` diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md new file mode 100644 index 0000000..fe53fa2 --- /dev/null +++ b/docs/examples/backups/update-policy.md @@ -0,0 +1,20 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->updatePolicy( + policyId: '', + name: '', // optional + retention: 1, // optional + schedule: '', // optional + enabled: false // optional +);``` diff --git a/docs/examples/health/get-console-pausing.md b/docs/examples/health/get-console-pausing.md new file mode 100644 index 0000000..06a434d --- /dev/null +++ b/docs/examples/health/get-console-pausing.md @@ -0,0 +1,17 @@ +```php +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$health = new Health($client); + +$result = $health->getConsolePausing( + threshold: null, // optional + inactivityDays: null // optional +);``` diff --git a/docs/health.md b/docs/health.md index a381890..fedaa15 100644 --- a/docs/health.md +++ b/docs/health.md @@ -35,6 +35,21 @@ GET https://cloud.appwrite.io/v1/health/certificate | domain | string | string | | +```http request +GET https://cloud.appwrite.io/v1/health/console-pausing +``` + +** Get console pausing health status. Monitors projects approaching the pause threshold to detect potential issues with console access tracking. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| threshold | integer | Percentage threshold of projects approaching pause. When hit (equal or higher), endpoint returns server error. Default value is 10. | 10 | +| inactivityDays | integer | Number of days of inactivity before a project is paused. Should match the plan's projectInactivityDays setting. Default value is 7. | 7 | + + ```http request GET https://cloud.appwrite.io/v1/health/db ``` @@ -62,6 +77,32 @@ GET https://cloud.appwrite.io/v1/health/queue/audits | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | +```http request +GET https://cloud.appwrite.io/v1/health/queue/billing-project-aggregation +``` + +** Get billing project aggregation queue. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 10000 | + + +```http request +GET https://cloud.appwrite.io/v1/health/queue/billing-team-aggregation +``` + +** Get billing team aggregation queue. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 10000 | + + ```http request GET https://cloud.appwrite.io/v1/health/queue/builds ``` @@ -75,6 +116,19 @@ GET https://cloud.appwrite.io/v1/health/queue/builds | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | +```http request +GET https://cloud.appwrite.io/v1/health/queue/builds-priority +``` + +** Get the priority builds queue size. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 500. | 500 | + + ```http request GET https://cloud.appwrite.io/v1/health/queue/certificates ``` @@ -195,6 +249,19 @@ GET https://cloud.appwrite.io/v1/health/queue/migrations | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | +```http request +GET https://cloud.appwrite.io/v1/health/queue/region-manager +``` + +** Get region manager queue. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. | 100 | + + ```http request GET https://cloud.appwrite.io/v1/health/queue/stats-resources ``` @@ -221,6 +288,19 @@ GET https://cloud.appwrite.io/v1/health/queue/stats-usage | threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | +```http request +GET https://cloud.appwrite.io/v1/health/queue/threats +``` + +** Get threats queue. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100. | 100 | + + ```http request GET https://cloud.appwrite.io/v1/health/queue/webhooks ``` diff --git a/docs/storage.md b/docs/storage.md index 74960e3..c051c9b 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -31,7 +31,7 @@ POST https://cloud.appwrite.io/v1/storage/buckets | permissions | array | An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | fileSecurity | boolean | Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. | 1 | -| maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 30MB. | [] | +| maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 5GB. | [] | | allowedFileExtensions | array | Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. | [] | | compression | string | Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled | none | | encryption | boolean | Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled | 1 | @@ -67,7 +67,7 @@ PUT https://cloud.appwrite.io/v1/storage/buckets/{bucketId} | permissions | array | An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | fileSecurity | boolean | Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | enabled | boolean | Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. | 1 | -| maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 30MB. | [] | +| maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 5GB. | [] | | allowedFileExtensions | array | Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. | [] | | compression | string | Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled | none | | encryption | boolean | Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled | 1 | diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 5a21121..d5c08f0 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,11 +37,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/20.0.1 ()', + 'user-agent' => 'AppwritePHPSDK/21.0.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '20.0.1', + 'x-sdk-version'=> '21.0.0', ]; /** diff --git a/src/Appwrite/Enums/BackupServices.php b/src/Appwrite/Enums/BackupServices.php new file mode 100644 index 0000000..8eb096d --- /dev/null +++ b/src/Appwrite/Enums/BackupServices.php @@ -0,0 +1,51 @@ +value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function DATABASES(): BackupServices + { + if (!isset(self::$DATABASES)) { + self::$DATABASES = new BackupServices('databases'); + } + return self::$DATABASES; + } + public static function FUNCTIONS(): BackupServices + { + if (!isset(self::$FUNCTIONS)) { + self::$FUNCTIONS = new BackupServices('functions'); + } + return self::$FUNCTIONS; + } + public static function STORAGE(): BackupServices + { + if (!isset(self::$STORAGE)) { + self::$STORAGE = new BackupServices('storage'); + } + return self::$STORAGE; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/BuildRuntime.php b/src/Appwrite/Enums/BuildRuntime.php index 636db5a..f0d01a0 100644 --- a/src/Appwrite/Enums/BuildRuntime.php +++ b/src/Appwrite/Enums/BuildRuntime.php @@ -37,9 +37,6 @@ class BuildRuntime implements JsonSerializable private static BuildRuntime $PYTHONML311; private static BuildRuntime $PYTHONML312; private static BuildRuntime $PYTHONML313; - private static BuildRuntime $DENO121; - private static BuildRuntime $DENO124; - private static BuildRuntime $DENO135; private static BuildRuntime $DENO140; private static BuildRuntime $DENO146; private static BuildRuntime $DENO20; @@ -330,27 +327,6 @@ public static function PYTHONML313(): BuildRuntime } return self::$PYTHONML313; } - public static function DENO121(): BuildRuntime - { - if (!isset(self::$DENO121)) { - self::$DENO121 = new BuildRuntime('deno-1.21'); - } - return self::$DENO121; - } - public static function DENO124(): BuildRuntime - { - if (!isset(self::$DENO124)) { - self::$DENO124 = new BuildRuntime('deno-1.24'); - } - return self::$DENO124; - } - public static function DENO135(): BuildRuntime - { - if (!isset(self::$DENO135)) { - self::$DENO135 = new BuildRuntime('deno-1.35'); - } - return self::$DENO135; - } public static function DENO140(): BuildRuntime { if (!isset(self::$DENO140)) { diff --git a/src/Appwrite/Enums/Runtime.php b/src/Appwrite/Enums/Runtime.php index a0a8355..2388a96 100644 --- a/src/Appwrite/Enums/Runtime.php +++ b/src/Appwrite/Enums/Runtime.php @@ -37,9 +37,6 @@ class Runtime implements JsonSerializable private static Runtime $PYTHONML311; private static Runtime $PYTHONML312; private static Runtime $PYTHONML313; - private static Runtime $DENO121; - private static Runtime $DENO124; - private static Runtime $DENO135; private static Runtime $DENO140; private static Runtime $DENO146; private static Runtime $DENO20; @@ -330,27 +327,6 @@ public static function PYTHONML313(): Runtime } return self::$PYTHONML313; } - public static function DENO121(): Runtime - { - if (!isset(self::$DENO121)) { - self::$DENO121 = new Runtime('deno-1.21'); - } - return self::$DENO121; - } - public static function DENO124(): Runtime - { - if (!isset(self::$DENO124)) { - self::$DENO124 = new Runtime('deno-1.24'); - } - return self::$DENO124; - } - public static function DENO135(): Runtime - { - if (!isset(self::$DENO135)) { - self::$DENO135 = new Runtime('deno-1.35'); - } - return self::$DENO135; - } public static function DENO140(): Runtime { if (!isset(self::$DENO140)) { diff --git a/src/Appwrite/Enums/Scopes.php b/src/Appwrite/Enums/Scopes.php index 0516c7b..e9478f1 100644 --- a/src/Appwrite/Enums/Scopes.php +++ b/src/Appwrite/Enums/Scopes.php @@ -63,6 +63,15 @@ class Scopes implements JsonSerializable private static Scopes $ASSISTANTREAD; private static Scopes $TOKENSREAD; private static Scopes $TOKENSWRITE; + private static Scopes $POLICIESWRITE; + private static Scopes $POLICIESREAD; + private static Scopes $ARCHIVESREAD; + private static Scopes $ARCHIVESWRITE; + private static Scopes $RESTORATIONSREAD; + private static Scopes $RESTORATIONSWRITE; + private static Scopes $DOMAINSREAD; + private static Scopes $DOMAINSWRITE; + private static Scopes $EVENTSREAD; private string $value; @@ -480,4 +489,67 @@ public static function TOKENSWRITE(): Scopes } return self::$TOKENSWRITE; } + public static function POLICIESWRITE(): Scopes + { + if (!isset(self::$POLICIESWRITE)) { + self::$POLICIESWRITE = new Scopes('policies.write'); + } + return self::$POLICIESWRITE; + } + public static function POLICIESREAD(): Scopes + { + if (!isset(self::$POLICIESREAD)) { + self::$POLICIESREAD = new Scopes('policies.read'); + } + return self::$POLICIESREAD; + } + public static function ARCHIVESREAD(): Scopes + { + if (!isset(self::$ARCHIVESREAD)) { + self::$ARCHIVESREAD = new Scopes('archives.read'); + } + return self::$ARCHIVESREAD; + } + public static function ARCHIVESWRITE(): Scopes + { + if (!isset(self::$ARCHIVESWRITE)) { + self::$ARCHIVESWRITE = new Scopes('archives.write'); + } + return self::$ARCHIVESWRITE; + } + public static function RESTORATIONSREAD(): Scopes + { + if (!isset(self::$RESTORATIONSREAD)) { + self::$RESTORATIONSREAD = new Scopes('restorations.read'); + } + return self::$RESTORATIONSREAD; + } + public static function RESTORATIONSWRITE(): Scopes + { + if (!isset(self::$RESTORATIONSWRITE)) { + self::$RESTORATIONSWRITE = new Scopes('restorations.write'); + } + return self::$RESTORATIONSWRITE; + } + public static function DOMAINSREAD(): Scopes + { + if (!isset(self::$DOMAINSREAD)) { + self::$DOMAINSREAD = new Scopes('domains.read'); + } + return self::$DOMAINSREAD; + } + public static function DOMAINSWRITE(): Scopes + { + if (!isset(self::$DOMAINSWRITE)) { + self::$DOMAINSWRITE = new Scopes('domains.write'); + } + return self::$DOMAINSWRITE; + } + public static function EVENTSREAD(): Scopes + { + if (!isset(self::$EVENTSREAD)) { + self::$EVENTSREAD = new Scopes('events.read'); + } + return self::$EVENTSREAD; + } } \ No newline at end of file diff --git a/src/Appwrite/Services/Activities.php b/src/Appwrite/Services/Activities.php new file mode 100644 index 0000000..b8c0e83 --- /dev/null +++ b/src/Appwrite/Services/Activities.php @@ -0,0 +1,76 @@ +client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get event by ID. + * + * + * @param string $eventId + * @throws AppwriteException + * @return array + */ + public function getEvent(string $eventId): array + { + $apiPath = str_replace( + ['{eventId}'], + [$eventId], + '/activities/events/{eventId}' + ); + + $apiParams = []; + $apiParams['eventId'] = $eventId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } +} \ No newline at end of file diff --git a/src/Appwrite/Services/Backups.php b/src/Appwrite/Services/Backups.php new file mode 100644 index 0000000..bca41ac --- /dev/null +++ b/src/Appwrite/Services/Backups.php @@ -0,0 +1,411 @@ +client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new archive asynchronously for a project. + * + * @param array $services + * @param ?string $resourceId + * @throws AppwriteException + * @return array + */ + public function createArchive(array $services, ?string $resourceId = null): array + { + $apiPath = str_replace( + [], + [], + '/backups/archives' + ); + + $apiParams = []; + $apiParams['services'] = $services; + $apiParams['resourceId'] = $resourceId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a backup archive using it's ID. + * + * @param string $archiveId + * @throws AppwriteException + * @return array + */ + public function getArchive(string $archiveId): array + { + $apiPath = str_replace( + ['{archiveId}'], + [$archiveId], + '/backups/archives/{archiveId}' + ); + + $apiParams = []; + $apiParams['archiveId'] = $archiveId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete an existing archive for a project. + * + * @param string $archiveId + * @throws AppwriteException + * @return string + */ + public function deleteArchive(string $archiveId): string + { + $apiPath = str_replace( + ['{archiveId}'], + [$archiveId], + '/backups/archives/{archiveId}' + ); + + $apiParams = []; + $apiParams['archiveId'] = $archiveId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * List all policies for a project. + * + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listPolicies(?array $queries = null): array + { + $apiPath = str_replace( + [], + [], + '/backups/policies' + ); + + $apiParams = []; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new backup policy. + * + * @param string $policyId + * @param array $services + * @param int $retention + * @param string $schedule + * @param ?string $name + * @param ?string $resourceId + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function createPolicy(string $policyId, array $services, int $retention, string $schedule, ?string $name = null, ?string $resourceId = null, ?bool $enabled = null): array + { + $apiPath = str_replace( + [], + [], + '/backups/policies' + ); + + $apiParams = []; + $apiParams['policyId'] = $policyId; + $apiParams['services'] = $services; + $apiParams['retention'] = $retention; + $apiParams['schedule'] = $schedule; + + if (!is_null($name)) { + $apiParams['name'] = $name; + } + $apiParams['resourceId'] = $resourceId; + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a backup policy using it's ID. + * + * @param string $policyId + * @throws AppwriteException + * @return array + */ + public function getPolicy(string $policyId): array + { + $apiPath = str_replace( + ['{policyId}'], + [$policyId], + '/backups/policies/{policyId}' + ); + + $apiParams = []; + $apiParams['policyId'] = $policyId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an existing policy using it's ID. + * + * @param string $policyId + * @param ?string $name + * @param ?int $retention + * @param ?string $schedule + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function updatePolicy(string $policyId, ?string $name = null, ?int $retention = null, ?string $schedule = null, ?bool $enabled = null): array + { + $apiPath = str_replace( + ['{policyId}'], + [$policyId], + '/backups/policies/{policyId}' + ); + + $apiParams = []; + $apiParams['policyId'] = $policyId; + $apiParams['name'] = $name; + $apiParams['retention'] = $retention; + + if (!is_null($schedule)) { + $apiParams['schedule'] = $schedule; + } + $apiParams['enabled'] = $enabled; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a policy using it's ID. + * + * @param string $policyId + * @throws AppwriteException + * @return string + */ + public function deletePolicy(string $policyId): string + { + $apiPath = str_replace( + ['{policyId}'], + [$policyId], + '/backups/policies/{policyId}' + ); + + $apiParams = []; + $apiParams['policyId'] = $policyId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create and trigger a new restoration for a backup on a project. + * + * @param string $archiveId + * @param array $services + * @param ?string $newResourceId + * @param ?string $newResourceName + * @throws AppwriteException + * @return array + */ + public function createRestoration(string $archiveId, array $services, ?string $newResourceId = null, ?string $newResourceName = null): array + { + $apiPath = str_replace( + [], + [], + '/backups/restoration' + ); + + $apiParams = []; + $apiParams['archiveId'] = $archiveId; + $apiParams['services'] = $services; + + if (!is_null($newResourceId)) { + $apiParams['newResourceId'] = $newResourceId; + } + + if (!is_null($newResourceName)) { + $apiParams['newResourceName'] = $newResourceName; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * List all backup restorations for a project. + * + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listRestorations(?array $queries = null): array + { + $apiPath = str_replace( + [], + [], + '/backups/restorations' + ); + + $apiParams = []; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get the current status of a backup restoration. + * + * @param string $restorationId + * @throws AppwriteException + * @return array + */ + public function getRestoration(string $restorationId): array + { + $apiPath = str_replace( + ['{restorationId}'], + [$restorationId], + '/backups/restorations/{restorationId}' + ); + + $apiParams = []; + $apiParams['restorationId'] = $restorationId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } +} \ No newline at end of file diff --git a/src/Appwrite/Services/Health.php b/src/Appwrite/Services/Health.php index c4a694b..06407e9 100644 --- a/src/Appwrite/Services/Health.php +++ b/src/Appwrite/Services/Health.php @@ -125,6 +125,44 @@ public function getCertificate(?string $domain = null): array ); } + /** + * Get console pausing health status. Monitors projects approaching the pause + * threshold to detect potential issues with console access tracking. + * + * + * @param ?int $threshold + * @param ?int $inactivityDays + * @throws AppwriteException + * @return array + */ + public function getConsolePausing(?int $threshold = null, ?int $inactivityDays = null): array + { + $apiPath = str_replace( + [], + [], + '/health/console-pausing' + ); + + $apiParams = []; + + if (!is_null($threshold)) { + $apiParams['threshold'] = $threshold; + } + + if (!is_null($inactivityDays)) { + $apiParams['inactivityDays'] = $inactivityDays; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Check the Appwrite database servers are up and connection is successful. * @@ -209,6 +247,68 @@ public function getQueueAudits(?int $threshold = null): array ); } + /** + * Get billing project aggregation queue. + * + * @param ?int $threshold + * @throws AppwriteException + * @return array + */ + public function getQueueBillingProjectAggregation(?int $threshold = null): array + { + $apiPath = str_replace( + [], + [], + '/health/queue/billing-project-aggregation' + ); + + $apiParams = []; + + if (!is_null($threshold)) { + $apiParams['threshold'] = $threshold; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get billing team aggregation queue. + * + * @param ?int $threshold + * @throws AppwriteException + * @return array + */ + public function getQueueBillingTeamAggregation(?int $threshold = null): array + { + $apiPath = str_replace( + [], + [], + '/health/queue/billing-team-aggregation' + ); + + $apiParams = []; + + if (!is_null($threshold)) { + $apiParams['threshold'] = $threshold; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get the number of builds that are waiting to be processed in the Appwrite * internal queue server. @@ -241,6 +341,37 @@ public function getQueueBuilds(?int $threshold = null): array ); } + /** + * Get the priority builds queue size. + * + * @param ?int $threshold + * @throws AppwriteException + * @return array + */ + public function getQueuePriorityBuilds(?int $threshold = null): array + { + $apiPath = str_replace( + [], + [], + '/health/queue/builds-priority' + ); + + $apiParams = []; + + if (!is_null($threshold)) { + $apiParams['threshold'] = $threshold; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get the number of certificates that are waiting to be issued against * [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue @@ -537,6 +668,37 @@ public function getQueueMigrations(?int $threshold = null): array ); } + /** + * Get region manager queue. + * + * @param ?int $threshold + * @throws AppwriteException + * @return array + */ + public function getQueueRegionManager(?int $threshold = null): array + { + $apiPath = str_replace( + [], + [], + '/health/queue/region-manager' + ); + + $apiParams = []; + + if (!is_null($threshold)) { + $apiParams['threshold'] = $threshold; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get the number of metrics that are waiting to be processed in the Appwrite * stats resources queue. @@ -601,6 +763,37 @@ public function getQueueUsage(?int $threshold = null): array ); } + /** + * Get threats queue. + * + * @param ?int $threshold + * @throws AppwriteException + * @return array + */ + public function getQueueThreats(?int $threshold = null): array + { + $apiPath = str_replace( + [], + [], + '/health/queue/threats' + ); + + $apiParams = []; + + if (!is_null($threshold)) { + $apiParams['threshold'] = $threshold; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get the number of webhooks that are waiting to be processed in the Appwrite * internal queue server. diff --git a/tests/Appwrite/Services/ActivitiesTest.php b/tests/Appwrite/Services/ActivitiesTest.php new file mode 100644 index 0000000..caaf39e --- /dev/null +++ b/tests/Appwrite/Services/ActivitiesTest.php @@ -0,0 +1,82 @@ +client = Mockery::mock(Client::class); + $this->activities = new Activities($this->client); + } + + public function testMethodListEvents(): void { + + $data = array( + "total" => 5, + "events" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->activities->listEvents( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetEvent(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "userType" => "user", + "userId" => "610fc2f985ee0", + "userEmail" => "john@appwrite.io", + "userName" => "John Doe", + "resourceParent" => "database/ID", + "resourceType" => "collection", + "resourceId" => "610fc2f985ee0", + "resource" => "collections/610fc2f985ee0", + "event" => "account.sessions.create", + "userAgent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36", + "ip" => "127.0.0.1", + "mode" => "admin", + "country" => "US", + "time" => "2020-10-15T06:38:00.000+00:00", + "projectId" => "610fc2f985ee0", + "teamId" => "610fc2f985ee0", + "hostname" => "appwrite.io", + "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); + + $response = $this->activities->getEvent( + "" + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/BackupsTest.php b/tests/Appwrite/Services/BackupsTest.php new file mode 100644 index 0000000..c485ef7 --- /dev/null +++ b/tests/Appwrite/Services/BackupsTest.php @@ -0,0 +1,276 @@ +client = Mockery::mock(Client::class); + $this->backups = new Backups($this->client); + } + + public function testMethodListArchives(): void { + + $data = array( + "total" => 5, + "archives" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->listArchives( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateArchive(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$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" => array(), + "resources" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->createArchive( + array(BackupServices::DATABASES()) + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetArchive(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$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" => array(), + "resources" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->getArchive( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteArchive(): void { + + $data = ''; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->deleteArchive( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListPolicies(): void { + + $data = array( + "total" => 5, + "policies" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->listPolicies( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePolicy(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "Hourly backups", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "services" => array(), + "resources" => array(), + "retention" => 7, + "schedule" => "0 * * * *", + "enabled" => true); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->createPolicy( + "", + array(BackupServices::DATABASES()), + 1, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetPolicy(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "Hourly backups", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "services" => array(), + "resources" => array(), + "retention" => 7, + "schedule" => "0 * * * *", + "enabled" => true); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->getPolicy( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePolicy(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "Hourly backups", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "services" => array(), + "resources" => array(), + "retention" => 7, + "schedule" => "0 * * * *", + "enabled" => true); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->updatePolicy( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeletePolicy(): void { + + $data = ''; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->deletePolicy( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRestoration(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "archiveId" => "did8jx6ws45jana098ab7", + "policyId" => "did8jx6ws45jana098ab7", + "status" => "completed", + "startedAt" => "2020-10-15T06:38:00.000+00:00", + "migrationId" => "did8jx6ws45jana098ab7", + "services" => array(), + "resources" => array(), + "options" => "{databases.database[{oldId, newId, newName}]}"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->createRestoration( + "", + array(BackupServices::DATABASES()) + ); + + $this->assertSame($data, $response); + } + + public function testMethodListRestorations(): void { + + $data = array( + "total" => 5, + "restorations" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->listRestorations( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetRestoration(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "archiveId" => "did8jx6ws45jana098ab7", + "policyId" => "did8jx6ws45jana098ab7", + "status" => "completed", + "startedAt" => "2020-10-15T06:38:00.000+00:00", + "migrationId" => "did8jx6ws45jana098ab7", + "services" => array(), + "resources" => array(), + "options" => "{databases.database[{oldId, newId, newName}]}"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->getRestoration( + "" + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index a6e87b6..fb065df 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -44,7 +44,9 @@ public function testMethodCreate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy"); + "type" => "legacy", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -180,7 +182,9 @@ public function testMethodGet(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy"); + "type" => "legacy", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -201,7 +205,9 @@ public function testMethodUpdate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy"); + "type" => "legacy", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) diff --git a/tests/Appwrite/Services/HealthTest.php b/tests/Appwrite/Services/HealthTest.php index 28c637c..2fddf3a 100644 --- a/tests/Appwrite/Services/HealthTest.php +++ b/tests/Appwrite/Services/HealthTest.php @@ -86,6 +86,23 @@ public function testMethodGetCertificate(): void { $this->assertSame($data, $response); } + public function testMethodGetConsolePausing(): void { + + $data = array( + "name" => "database", + "ping" => 128, + "status" => "pass"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getConsolePausing( + ); + + $this->assertSame($data, $response); + } + public function testMethodGetDB(): void { $data = array( @@ -133,6 +150,36 @@ public function testMethodGetQueueAudits(): void { $this->assertSame($data, $response); } + public function testMethodGetQueueBillingProjectAggregation(): void { + + $data = array( + "size" => 8); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueBillingProjectAggregation( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetQueueBillingTeamAggregation(): void { + + $data = array( + "size" => 8); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueBillingTeamAggregation( + ); + + $this->assertSame($data, $response); + } + public function testMethodGetQueueBuilds(): void { $data = array( @@ -148,6 +195,21 @@ public function testMethodGetQueueBuilds(): void { $this->assertSame($data, $response); } + public function testMethodGetQueuePriorityBuilds(): void { + + $data = array( + "size" => 8); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueuePriorityBuilds( + ); + + $this->assertSame($data, $response); + } + public function testMethodGetQueueCertificates(): void { $data = array( @@ -284,6 +346,21 @@ public function testMethodGetQueueMigrations(): void { $this->assertSame($data, $response); } + public function testMethodGetQueueRegionManager(): void { + + $data = array( + "size" => 8); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueRegionManager( + ); + + $this->assertSame($data, $response); + } + public function testMethodGetQueueStatsResources(): void { $data = array( @@ -314,6 +391,21 @@ public function testMethodGetQueueUsage(): void { $this->assertSame($data, $response); } + public function testMethodGetQueueThreats(): void { + + $data = array( + "size" => 8); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueThreats( + ); + + $this->assertSame($data, $response); + } + public function testMethodGetQueueWebhooks(): void { $data = array( diff --git a/tests/Appwrite/Services/TablesDBTest.php b/tests/Appwrite/Services/TablesDBTest.php index 970871c..fb91185 100644 --- a/tests/Appwrite/Services/TablesDBTest.php +++ b/tests/Appwrite/Services/TablesDBTest.php @@ -44,7 +44,9 @@ public function testMethodCreate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy"); + "type" => "legacy", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -180,7 +182,9 @@ public function testMethodGet(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy"); + "type" => "legacy", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -201,7 +205,9 @@ public function testMethodUpdate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy"); + "type" => "legacy", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) From a771bbf992505bdd16660fa1de5d24746a141698 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Mar 2026 10:32:25 +0000 Subject: [PATCH 3/3] regen --- CHANGELOG.md | 6 ++++++ src/Appwrite/Client.php | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b8d0be4..244095f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 21.0.0 + +* Breaking: Updated createDeployment signature and relationship attribute endpoint path +* Added TTL parameter support to listDocuments and listRows +* Added getConsolePausing health endpoint to Health service + ## 20.2.0 * Added optional encrypt parameter for database attributes (Text, Longtext, Mediumtext, Varchar) and corresponding column creation methods to enable encryption at rest. Encrypted attributes/columns cannot be queried. diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index d5c08f0..0a744c8 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,11 +37,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/21.0.0 ()', + 'user-agent' => 'AppwritePHPSDK/20.2.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '21.0.0', + 'x-sdk-version'=> '20.2.0', ]; /**