Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
39 changes: 20 additions & 19 deletions docs/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | |
Expand Down Expand Up @@ -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
```
Expand Down Expand Up @@ -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
```
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/databases/list-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ $result = $databases->listDocuments(
collectionId: '<COLLECTION_ID>',
queries: [], // optional
transactionId: '<TRANSACTION_ID>', // optional
total: false // optional
total: false, // optional
ttl: 0 // optional
);```
17 changes: 17 additions & 0 deletions docs/examples/health/get-console-pausing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```php
<?php

use Appwrite\Client;
use Appwrite\Services\Health;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setKey('<YOUR_API_KEY>'); // Your secret API key

$health = new Health($client);

$result = $health->getConsolePausing(
threshold: null, // optional
inactivityDays: null // optional
);```
4 changes: 2 additions & 2 deletions docs/examples/sites/create-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ $sites = new Sites($client);
$result = $sites->createDeployment(
siteId: '<SITE_ID>',
code: InputFile::withPath('file.png'),
activate: false,
installCommand: '<INSTALL_COMMAND>', // optional
buildCommand: '<BUILD_COMMAND>', // optional
outputDirectory: '<OUTPUT_DIRECTORY>' // optional
outputDirectory: '<OUTPUT_DIRECTORY>', // optional
activate: false // optional
);```
3 changes: 2 additions & 1 deletion docs/examples/tablesdb/list-rows.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ $result = $tablesDB->listRows(
tableId: '<TABLE_ID>',
queries: [], // optional
transactionId: '<TRANSACTION_ID>', // optional
total: false // optional
total: false, // optional
ttl: 0 // optional
);```
15 changes: 15 additions & 0 deletions docs/health.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
2 changes: 1 addition & 1 deletion docs/messaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
1 change: 1 addition & 0 deletions docs/tablesdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/teams.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. | |

Expand Down Expand Up @@ -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
Expand Down
94 changes: 51 additions & 43 deletions src/Appwrite/Services/Databases.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
Expand All @@ -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}'],
Expand All @@ -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(
Expand Down
38 changes: 38 additions & 0 deletions src/Appwrite/Services/Health.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
9 changes: 6 additions & 3 deletions src/Appwrite/Services/Sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}'],
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Loading