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/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/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/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/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..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 ``` 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/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/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..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. * 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/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index 551944c..fb065df 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -1023,6 +1023,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 +1306,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..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( 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);