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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 23.1.1

* Fixed: `Database` model `policies` and `archives` now hydrate as `BackupPolicy` / `BackupArchive` instead of `Index` / `Collection`
* Added: `prompt` parameter to `Project::updateOAuth2Google` and `prompt` field on the `OAuth2Google` model, backed by the new `OAuth2GooglePrompt` enum
* Added: `Project::updateDenyCanonicalEmailPolicy`, `Project::updateDenyDisposableEmailPolicy`, and `Project::updateDenyFreeEmailPolicy`
* Updated: `BuildRuntime` and `Runtime` enums with `deno-1.21`, `deno-1.24`, and `deno-1.35`

## 23.1.0

* Added: Introduced `bigint` create/update APIs for legacy Databases attributes
Expand Down
16 changes: 16 additions & 0 deletions docs/examples/project/update-deny-canonical-email-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```php
<?php

use Appwrite\Client;
use Appwrite\Services\Project;

$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

$project = new Project($client);

$result = $project->updateDenyCanonicalEmailPolicy(
enabled: false
);```
16 changes: 16 additions & 0 deletions docs/examples/project/update-deny-disposable-email-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```php
<?php

use Appwrite\Client;
use Appwrite\Services\Project;

$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

$project = new Project($client);

$result = $project->updateDenyDisposableEmailPolicy(
enabled: false
);```
16 changes: 16 additions & 0 deletions docs/examples/project/update-deny-free-email-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```php
<?php

use Appwrite\Client;
use Appwrite\Services\Project;

$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

$project = new Project($client);

$result = $project->updateDenyFreeEmailPolicy(
enabled: false
);```
2 changes: 2 additions & 0 deletions docs/examples/project/update-o-auth-2-google.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Appwrite\Client;
use Appwrite\Services\Project;
use Appwrite\Enums\Prompt;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
Expand All @@ -14,5 +15,6 @@ $project = new Project($client);
$result = $project->updateOAuth2Google(
clientId: '<CLIENT_ID>', // optional
clientSecret: '<CLIENT_SECRET>', // optional
prompt: [Prompt::NONE()], // optional
enabled: false // optional
);```
122 changes: 81 additions & 41 deletions docs/project.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Appwrite/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class Client
*/
protected array $headers = [
'content-type' => '',
'user-agent' => 'AppwritePHPSDK/23.1.0 ()',
'user-agent' => 'AppwritePHPSDK/23.1.1 ()',
'x-sdk-name'=> 'PHP',
'x-sdk-platform'=> 'server',
'x-sdk-language'=> 'php',
'x-sdk-version'=> '23.1.0',
'x-sdk-version'=> '23.1.1',
];

/**
Expand Down
27 changes: 27 additions & 0 deletions src/Appwrite/Enums/BuildRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -330,6 +333,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)) {
Expand Down Expand Up @@ -771,6 +795,9 @@ public static function from(string $value): self
'python-ml-3.11' => self::PYTHONML311(),
'python-ml-3.12' => self::PYTHONML312(),
'python-ml-3.13' => self::PYTHONML313(),
'deno-1.21' => self::DENO121(),
'deno-1.24' => self::DENO124(),
'deno-1.35' => self::DENO135(),
'deno-1.40' => self::DENO140(),
'deno-1.46' => self::DENO146(),
'deno-2.0' => self::DENO20(),
Expand Down
61 changes: 61 additions & 0 deletions src/Appwrite/Enums/OAuth2GooglePrompt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace Appwrite\Enums;

use JsonSerializable;

class OAuth2GooglePrompt implements JsonSerializable
{
private static OAuth2GooglePrompt $NONE;
private static OAuth2GooglePrompt $CONSENT;
private static OAuth2GooglePrompt $SELECTACCOUNT;

private string $value;

private function __construct(string $value)
{
$this->value = $value;
}

public function __toString(): string
{
return $this->value;
}

public function jsonSerialize(): string
{
return $this->value;
}

public static function NONE(): OAuth2GooglePrompt
{
if (!isset(self::$NONE)) {
self::$NONE = new OAuth2GooglePrompt('none');
}
return self::$NONE;
}
public static function CONSENT(): OAuth2GooglePrompt
{
if (!isset(self::$CONSENT)) {
self::$CONSENT = new OAuth2GooglePrompt('consent');
}
return self::$CONSENT;
}
public static function SELECTACCOUNT(): OAuth2GooglePrompt
{
if (!isset(self::$SELECTACCOUNT)) {
self::$SELECTACCOUNT = new OAuth2GooglePrompt('select_account');
}
return self::$SELECTACCOUNT;
}

public static function from(string $value): self
{
return match ($value) {
'none' => self::NONE(),
'consent' => self::CONSENT(),
'select_account' => self::SELECTACCOUNT(),
default => throw new \InvalidArgumentException('Unknown OAuth2GooglePrompt value: ' . $value),
};
}
}
61 changes: 61 additions & 0 deletions src/Appwrite/Enums/Prompt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace Appwrite\Enums;

use JsonSerializable;

class Prompt implements JsonSerializable
{
private static Prompt $NONE;
private static Prompt $CONSENT;
private static Prompt $SELECTACCOUNT;

private string $value;

private function __construct(string $value)
{
$this->value = $value;
}

public function __toString(): string
{
return $this->value;
}

public function jsonSerialize(): string
{
return $this->value;
}

public static function NONE(): Prompt
{
if (!isset(self::$NONE)) {
self::$NONE = new Prompt('none');
}
return self::$NONE;
}
public static function CONSENT(): Prompt
{
if (!isset(self::$CONSENT)) {
self::$CONSENT = new Prompt('consent');
}
return self::$CONSENT;
}
public static function SELECTACCOUNT(): Prompt
{
if (!isset(self::$SELECTACCOUNT)) {
self::$SELECTACCOUNT = new Prompt('select_account');
}
return self::$SELECTACCOUNT;
}

public static function from(string $value): self
{
return match ($value) {
'none' => self::NONE(),
'consent' => self::CONSENT(),
'select_account' => self::SELECTACCOUNT(),
default => throw new \InvalidArgumentException('Unknown Prompt value: ' . $value),
};
}
}
27 changes: 27 additions & 0 deletions src/Appwrite/Enums/Runtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -330,6 +333,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)) {
Expand Down Expand Up @@ -771,6 +795,9 @@ public static function from(string $value): self
'python-ml-3.11' => self::PYTHONML311(),
'python-ml-3.12' => self::PYTHONML312(),
'python-ml-3.13' => self::PYTHONML313(),
'deno-1.21' => self::DENO121(),
'deno-1.24' => self::DENO124(),
'deno-1.35' => self::DENO135(),
'deno-1.40' => self::DENO140(),
'deno-1.46' => self::DENO146(),
'deno-2.0' => self::DENO20(),
Expand Down
8 changes: 4 additions & 4 deletions src/Appwrite/Models/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* @param string $updatedAt database update date in iso 8601 format.
* @param bool $enabled if database is enabled. can be 'enabled' or 'disabled'. when disabled, the database is inaccessible to users, but remains accessible to server sdks using api keys.
* @param DatabaseType $type database type.
* @param list<Index> $policies database backup policies.
* @param list<Collection> $archives database backup archives.
* @param list<BackupPolicy> $policies database backup policies.
* @param list<BackupArchive> $archives database backup archives.
*/
public function __construct(
public string $id,
Expand Down Expand Up @@ -74,13 +74,13 @@ public static function from(array $data): static
type: static::hydrateTypedValue(DatabaseType::class, $data['type']),
policies: is_array($data['policies'])
? array_map(
static fn (mixed $item): mixed => static::hydrateTypedValue(Index::class, $item),
static fn (mixed $item): mixed => static::hydrateTypedValue(BackupPolicy::class, $item),
$data['policies']
)
: $data['policies'],
archives: is_array($data['archives'])
? array_map(
static fn (mixed $item): mixed => static::hydrateTypedValue(Collection::class, $item),
static fn (mixed $item): mixed => static::hydrateTypedValue(BackupArchive::class, $item),
$data['archives']
)
: $data['archives']
Expand Down
20 changes: 17 additions & 3 deletions src/Appwrite/Models/OAuth2Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Appwrite\Models;

use Appwrite\Enums\OAuth2GooglePrompt;

/**
* OAuth2Google
*/
Expand All @@ -16,12 +18,14 @@
* @param bool $enabled oauth2 provider is active and can be used to create sessions.
* @param string $clientId google oauth2 client id.
* @param string $clientSecret google oauth2 client secret.
* @param list<OAuth2GooglePrompt> $prompt google oauth2 prompt values.
*/
public function __construct(
public string $id,
public bool $enabled,
public string $clientId,
public string $clientSecret
public string $clientSecret,
public array $prompt
) {
}

Expand All @@ -42,12 +46,21 @@ public static function from(array $data): static
if (!array_key_exists('clientSecret', $data)) {
throw new \InvalidArgumentException('Missing required field "clientSecret" for ' . static::class . '.');
}
if (!array_key_exists('prompt', $data)) {
throw new \InvalidArgumentException('Missing required field "prompt" for ' . static::class . '.');
}

return new static(
id: $data['$id'],
enabled: $data['enabled'],
clientId: $data['clientId'],
clientSecret: $data['clientSecret']
clientSecret: $data['clientSecret'],
prompt: is_array($data['prompt'])
? array_map(
static fn (mixed $item): mixed => static::hydrateTypedValue(OAuth2GooglePrompt::class, $item),
$data['prompt']
)
: $data['prompt']
);
}

Expand All @@ -60,7 +73,8 @@ public function toArray(): array
'$id' => static::serializeValue($this->id),
'enabled' => static::serializeValue($this->enabled),
'clientId' => static::serializeValue($this->clientId),
'clientSecret' => static::serializeValue($this->clientSecret)
'clientSecret' => static::serializeValue($this->clientSecret),
'prompt' => static::serializeValue($this->prompt)
];

return $result;
Expand Down
Loading