@@ -229,44 +229,20 @@ public function report(array $resources = [], array $resourceIds = []): array
229229 $ this ->sites ->create ('' , '' , Framework::OTHER (), BuildRuntime::STATIC1 ());
230230 }
231231
232- } catch (AppwriteException $ e ) {
233- if ($ e ->getCode () === 403 ) {
234- throw new \Exception ('Missing scope: ' . $ scope , previous: $ e );
235- }
236- throw $ e ;
237- }
238-
239- // Backups use call() instead of the SDK, so they need separate error handling.
240- if (\in_array (Resource::TYPE_BACKUP_POLICY , $ resources )) {
241- try {
232+ // Backups
233+ if (\in_array (Resource::TYPE_BACKUP_POLICY , $ resources )) {
242234 $ scope = 'policies.read ' ;
243- $ this ->call ('GET ' , '/backups/policies ' , [
244- 'Content-Type ' => 'application/json ' ,
245- 'X-Appwrite-Project ' => $ this ->project ,
246- 'X-Appwrite-Key ' => $ this ->key ,
247- ]);
235+ $ this ->backups ->listPolicies ();
248236
249237 $ scope = 'policies.write ' ;
250- $ this ->call ('POST ' , '/backups/policies ' , [
251- 'Content-Type ' => 'application/json ' ,
252- 'X-Appwrite-Project ' => $ this ->project ,
253- 'X-Appwrite-Key ' => $ this ->key ,
254- ], []);
255- } catch (\Throwable $ e ) {
256- $ body = \json_decode ($ e ->getMessage (), true );
257- $ code = $ body ['code ' ] ?? 0 ;
258- $ type = $ body ['type ' ] ?? '' ;
259-
260- if ($ type === 'additional_resource_not_allowed ' ) {
261- throw new \Exception ('Backups are not available on the destination project \'s plan ' , previous: $ e );
262- }
263-
264- if ($ code === 401 || $ code === 403 ) {
265- throw new \Exception ('Missing scope: ' . $ scope , previous: $ e );
266- }
238+ $ this ->backups ->createPolicy ('' , [], 0 , '' );
239+ }
267240
268- throw $ e ;
241+ } catch (AppwriteException $ e ) {
242+ if ($ e ->getCode () === 403 ) {
243+ throw new \Exception ('Missing scope: ' . $ scope , previous: $ e );
269244 }
245+ throw $ e ;
270246 }
271247
272248 return [];
0 commit comments