Class: Appwrite::Mongo

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Mongo

Returns a new instance of Mongo.



5
6
7
# File 'lib/appwrite/services/mongo.rb', line 5

def initialize(client)
    @client = client
end

Instance Method Details

#create(database_id:, name:, version: nil, specification: nil, replicas: nil, sync_mode: nil, network_idle_timeout_seconds: nil, network_ip_allowlist: nil, idle_timeout_minutes: nil, pitr: nil, pitr_retention_days: nil, storage_autoscaling: nil, storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil) ⇒ DedicatedDatabase

Create a new dedicated database with the chosen engine and configuration. Status will be 'provisioning' until the database is ready.

Parameters:

  • database_id (String) —

    Database 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.

  • name (String) —

    Database display name. Max length: 128 chars.

  • version (String) (defaults to: nil) —

    Database engine version. Defaults to latest for selected engine.

  • specification (String) (defaults to: nil) —

    Specification identifier. Drives the allocated CPU, memory, storage, storage class, and connection ceiling.

  • replicas (Integer) (defaults to: nil) —

    Number of high availability replicas (0-5). High availability is enabled when greater than 0.

  • sync_mode (String) (defaults to: nil) —

    Replication sync mode preference. Allowed values: async, sync, quorum.

  • network_idle_timeout_seconds (Integer) (defaults to: nil) —

    Connection idle timeout in seconds.

  • network_ip_allowlist (Array) (defaults to: nil) —

    IP addresses/CIDR ranges allowed to connect.

  • idle_timeout_minutes (Integer) (defaults to: nil) —

    Minutes of inactivity before container scales to zero.

  • [] —

    pitr Enable point-in-time recovery (PITR). Continuously archives changes so the database can be restored to any moment within the retention window.

  • pitr_retention_days (Integer) (defaults to: nil) —

    Number of days to retain PITR data.

  • [] —

    storage_autoscaling Enable automatic storage expansion when usage exceeds threshold.

  • storage_autoscaling_threshold_percent (Integer) (defaults to: nil) —

    Storage usage percentage (50-95) that triggers automatic expansion.

  • storage_autoscaling_max_gb (Integer) (defaults to: nil) —

    Maximum storage size in GB for autoscaling. Defaults to 3 times the specification's storage. 0 means no limit.

Returns:

  • (DedicatedDatabase)


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/appwrite/services/mongo.rb', line 59

def create(
    database_id:,
    name:,
    version: nil,
    specification: nil,
    replicas: nil,
    sync_mode: nil,
    network_idle_timeout_seconds: nil,
    network_ip_allowlist: nil,
    idle_timeout_minutes: nil,
    pitr: nil,
    pitr_retention_days: nil,
    storage_autoscaling: nil,
    storage_autoscaling_threshold_percent: nil,
    storage_autoscaling_max_gb: nil
)
    if database_id.nil?
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

    api_path = '/mongo'

    api_params = {
        databaseId: database_id,
        name: name,
        version: version,
        specification: specification,
        replicas: replicas,
        syncMode: sync_mode,
        networkIdleTimeoutSeconds: network_idle_timeout_seconds,
        networkIPAllowlist: network_ip_allowlist,
        idleTimeoutMinutes: idle_timeout_minutes,
        pitr: pitr,
        pitrRetentionDays: pitr_retention_days,
        storageAutoscaling: storage_autoscaling,
        storageAutoscalingThresholdPercent: storage_autoscaling_threshold_percent,
        storageAutoscalingMaxGb: storage_autoscaling_max_gb,
    }

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

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

#create_backup(database_id:, type: nil) ⇒ DedicatedDatabaseBackup

Create a manual backup of a dedicated database. The backup will be created asynchronously and its status can be checked via the get backup endpoint.

Parameters:

  • database_id (String) —

    Database ID.

  • type (String) (defaults to: nil) —

    Backup type: full or incremental.

Returns:

  • (DedicatedDatabaseBackup)


350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# File 'lib/appwrite/services/mongo.rb', line 350

def create_backup(
    database_id:,
    type: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/backups'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        type: type,
    }

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

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

#create_backup_policy(database_id:, policy_id:, name:, schedule:, retention:, type: nil, enabled: nil) ⇒ BackupPolicy

Create a scheduled backup policy for a dedicated database.

Parameters:

  • database_id (String) —

    Database ID.

  • 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.

  • name (String) —

    Policy name. Max length: 128 chars.

  • schedule (String) —

    Schedule CRON syntax.

  • retention (Integer) —

    Days to keep backups before deletion.

  • type (String) (defaults to: nil) —

    Backup type: full or incremental.

  • [] —

    enabled Is policy enabled? When disabled, no backups will be taken.

Returns:

  • (BackupPolicy)


429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/appwrite/services/mongo.rb', line 429

def create_backup_policy(
    database_id:,
    policy_id:,
    name:,
    schedule:,
    retention:,
    type: nil,
    enabled: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

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

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

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

    api_path = '/mongo/{databaseId}/backups/policies'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        policyId: policy_id,
        name: name,
        schedule: schedule,
        retention: retention,
        type: type,
        enabled: enabled,
    }

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

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

#create_branch(database_id:, branch_id: nil, ttl: nil) ⇒ DedicatedDatabase

Create an ephemeral database branch from the primary via PVC snapshot. The branch is a full copy of the database at the current point in time, useful for testing schema migrations or running experiments without affecting production data. Branches expire after the configured TTL (default 24 hours). The branch is created asynchronously.

Parameters:

  • database_id (String) —

    Database ID.

  • branch_id (String) (defaults to: nil) —

    Branch 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.

  • ttl (Integer) (defaults to: nil) —

    Time-to-live in seconds before the branch expires. Min 300 (5 min), max 604800 (7 days). Default: 86400 (24h).

Returns:

  • (DedicatedDatabase)


807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
# File 'lib/appwrite/services/mongo.rb', line 807

def create_branch(
    database_id:,
    branch_id: nil,
    ttl: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/branches'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        branchId: branch_id,
        ttl: ttl,
    }

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

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

#create_failover(database_id:, target_replica_id: nil) ⇒ DedicatedDatabase

Trigger a manual failover for a dedicated database with high availability enabled. Promotes a replica to primary. The failover runs asynchronously; poll the database document for status updates. A database left mid-operation also accepts this call as a repair once nothing is driving the operation it is stuck in. Repairing a failover that did not finish, a failed database, a stranded upgrade or migrate, or a stranded compute resize additionally requires targetReplicaId to name the member to promote, because the default target may be the member that operation already promoted.

Parameters:

  • database_id (String) —

    Database ID.

  • target_replica_id (String) (defaults to: nil) —

    Target replica ID to promote. If not specified, the healthiest replica is selected.

Returns:

  • (DedicatedDatabase)


929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
# File 'lib/appwrite/services/mongo.rb', line 929

def create_failover(
    database_id:,
    target_replica_id: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/failovers'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        targetReplicaId: target_replica_id,
    }

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

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

#create_migration(database_id:, target_type:, specification: nil) ⇒ DedicatedDatabase

Migrate a database between shared and dedicated types. Shared to dedicated provisions an always-on dedicated instance; dedicated to shared converts to a serverless instance that scales to zero when idle. Data is copied to the target with a brief read-only window during cutover.

Parameters:

  • database_id (String) —

    Database ID.

  • target_type (String) —

    Target database type to migrate to. Allowed values: shared (serverless, scales to zero when idle), dedicated (always-on with persistent resources).

  • specification (String) (defaults to: nil) —

    Target specification to provision when migrating to dedicated. Ignored for shared. Defaults to the database's current specification.

Returns:

  • (DedicatedDatabase)


1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
# File 'lib/appwrite/services/mongo.rb', line 1018

def create_migration(
    database_id:,
    target_type:,
    specification: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

    api_path = '/mongo/{databaseId}/migrations'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        targetType: target_type,
        specification: specification,
    }

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

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

#create_restoration(database_id:, type: nil, backup_id: nil, target_database_id: nil, target_time: nil, restore_mode: nil, target_name: nil, auto_promote: nil) ⇒ DedicatedDatabaseRestoration

Restore a database from a backup or to a specific point in time (PITR). For backup restoration, provide a backupId. For PITR, provide a targetTime as an ISO 8601 datetime. PITR requires the database to have PITR enabled and is only available for enterprise databases.

By default the backup is replayed over the database it was taken from. Pass restoreMode as clone to recover it onto a second workload beside this database instead: this database keeps serving its own data while the clone is filled, and the switch happens as soon as the clone is ready, on the endpoint and credentials it already had. Pass autoPromote as false to hold the clone until you promote it yourself. Pass restoreMode as copy to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one provisioned as a copy of this database's engine, version, specification and replicas. Neither mode is available for a point-in-time recovery or an incremental backup.

Parameters:

  • database_id (String) —

    Database ID.

  • type (String) (defaults to: nil) —

    Restoration type. Allowed values: backup, pitr. Use "backup" to restore from a specific backup, or "pitr" for point-in-time recovery.

  • backup_id (String) (defaults to: nil) —

    Backup ID to restore from (required for backup type).

  • target_database_id (String) (defaults to: nil) —

    Existing database ID to restore into. The target must be distinct, ready, and use the same engine and version. Omit it on a copy restoration to have one provisioned. Not accepted for a clone, which is recovered inside this database.

  • target_time (String) (defaults to: nil) —

    Target time for PITR (required for pitr type) as an ISO 8601 datetime.

  • restore_mode (String) (defaults to: nil) —

    Where the backup is restored. Allowed values: in_place, clone, copy. Use "clone" to recover onto a second workload beside this database and leave it serving until you promote — the endpoint and credentials do not change. Use "copy" to recover onto a separate database with its own endpoint, either one you name with targetDatabaseId or one Cloud provisions. Use "in_place" to replay the backup over this database. Defaults to "copy" when a targetDatabaseId is given, "in_place" otherwise.

  • target_name (String) (defaults to: nil) —

    Display name for the database a copy restoration provisions. Defaults to this database's name followed by "(restored)". Max length: 128 chars.

  • [] —

    auto_promote Whether a clone restoration switches the database over as soon as the recovery is ready. Default true: the restore finishes with the database serving the recovery point on the endpoint it already had, and the side it replaced kept briefly so the switch can be reversed. Pass false to hold the recovery until you call the promotion endpoint yourself.

Returns:

  • (DedicatedDatabaseRestoration)


1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
# File 'lib/appwrite/services/mongo.rb', line 1233

def create_restoration(
    database_id:,
    type: nil,
    backup_id: nil,
    target_database_id: nil,
    target_time: nil,
    restore_mode: nil,
    target_name: nil,
    auto_promote: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/restorations'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        type: type,
        backupId: backup_id,
        targetDatabaseId: target_database_id,
        targetTime: target_time,
        restoreMode: restore_mode,
        targetName: target_name,
        autoPromote: auto_promote,
    }

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

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

#create_upgrade(database_id:, target_version:) ⇒ DedicatedDatabase

Upgrade a dedicated database to a new engine version. Uses blue-green deployment for zero-downtime cutover.

Parameters:

  • database_id (String) —

    Database ID.

  • target_version (String) —

    Target engine version to upgrade to.

Returns:

  • (DedicatedDatabase)


1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
# File 'lib/appwrite/services/mongo.rb', line 1398

def create_upgrade(
    database_id:,
    target_version:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

    api_path = '/mongo/{databaseId}/upgrades'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        targetVersion: target_version,
    }

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

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

#delete(database_id:) ⇒ Object

Delete a dedicated database. This action is irreversible. The database status will be set to 'deleting' and all resources will be cleaned up. Deletion is allowed from any state, and repeating the call re-dispatches the cleanup.

Parameters:

  • database_id (String) —

    Database ID.

Returns:

  • []



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

def delete(
    database_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {}

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

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

#delete_backup(database_id:, backup_id:) ⇒ Object

Delete a database backup. This will permanently remove the backup from storage and cannot be undone.

Parameters:

  • database_id (String) —

    Database ID.

  • backup_id (String) —

    Backup ID.

Returns:

  • []



732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'lib/appwrite/services/mongo.rb', line 732

def delete_backup(
    database_id:,
    backup_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    if backup_id.nil? || backup_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "backupId"')
    end

    api_path = '/mongo/{databaseId}/backups/{backupId}'
        .gsub('{databaseId}', @client.encode_path(database_id))
        .gsub('{backupId}', @client.encode_path(backup_id))

    api_params = {}

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

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

#delete_backup_policy(database_id:, policy_id:) ⇒ Object

Delete a scheduled backup policy for a dedicated database. Backups already taken by the policy are kept until their retention expires.

Parameters:

  • database_id (String) —

    Database ID.

  • policy_id (String) —

    Policy ID.

Returns:

  • []



582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/appwrite/services/mongo.rb', line 582

def delete_backup_policy(
    database_id:,
    policy_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

    api_path = '/mongo/{databaseId}/backups/policies/{policyId}'
        .gsub('{databaseId}', @client.encode_path(database_id))
        .gsub('{policyId}', @client.encode_path(policy_id))

    api_params = {}

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

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

#delete_branch(database_id:, branch_id:) ⇒ DedicatedDatabase

Delete an ephemeral database branch. This removes the branch namespace, its PVC, and the associated VolumeSnapshot. The deletion runs asynchronously and is irreversible.

Parameters:

  • database_id (String) —

    Database ID.

  • branch_id (String) —

    Branch ID.

Returns:

  • (DedicatedDatabase)


847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
# File 'lib/appwrite/services/mongo.rb', line 847

def delete_branch(
    database_id:,
    branch_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    if branch_id.nil? || branch_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "branchId"')
    end

    api_path = '/mongo/{databaseId}/branches/{branchId}'
        .gsub('{databaseId}', @client.encode_path(database_id))
        .gsub('{branchId}', @client.encode_path(branch_id))

    api_params = {}

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

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

#get(database_id:) ⇒ DedicatedDatabase

Get a dedicated database by its unique ID. Returns the database configuration and current status.

Parameters:

  • database_id (String) —

    Database ID.

Returns:

  • (DedicatedDatabase)


148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/appwrite/services/mongo.rb', line 148

def get(
    database_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {}

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

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

#get_backup(database_id:, backup_id:) ⇒ DedicatedDatabaseBackup

Get details of a specific database backup including its status, size, and timestamps.

Parameters:

  • database_id (String) —

    Database ID.

  • backup_id (String) —

    Backup ID.

Returns:

  • (DedicatedDatabaseBackup)


693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
# File 'lib/appwrite/services/mongo.rb', line 693

def get_backup(
    database_id:,
    backup_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    if backup_id.nil? || backup_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "backupId"')
    end

    api_path = '/mongo/{databaseId}/backups/{backupId}'
        .gsub('{databaseId}', @client.encode_path(database_id))
        .gsub('{backupId}', @client.encode_path(backup_id))

    api_params = {}

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

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

#get_backup_policy(database_id:, policy_id:) ⇒ BackupPolicy

Get a scheduled backup policy for a dedicated database.

Parameters:

  • database_id (String) —

    Database ID.

  • policy_id (String) —

    Policy ID.

Returns:

  • (BackupPolicy)


491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/appwrite/services/mongo.rb', line 491

def get_backup_policy(
    database_id:,
    policy_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

    api_path = '/mongo/{databaseId}/backups/policies/{policyId}'
        .gsub('{databaseId}', @client.encode_path(database_id))
        .gsub('{policyId}', @client.encode_path(policy_id))

    api_params = {}

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

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

#get_pitr(database_id:) ⇒ DedicatedDatabasePITRWindows

Get available point-in-time recovery windows for a dedicated database. Returns the earliest and latest recovery points.

Parameters:

  • database_id (String) —

    Database ID.

Returns:

  • (DedicatedDatabasePITRWindows)


1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
# File 'lib/appwrite/services/mongo.rb', line 1104

def get_pitr(
    database_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/pitr'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {}

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

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

#get_replicas(database_id:) ⇒ DedicatedDatabaseReplicas

Get high availability status for a dedicated database. Returns replica statuses, replication lag, and sync mode.

Parameters:

  • database_id (String) —

    Database ID.

Returns:

  • (DedicatedDatabaseReplicas)


1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
# File 'lib/appwrite/services/mongo.rb', line 1136

def get_replicas(
    database_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/replicas'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {}

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

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

#get_restoration(database_id:, restoration_id:) ⇒ DedicatedDatabaseRestoration

Get details of a specific database restoration including its status, type, and timestamps.

Parameters:

  • database_id (String) —

    Database ID.

  • restoration_id (String) —

    Restoration ID.

Returns:

  • (DedicatedDatabaseRestoration)


1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
# File 'lib/appwrite/services/mongo.rb', line 1282

def get_restoration(
    database_id:,
    restoration_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

    api_path = '/mongo/{databaseId}/restorations/{restorationId}'
        .gsub('{databaseId}', @client.encode_path(database_id))
        .gsub('{restorationId}', @client.encode_path(restoration_id))

    api_params = {}

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

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

#get_status(database_id:) ⇒ DatabaseStatus

Get real-time health and status information for a dedicated database. Returns health status, readiness, uptime, connection info, replica status, and volume information.

Parameters:

  • database_id (String) —

    Database ID.

Returns:

  • (DatabaseStatus)


1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
# File 'lib/appwrite/services/mongo.rb', line 1365

def get_status(
    database_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/status'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {}

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

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

#list(queries: nil, total: nil) ⇒ DedicatedDatabaseList

List all dedicated databases. Results support pagination.

Parameters:

  • queries (Array) (defaults to: nil) —

    Array of query strings.

  • [] —

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (DedicatedDatabaseList)


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

def list(
    queries: nil,
    total: nil
)
    api_path = '/mongo'

    api_params = {
        queries: queries,
        total: total,
    }

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

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

#list_backup_policies(database_id:, queries: nil, total: nil) ⇒ BackupPolicyList

List scheduled backup policies for a dedicated database.

Parameters:

  • database_id (String) —

    Database ID.

  • queries (Array) (defaults to: nil) —

    Array of query strings generated using the Query class provided by the SDK.

  • [] —

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (BackupPolicyList)


387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/appwrite/services/mongo.rb', line 387

def list_backup_policies(
    database_id:,
    queries: nil,
    total: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/backups/policies'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        queries: queries,
        total: total,
    }

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

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

#list_backups(database_id:, queries: nil, total: nil) ⇒ DedicatedDatabaseBackupList

List all backups for a dedicated database. Results can be filtered by status and type.

Parameters:

  • database_id (String) —

    Database ID.

  • queries (Array) (defaults to: nil) —

    Array of query strings generated using the Query class provided by the SDK. Learn more about queries. Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: status, type, databaseId

  • [] —

    total When set to false, the total count returned will be 0 and will not be calculated.

Returns:

  • (DedicatedDatabaseBackupList)


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
339
340
341
# File 'lib/appwrite/services/mongo.rb', line 312

def list_backups(
    database_id:,
    queries: nil,
    total: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/backups'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        queries: queries,
        total: total,
    }

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

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

#list_branches(database_id:) ⇒ DedicatedDatabaseBranchList

List all ephemeral branches for a dedicated database. Returns branch metadata including ID, name, namespace, and expiration time.

Parameters:

  • database_id (String) —

    Database ID.

Returns:

  • (DedicatedDatabaseBranchList)


770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# File 'lib/appwrite/services/mongo.rb', line 770

def list_branches(
    database_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/branches'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {}

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

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

#list_operations(database_id:, status: nil, limit: nil, offset: nil) ⇒ DedicatedDatabaseOperationList

List the lifecycle operations recorded for a dedicated database, newest first. Every provision, update, restore, backup and replication action is recorded here with its outcome, including an attempt that was abandoned because another worker took over the database.

Parameters:

  • database_id (String) —

    Database ID.

  • status (String) (defaults to: nil) —

    Filter by operation status.

  • limit (Integer) (defaults to: nil) —

    Maximum number of operations to return.

  • offset (Integer) (defaults to: nil) —

    Number of operations to skip.

Returns:

  • (DedicatedDatabaseOperationList)


1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
# File 'lib/appwrite/services/mongo.rb', line 1065

def list_operations(
    database_id:,
    status: nil,
    limit: nil,
    offset: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/operations'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        status: status,
        limit: limit,
        offset: offset,
    }

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

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

#list_restorations(database_id:, status: nil, type: nil, limit: nil, offset: nil) ⇒ DedicatedDatabaseRestorationList

List all restorations for a dedicated database. Results can be filtered by status and type.

Parameters:

  • database_id (String) —

    Database ID.

  • status (String) (defaults to: nil) —

    Filter by restoration status.

  • type (String) (defaults to: nil) —

    Filter by restoration type.

  • limit (Integer) (defaults to: nil) —

    Maximum number of restorations to return.

  • offset (Integer) (defaults to: nil) —

    Number of restorations to skip.

Returns:

  • (DedicatedDatabaseRestorationList)


1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
# File 'lib/appwrite/services/mongo.rb', line 1172

def list_restorations(
    database_id:,
    status: nil,
    type: nil,
    limit: nil,
    offset: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/restorations'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        status: status,
        type: type,
        limit: limit,
        offset: offset,
    }

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

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

#list_specifications ⇒ DedicatedDatabaseSpecificationList

List the dedicated database specifications available on the current plan. Each specification reports its resource limits, its own prices and overage rates, and whether it is enabled for the organization.

Returns:

  • (DedicatedDatabaseSpecificationList)


123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/appwrite/services/mongo.rb', line 123

def list_specifications()
    api_path = '/mongo/specifications'

    api_params = {}

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

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

#promote_restoration(database_id:, restoration_id:) ⇒ DedicatedDatabaseRestoration

Switch the database over to the clone a restoration recovered. The database keeps its endpoint and credentials; clients reconnect once. Writes made after the recovery point are discarded, and the side being replaced is retained briefly so the switch can be reversed.

Parameters:

  • database_id (String) —

    Database ID.

  • restoration_id (String) —

    Restoration ID.

Returns:

  • (DedicatedDatabaseRestoration)


1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
# File 'lib/appwrite/services/mongo.rb', line 1325

def promote_restoration(
    database_id:,
    restoration_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

    api_path = '/mongo/{databaseId}/restorations/{restorationId}/promotions'
        .gsub('{databaseId}', @client.encode_path(database_id))
        .gsub('{restorationId}', @client.encode_path(restoration_id))

    api_params = {}

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

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

#update(database_id:, name: nil, status: nil, specification: nil, replicas: nil, sync_mode: nil, network_idle_timeout_seconds: nil, network_ip_allowlist: nil, idle_timeout_minutes: nil, pitr: nil, pitr_retention_days: nil, storage_autoscaling: nil, storage_autoscaling_threshold_percent: nil, storage_autoscaling_max_gb: nil, metrics_trace_sample_rate: nil, metrics_slow_query_log_threshold_ms: nil, sql_api_enabled: nil, sql_api_allowed_statements: nil, sql_api_max_rows: nil, sql_api_max_bytes: nil, sql_api_timeout_seconds: nil) ⇒ DedicatedDatabase

Update a dedicated database configuration. All changes are applied with zero downtime. Specification changes (cpu, memory, storage) are handled via rolling cutover. Storage expansion is done online. All other settings are applied in-place.

Parameters:

  • database_id (String) —

    Database ID.

  • name (String) (defaults to: nil) —

    Database display name.

  • status (String) (defaults to: nil) —

    Database status. Allowed values: ready, paused, inactive. Set to "paused" to pause, "ready" to resume (also recovers a failed database whose infrastructure is healthy), or "inactive" to spin down a shared-pool database.

  • specification (String) (defaults to: nil) —

    Specification. Changes cpu, memory, storage, connection ceiling, and node pool based on specification config. Resource changes are applied via rolling cutover with zero downtime.

  • replicas (Integer) (defaults to: nil) —

    Number of high availability replicas (0-5). High availability is enabled when greater than 0.

  • sync_mode (String) (defaults to: nil) —

    Replication sync mode preference. Allowed values: async, sync, quorum.

  • network_idle_timeout_seconds (Integer) (defaults to: nil) —

    Connection idle timeout in seconds (60-86400).

  • network_ip_allowlist (Array) (defaults to: nil) —

    IP addresses/CIDR ranges allowed to connect.

  • idle_timeout_minutes (Integer) (defaults to: nil) —

    Minutes before container scales to zero.

  • [] —

    pitr Enable or disable point-in-time recovery (PITR).

  • pitr_retention_days (Integer) (defaults to: nil) —

    Days to retain PITR data.

  • [] —

    storage_autoscaling Enable automatic storage expansion when usage exceeds threshold.

  • storage_autoscaling_threshold_percent (Integer) (defaults to: nil) —

    Storage usage percentage (50-95) that triggers automatic expansion.

  • storage_autoscaling_max_gb (Integer) (defaults to: nil) —

    Maximum storage size in GB for autoscaling. 0 means no limit.

  • metrics_trace_sample_rate (Float) (defaults to: nil) —

    Fraction of queries to trace (0.0–1.0). Forwarded to the sidecar.

  • metrics_slow_query_log_threshold_ms (Integer) (defaults to: nil) —

    Threshold in ms above which queries are logged as slow. Forwarded to the sidecar.

  • [] —

    sql_api_enabled Enable the SQL API sidecar for this database.

  • sql_api_allowed_statements (Array) (defaults to: nil) —

    Statement types the SQL API accepts. Allowed values: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, TRUNCATE, GRANT, REVOKE.

  • sql_api_max_rows (Integer) (defaults to: nil) —

    Maximum rows returned per SQL API execution (1-1000000).

  • sql_api_max_bytes (Integer) (defaults to: nil) —

    Maximum serialised SQL API result payload in bytes (1024-104857600).

  • sql_api_timeout_seconds (Integer) (defaults to: nil) —

    Per-call SQL API execution timeout in seconds (1-300).

Returns:

  • (DedicatedDatabase)


202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
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
# File 'lib/appwrite/services/mongo.rb', line 202

def update(
    database_id:,
    name: nil,
    status: nil,
    specification: nil,
    replicas: nil,
    sync_mode: nil,
    network_idle_timeout_seconds: nil,
    network_ip_allowlist: nil,
    idle_timeout_minutes: nil,
    pitr: nil,
    pitr_retention_days: nil,
    storage_autoscaling: nil,
    storage_autoscaling_threshold_percent: nil,
    storage_autoscaling_max_gb: nil,
    metrics_trace_sample_rate: nil,
    metrics_slow_query_log_threshold_ms: nil,
    sql_api_enabled: nil,
    sql_api_allowed_statements: nil,
    sql_api_max_rows: nil,
    sql_api_max_bytes: nil,
    sql_api_timeout_seconds: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        name: name,
        status: status,
        specification: specification,
        replicas: replicas,
        syncMode: sync_mode,
        networkIdleTimeoutSeconds: network_idle_timeout_seconds,
        networkIPAllowlist: network_ip_allowlist,
        idleTimeoutMinutes: idle_timeout_minutes,
        pitr: pitr,
        pitrRetentionDays: pitr_retention_days,
        storageAutoscaling: storage_autoscaling,
        storageAutoscalingThresholdPercent: storage_autoscaling_threshold_percent,
        storageAutoscalingMaxGb: storage_autoscaling_max_gb,
        metricsTraceSampleRate: metrics_trace_sample_rate,
        metricsSlowQueryLogThresholdMs: metrics_slow_query_log_threshold_ms,
        sqlApiEnabled: sql_api_enabled,
        sqlApiAllowedStatements: sql_api_allowed_statements,
        sqlApiMaxRows: sql_api_max_rows,
        sqlApiMaxBytes: sql_api_max_bytes,
        sqlApiTimeoutSeconds: sql_api_timeout_seconds,
    }

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

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

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

Update a scheduled backup policy for a dedicated database.

Parameters:

  • database_id (String) —

    Database ID.

  • policy_id (String) —

    Policy ID.

  • name (String) (defaults to: nil) —

    Policy name. Max length: 128 chars.

  • schedule (String) (defaults to: nil) —

    Schedule CRON syntax.

  • retention (Integer) (defaults to: nil) —

    Days to keep backups before deletion.

  • [] —

    enabled Is policy enabled? When disabled, no backups will be taken.

Returns:

  • (BackupPolicy)


533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/appwrite/services/mongo.rb', line 533

def update_backup_policy(
    database_id:,
    policy_id:,
    name: nil,
    schedule: nil,
    retention: nil,
    enabled: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

    api_path = '/mongo/{databaseId}/backups/policies/{policyId}'
        .gsub('{databaseId}', @client.encode_path(database_id))
        .gsub('{policyId}', @client.encode_path(policy_id))

    api_params = {
        name: name,
        schedule: schedule,
        retention: retention,
        enabled: enabled,
    }

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

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

#update_backup_storage(database_id:, provider:, bucket:, access_key:, secret_key:, region: nil, prefix: nil, endpoint: nil) ⇒ DedicatedDatabaseBackupStorage

Configure off-cluster backup storage for a dedicated database. Supports S3, GCS, and Azure Blob Storage destinations. Backups will be stored to the configured destination in addition to on-cluster storage.

Parameters:

  • database_id (String) —

    Database ID.

  • provider (String) —

    Storage provider for off-cluster backups. Allowed values: s3 (Amazon S3 or S3-compatible), gcs (Google Cloud Storage), azure (Azure Blob Storage).

  • bucket (String) —

    Storage bucket or container name.

  • access_key (String) —

    Access key or client ID for authentication.

  • secret_key (String) —

    Secret key or service account JSON for authentication.

  • region (String) (defaults to: nil) —

    Storage region.

  • prefix (String) (defaults to: nil) —

    Object key prefix for backups.

  • endpoint (String) (defaults to: nil) —

    Custom endpoint for S3-compatible storage (e.g. MinIO).

Returns:

  • (DedicatedDatabaseBackupStorage)


628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
# File 'lib/appwrite/services/mongo.rb', line 628

def update_backup_storage(
    database_id:,
    provider:,
    bucket:,
    access_key:,
    secret_key:,
    region: nil,
    prefix: nil,
    endpoint: nil
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

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

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

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

    api_path = '/mongo/{databaseId}/backups/storage'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        provider: provider,
        bucket: bucket,
        region: region,
        prefix: prefix,
        endpoint: endpoint,
        accessKey: access_key,
        secretKey: secret_key,
    }

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

    @client.call(
        method: 'PUT',
        path: api_path,
        headers: api_headers,
        params: api_params,
        response_type: Models::DedicatedDatabaseBackupStorage
    )
end

#update_credentials(database_id:) ⇒ DedicatedDatabaseOperation

Queue a rotation of the primary connection credentials for a dedicated database. A hibernated database is woken by the worker before rotation. List database operations until the returned operation reaches a terminal status, then fetch the database again for the refreshed connection string.

Parameters:

  • database_id (String) —

    Database ID.

Returns:

  • (DedicatedDatabaseOperation)


888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
# File 'lib/appwrite/services/mongo.rb', line 888

def update_credentials(
    database_id:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

    api_path = '/mongo/{databaseId}/credentials'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {}

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

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

#update_maintenance(database_id:, day:, hour_utc:) ⇒ DedicatedDatabase

Update the maintenance window for a dedicated database. Maintenance operations like minor version upgrades will be performed during this window.

Parameters:

  • database_id (String) —

    Database ID.

  • day (String) —

    Day of the week for the maintenance window. Allowed values: sun, mon, tue, wed, thu, fri, sat.

  • hour_utc (Integer) —

    Hour in UTC (0-23) for maintenance window start.

Returns:

  • (DedicatedDatabase)


968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
# File 'lib/appwrite/services/mongo.rb', line 968

def update_maintenance(
    database_id:,
    day:,
    hour_utc:
)
    if database_id.nil? || database_id == ''
        raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
    end

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

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

    api_path = '/mongo/{databaseId}/maintenance'
        .gsub('{databaseId}', @client.encode_path(database_id))

    api_params = {
        day: day,
        hourUtc: hour_utc,
    }

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

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