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)


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

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 = {
        "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)


161
162
163
164
165
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
# File 'lib/appwrite/services/backups.rb', line 161

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 = {
        "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)


308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/appwrite/services/backups.rb', line 308

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 = {
        "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:



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

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 = {
        "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:



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/appwrite/services/backups.rb', line 276

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 = {
        "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)


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

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 = {
    }

    @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)


209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/appwrite/services/backups.rb', line 209

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 = {
    }

    @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)


370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# File 'lib/appwrite/services/backups.rb', line 370

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 = {
    }

    @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
# File 'lib/appwrite/services/backups.rb', line 15

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

    api_params = {
        queries: queries,
    }
    
    api_headers = {
    }

    @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)


130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/appwrite/services/backups.rb', line 130

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

    api_params = {
        queries: queries,
    }
    
    api_headers = {
    }

    @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)


345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/appwrite/services/backups.rb', line 345

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

    api_params = {
        queries: queries,
    }
    
    api_headers = {
    }

    @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)


242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/appwrite/services/backups.rb', line 242

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 = {
        "content-type": 'application/json',
    }

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

end