diff --git a/CHANGELOG.md b/CHANGELOG.md index 0480702..07f1534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 24.1.0 + +* Added `sizeActual` property to `File` model for actual stored size after compression/encryption +* Updated `BillingLimits` properties to be nullable to match the server's sparse "limits crossed" response +* Updated `Project.billingLimits` to be nullable +* Updated advisor example docs to use API key authentication +* Removed orphaned `Prompt` enum (already unused; superseded by `ProjectOAuth2GooglePrompt` in 24.0.0) + ## 24.0.0 * Breaking: Renamed `AuthMethod` enum to `ProjectAuthMethodId` diff --git a/docs/examples/advisor/get-insight.md b/docs/examples/advisor/get-insight.md index 79412e7..421a847 100644 --- a/docs/examples/advisor/get-insight.md +++ b/docs/examples/advisor/get-insight.md @@ -7,7 +7,7 @@ use Appwrite\Services\Advisor; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with + ->setKey(''); // Your secret API key $advisor = new Advisor($client); diff --git a/docs/examples/advisor/get-report.md b/docs/examples/advisor/get-report.md index 93e4d71..8baacab 100644 --- a/docs/examples/advisor/get-report.md +++ b/docs/examples/advisor/get-report.md @@ -7,7 +7,7 @@ use Appwrite\Services\Advisor; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with + ->setKey(''); // Your secret API key $advisor = new Advisor($client); diff --git a/docs/examples/advisor/list-insights.md b/docs/examples/advisor/list-insights.md index 241075b..10cf4fd 100644 --- a/docs/examples/advisor/list-insights.md +++ b/docs/examples/advisor/list-insights.md @@ -7,7 +7,7 @@ use Appwrite\Services\Advisor; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with + ->setKey(''); // Your secret API key $advisor = new Advisor($client); diff --git a/docs/examples/advisor/list-reports.md b/docs/examples/advisor/list-reports.md index 91f3c2d..29c4220 100644 --- a/docs/examples/advisor/list-reports.md +++ b/docs/examples/advisor/list-reports.md @@ -7,7 +7,7 @@ use Appwrite\Services\Advisor; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with + ->setKey(''); // Your secret API key $advisor = new Advisor($client); diff --git a/docs/examples/project/update-deny-canonical-email-policy.md b/docs/examples/project/update-deny-canonical-email-policy.md deleted file mode 100644 index 1580f5e..0000000 --- a/docs/examples/project/update-deny-canonical-email-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 - -$project = new Project($client); - -$result = $project->updateDenyCanonicalEmailPolicy( - enabled: false -);``` diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 09df9b9..f9ff454 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/24.0.0 ()', + 'user-agent' => 'AppwritePHPSDK/24.1.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '24.0.0', + 'x-sdk-version'=> '24.1.0', ]; /** diff --git a/src/Appwrite/Enums/Prompt.php b/src/Appwrite/Enums/Prompt.php deleted file mode 100644 index 92980f9..0000000 --- a/src/Appwrite/Enums/Prompt.php +++ /dev/null @@ -1,61 +0,0 @@ -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), - }; - } -} diff --git a/src/Appwrite/Models/BillingLimits.php b/src/Appwrite/Models/BillingLimits.php index 8f95f73..f80a744 100644 --- a/src/Appwrite/Models/BillingLimits.php +++ b/src/Appwrite/Models/BillingLimits.php @@ -12,24 +12,24 @@ /** * BillingLimits constructor. * - * @param int $bandwidth bandwidth limit - * @param int $storage storage limit - * @param int $users users limit - * @param int $executions executions limit - * @param int $gBHours gbhours limit - * @param int $imageTransformations image transformations limit - * @param int $authPhone auth phone limit - * @param int $budgetLimit budget limit percentage + * @param int|null $bandwidth bandwidth limit + * @param int|null $storage storage limit + * @param int|null $users users limit + * @param int|null $executions executions limit + * @param int|null $gBHours gbhours limit + * @param int|null $imageTransformations image transformations limit + * @param int|null $authPhone auth phone limit + * @param int|null $budgetLimit budget limit percentage */ public function __construct( - public int $bandwidth, - public int $storage, - public int $users, - public int $executions, - public int $gBHours, - public int $imageTransformations, - public int $authPhone, - public int $budgetLimit + public ?int $bandwidth = null, + public ?int $storage = null, + public ?int $users = null, + public ?int $executions = null, + public ?int $gBHours = null, + public ?int $imageTransformations = null, + public ?int $authPhone = null, + public ?int $budgetLimit = null ) { } @@ -38,40 +38,16 @@ public function __construct( */ public static function from(array $data): static { - if (!array_key_exists('bandwidth', $data)) { - throw new \InvalidArgumentException('Missing required field "bandwidth" for ' . static::class . '.'); - } - if (!array_key_exists('storage', $data)) { - throw new \InvalidArgumentException('Missing required field "storage" for ' . static::class . '.'); - } - if (!array_key_exists('users', $data)) { - throw new \InvalidArgumentException('Missing required field "users" for ' . static::class . '.'); - } - if (!array_key_exists('executions', $data)) { - throw new \InvalidArgumentException('Missing required field "executions" for ' . static::class . '.'); - } - if (!array_key_exists('GBHours', $data)) { - throw new \InvalidArgumentException('Missing required field "GBHours" for ' . static::class . '.'); - } - if (!array_key_exists('imageTransformations', $data)) { - throw new \InvalidArgumentException('Missing required field "imageTransformations" for ' . static::class . '.'); - } - if (!array_key_exists('authPhone', $data)) { - throw new \InvalidArgumentException('Missing required field "authPhone" for ' . static::class . '.'); - } - if (!array_key_exists('budgetLimit', $data)) { - throw new \InvalidArgumentException('Missing required field "budgetLimit" for ' . static::class . '.'); - } return new static( - bandwidth: $data['bandwidth'], - storage: $data['storage'], - users: $data['users'], - executions: $data['executions'], - gBHours: $data['GBHours'], - imageTransformations: $data['imageTransformations'], - authPhone: $data['authPhone'], - budgetLimit: $data['budgetLimit'] + bandwidth: array_key_exists('bandwidth', $data) ? $data['bandwidth'] : null, + storage: array_key_exists('storage', $data) ? $data['storage'] : null, + users: array_key_exists('users', $data) ? $data['users'] : null, + executions: array_key_exists('executions', $data) ? $data['executions'] : null, + gBHours: array_key_exists('GBHours', $data) ? $data['GBHours'] : null, + imageTransformations: array_key_exists('imageTransformations', $data) ? $data['imageTransformations'] : null, + authPhone: array_key_exists('authPhone', $data) ? $data['authPhone'] : null, + budgetLimit: array_key_exists('budgetLimit', $data) ? $data['budgetLimit'] : null ); } diff --git a/src/Appwrite/Models/File.php b/src/Appwrite/Models/File.php index b2bbc9a..0853e50 100644 --- a/src/Appwrite/Models/File.php +++ b/src/Appwrite/Models/File.php @@ -21,6 +21,7 @@ * @param string $signature file md5 signature. * @param string $mimeType file mime type. * @param int $sizeOriginal file original size in bytes. + * @param int $sizeActual file actual stored size in bytes after compression and/or encryption. * @param int $chunksTotal total number of chunks available * @param int $chunksUploaded total number of chunks uploaded * @param bool $encryption whether file contents are encrypted at rest. @@ -36,6 +37,7 @@ public function __construct( public string $signature, public string $mimeType, public int $sizeOriginal, + public int $sizeActual, public int $chunksTotal, public int $chunksUploaded, public bool $encryption, @@ -75,6 +77,9 @@ public static function from(array $data): static if (!array_key_exists('sizeOriginal', $data)) { throw new \InvalidArgumentException('Missing required field "sizeOriginal" for ' . static::class . '.'); } + if (!array_key_exists('sizeActual', $data)) { + throw new \InvalidArgumentException('Missing required field "sizeActual" for ' . static::class . '.'); + } if (!array_key_exists('chunksTotal', $data)) { throw new \InvalidArgumentException('Missing required field "chunksTotal" for ' . static::class . '.'); } @@ -98,6 +103,7 @@ public static function from(array $data): static signature: $data['signature'], mimeType: $data['mimeType'], sizeOriginal: $data['sizeOriginal'], + sizeActual: $data['sizeActual'], chunksTotal: $data['chunksTotal'], chunksUploaded: $data['chunksUploaded'], encryption: $data['encryption'], @@ -120,6 +126,7 @@ public function toArray(): array 'signature' => static::serializeValue($this->signature), 'mimeType' => static::serializeValue($this->mimeType), 'sizeOriginal' => static::serializeValue($this->sizeOriginal), + 'sizeActual' => static::serializeValue($this->sizeActual), 'chunksTotal' => static::serializeValue($this->chunksTotal), 'chunksUploaded' => static::serializeValue($this->chunksUploaded), 'encryption' => static::serializeValue($this->encryption), diff --git a/src/Appwrite/Models/Project.php b/src/Appwrite/Models/Project.php index cdcb986..0b31c9b 100644 --- a/src/Appwrite/Models/Project.php +++ b/src/Appwrite/Models/Project.php @@ -36,9 +36,9 @@ * @param list $services list of services. * @param list $protocols list of protocols. * @param string $region project region - * @param BillingLimits $billingLimits billing limits reached * @param list $blocks project blocks information * @param string $consoleAccessedAt last time the project was accessed via console. used with plan's projectinactivitydays to determine if project is paused. + * @param BillingLimits|null $billingLimits billing limits reached */ public function __construct( public string $id, @@ -65,9 +65,9 @@ public function __construct( public array $services, public array $protocols, public string $region, - public BillingLimits $billingLimits, public array $blocks, - public string $consoleAccessedAt + public string $consoleAccessedAt, + public ?BillingLimits $billingLimits = null ) { } @@ -148,9 +148,6 @@ public static function from(array $data): static if (!array_key_exists('region', $data)) { throw new \InvalidArgumentException('Missing required field "region" for ' . static::class . '.'); } - if (!array_key_exists('billingLimits', $data)) { - throw new \InvalidArgumentException('Missing required field "billingLimits" for ' . static::class . '.'); - } if (!array_key_exists('blocks', $data)) { throw new \InvalidArgumentException('Missing required field "blocks" for ' . static::class . '.'); } @@ -203,14 +200,14 @@ public static function from(array $data): static ) : $data['protocols'], region: $data['region'], - billingLimits: static::hydrateTypedValue(BillingLimits::class, $data['billingLimits']), blocks: is_array($data['blocks']) ? array_map( static fn (mixed $item): mixed => static::hydrateTypedValue(Block::class, $item), $data['blocks'] ) : $data['blocks'], - consoleAccessedAt: $data['consoleAccessedAt'] + consoleAccessedAt: $data['consoleAccessedAt'], + billingLimits: array_key_exists('billingLimits', $data) ? static::hydrateTypedValue(BillingLimits::class, $data['billingLimits'], true) : null ); } diff --git a/tests/Appwrite/Services/ProjectTest.php b/tests/Appwrite/Services/ProjectTest.php index 81180fb..4b85982 100644 --- a/tests/Appwrite/Services/ProjectTest.php +++ b/tests/Appwrite/Services/ProjectTest.php @@ -81,16 +81,6 @@ public function testMethodGet(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -181,16 +171,6 @@ public function testMethodUpdateAuthMethod(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -419,16 +399,6 @@ public function testMethodUpdateLabels(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -1736,16 +1706,6 @@ public function testMethodUpdateDenyAliasedEmailPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -1825,16 +1785,6 @@ public function testMethodUpdateDenyDisposableEmailPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -1914,16 +1864,6 @@ public function testMethodUpdateDenyFreeEmailPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2003,16 +1943,6 @@ public function testMethodUpdateMembershipPrivacyPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2090,16 +2020,6 @@ public function testMethodUpdatePasswordDictionaryPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2179,16 +2099,6 @@ public function testMethodUpdatePasswordHistoryPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2268,16 +2178,6 @@ public function testMethodUpdatePasswordPersonalDataPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2357,16 +2257,6 @@ public function testMethodUpdateSessionAlertPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2446,16 +2336,6 @@ public function testMethodUpdateSessionDurationPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2535,16 +2415,6 @@ public function testMethodUpdateSessionInvalidationPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2624,16 +2494,6 @@ public function testMethodUpdateSessionLimitPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2713,16 +2573,6 @@ public function testMethodUpdateUserLimitPolicy(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2829,16 +2679,6 @@ public function testMethodUpdateProtocol(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -2919,16 +2759,6 @@ public function testMethodUpdateService(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -3009,16 +2839,6 @@ public function testMethodUpdateSMTP(): void ) ), "region" => "fra", - "billingLimits" => array( - "bandwidth" => 5, - "storage" => 150, - "users" => 200000, - "executions" => 750000, - "GBHours" => 100, - "imageTransformations" => 100, - "authPhone" => 10, - "budgetLimit" => 100 - ), "blocks" => array( array( "\$createdAt" => "2020-10-15T06:38:00.000+00:00", diff --git a/tests/Appwrite/Services/StorageTest.php b/tests/Appwrite/Services/StorageTest.php index ac7c71f..4b62eea 100644 --- a/tests/Appwrite/Services/StorageTest.php +++ b/tests/Appwrite/Services/StorageTest.php @@ -176,6 +176,7 @@ public function testMethodListFiles(): void "signature" => "5d529fd02b544198ae075bd57c1762bb", "mimeType" => "image/png", "sizeOriginal" => 17890, + "sizeActual" => 12345, "chunksTotal" => 17890, "chunksUploaded" => 17890, "encryption" => true, @@ -207,6 +208,7 @@ public function testMethodCreateFile(): void "signature" => "5d529fd02b544198ae075bd57c1762bb", "mimeType" => "image/png", "sizeOriginal" => 17890, + "sizeActual" => 12345, "chunksTotal" => 17890, "chunksUploaded" => 17890, "encryption" => true, @@ -238,6 +240,7 @@ public function testMethodGetFile(): void "signature" => "5d529fd02b544198ae075bd57c1762bb", "mimeType" => "image/png", "sizeOriginal" => 17890, + "sizeActual" => 12345, "chunksTotal" => 17890, "chunksUploaded" => 17890, "encryption" => true, @@ -268,6 +271,7 @@ public function testMethodUpdateFile(): void "signature" => "5d529fd02b544198ae075bd57c1762bb", "mimeType" => "image/png", "sizeOriginal" => 17890, + "sizeActual" => 12345, "chunksTotal" => 17890, "chunksUploaded" => 17890, "encryption" => true,