Class: Appwrite::Backups

Inherits:
Service show all
Defined in:
lib/appwrite/services/backups.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Backups

Returns a new instance of Backups.



6
7
8
# File 'lib/appwrite/services/backups.rb', line 6

def initialize(client)
    @client = client
end

Instance Method Details

#create_archive(services:, resource_id: nil) ⇒ BackupArchive

Create a new archive asynchronously for a project.

Parameters:

  • services (Array)

    Array of services to backup

  • resource_id (String) (defaults to: nil)

    Resource ID. When set, only this single resource will be backed up.

Returns:

  • (BackupArchive)


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/appwrite/services/backups.rb', line 42

def create_archive(services:, resource_id: nil)
    api_path = '/backups/archives'

    if services.nil?
      raise Appwrite::Exception.new('Missing required parameter: "services"')
    end

    api_params = {
        services: services,
        resourceId: resource_id,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::BackupArchive
    )

end

#create_policy(policy_id:, services:, retention:, schedule:, name: nil, resource_id: nil, enabled: nil) ⇒ BackupPolicy

Create a new backup policy.

Parameters:

  • policy_id (String)

    Policy ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • services (Array)

    Array of services to backup

  • retention (Integer)

    Days to keep backups before deletion

  • schedule (String)

    Schedule CRON syntax.

  • name (String) (defaults to: nil)

    Policy name. Max length: 128 chars.

  • resource_id (String) (defaults to: nil)

    Resource ID. When set, only this single resource will be backed up.

  • []

    enabled Is policy enabled? When set to ‘disabled’, no backups will be taken

Returns:

  • (BackupPolicy)


166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/appwrite/services/backups.rb', line 166

def create_policy(policy_id:, services:, retention:, schedule:, name: nil, resource_id: nil, enabled: nil)
    api_path = '/backups/policies'

    if policy_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "policyId"')
    end

    if services.nil?
      raise Appwrite::Exception.new('Missing required parameter: "services"')
    end

    if retention.nil?
      raise Appwrite::Exception.new('Missing required parameter: "retention"')
    end

    if schedule.nil?
      raise Appwrite::Exception.new('Missing required parameter: "schedule"')
    end

    api_params = {
        policyId: policy_id,
        name: name,
        services: services,
        resourceId: resource_id,
        enabled: enabled,
        retention: retention,
        schedule: schedule,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::BackupPolicy
    )

end

#create_restoration(archive_id:, services:, new_resource_id: nil, new_resource_name: nil) ⇒ BackupRestoration

Create and trigger a new restoration for a backup on a project.

Parameters:

  • archive_id (String)

    Backup archive ID to restore

  • services (Array)

    Array of services to restore

  • new_resource_id (String) (defaults to: nil)

    Unique Id. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • new_resource_name (String) (defaults to: nil)

    Database name. Max length: 128 chars.

Returns:

  • (BackupRestoration)


317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/appwrite/services/backups.rb', line 317

def create_restoration(archive_id:, services:, new_resource_id: nil, new_resource_name: nil)
    api_path = '/backups/restoration'

    if archive_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "archiveId"')
    end

    if services.nil?
      raise Appwrite::Exception.new('Missing required parameter: "services"')
    end

    api_params = {
        archiveId: archive_id,
        services: services,
        newResourceId: new_resource_id,
        newResourceName: new_resource_name,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

    @client.call(
        method: 'POST',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::BackupRestoration
    )

end

#delete_archive(archive_id:) ⇒ Object

Delete an existing archive for a project.

Parameters:

  • archive_id (String)

    Policy ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

Returns:



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/appwrite/services/backups.rb', line 104

def delete_archive(archive_id:)
    api_path = '/backups/archives/{archiveId}'
        .gsub('{archiveId}', archive_id)

    if archive_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "archiveId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )

end

#delete_policy(policy_id:) ⇒ Object

Delete a policy using it’s ID.

Parameters:

  • policy_id (String)

    Policy ID. Choose a custom ID or generate a random ID with ‘ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

Returns:



284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/appwrite/services/backups.rb', line 284

def delete_policy(policy_id:)
    api_path = '/backups/policies/{policyId}'
        .gsub('{policyId}', policy_id)

    if policy_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "policyId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

    @client.call(
        method: 'DELETE',
        path: api_path,
        headers: api_headers,
        params: api_params,
    )

end

#get_archive(archive_id:) ⇒ BackupArchive

Get a backup archive using it’s ID.

Parameters:

  • archive_id (String)

    Archive ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

Returns:

  • (BackupArchive)


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/appwrite/services/backups.rb', line 74

def get_archive(archive_id:)
    api_path = '/backups/archives/{archiveId}'
        .gsub('{archiveId}', archive_id)

    if archive_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "archiveId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::BackupArchive
    )

end

#get_policy(policy_id:) ⇒ BackupPolicy

Get a backup policy using it’s ID.

Parameters:

  • policy_id (String)

    Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

Returns:

  • (BackupPolicy)


215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/appwrite/services/backups.rb', line 215

def get_policy(policy_id:)
    api_path = '/backups/policies/{policyId}'
        .gsub('{policyId}', policy_id)

    if policy_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "policyId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::BackupPolicy
    )

end

#get_restoration(restoration_id:) ⇒ BackupRestoration

Get the current status of a backup restoration.

Parameters:

  • restoration_id (String)

    Restoration ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

Returns:

  • (BackupRestoration)


381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/appwrite/services/backups.rb', line 381

def get_restoration(restoration_id:)
    api_path = '/backups/restorations/{restorationId}'
        .gsub('{restorationId}', restoration_id)

    if restoration_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "restorationId"')
    end

    api_params = {
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::BackupRestoration
    )

end

#list_archives(queries: nil) ⇒ BackupArchiveList

List all archives for a project.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.

Returns:

  • (BackupArchiveList)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/appwrite/services/backups.rb', line 15

def list_archives(queries: nil)
    api_path = '/backups/archives'

    api_params = {
        queries: queries,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::BackupArchiveList
    )

end

#list_policies(queries: nil) ⇒ BackupPolicyList

List all policies for a project.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.

Returns:

  • (BackupPolicyList)


134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/appwrite/services/backups.rb', line 134

def list_policies(queries: nil)
    api_path = '/backups/policies'

    api_params = {
        queries: queries,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::BackupPolicyList
    )

end

#list_restorations(queries: nil) ⇒ BackupRestorationList

List all backup restorations for a project.

Parameters:

  • queries (Array) (defaults to: nil)

    Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long.

Returns:

  • (BackupRestorationList)


355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'lib/appwrite/services/backups.rb', line 355

def list_restorations(queries: nil)
    api_path = '/backups/restorations'

    api_params = {
        queries: queries,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
    }

    @client.call(
        method: 'GET',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::BackupRestorationList
    )

end

#update_policy(policy_id:, name: nil, retention: nil, schedule: nil, enabled: nil) ⇒ BackupPolicy

Update an existing policy using it’s ID.

Parameters:

  • policy_id (String)

    Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can’t start with a special char. Max length is 36 chars.

  • name (String) (defaults to: nil)

    Policy name. Max length: 128 chars.

  • retention (Integer) (defaults to: nil)

    Days to keep backups before deletion

  • schedule (String) (defaults to: nil)

    Cron expression

  • []

    enabled Is Backup enabled? When set to ‘disabled’, No backup will be taken

Returns:

  • (BackupPolicy)


249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/appwrite/services/backups.rb', line 249

def update_policy(policy_id:, name: nil, retention: nil, schedule: nil, enabled: nil)
    api_path = '/backups/policies/{policyId}'
        .gsub('{policyId}', policy_id)

    if policy_id.nil?
      raise Appwrite::Exception.new('Missing required parameter: "policyId"')
    end

    api_params = {
        name: name,
        retention: retention,
        schedule: schedule,
        enabled: enabled,
    }
    
    api_headers = {
        "X-Appwrite-Project": @client.get_config('project'),
        "content-type": 'application/json',
    }

    @client.call(
        method: 'PATCH',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::BackupPolicy
    )

end