Skip to content

Commit d18b54e

Browse files
Drop support for ScaleGrid databases (#649)
1 parent 26e964f commit d18b54e

File tree

6 files changed

+0
-258
lines changed

6 files changed

+0
-258
lines changed

linode_api4/objects/database.py

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
from dataclasses import dataclass, field
22
from typing import Optional
33

4-
from deprecated import deprecated
5-
64
from linode_api4.objects import (
75
Base,
8-
DerivedBase,
96
JSONObject,
107
MappedObject,
118
Property,
@@ -86,69 +83,6 @@ class DatabasePrivateNetwork(JSONObject):
8683
public_access: Optional[bool] = None
8784

8885

89-
@deprecated(
90-
reason="Backups are not supported for non-legacy database clusters."
91-
)
92-
class DatabaseBackup(DerivedBase):
93-
"""
94-
A generic Managed Database backup.
95-
96-
This class is not intended to be used on its own.
97-
Use the appropriate subclasses for the corresponding database engine. (e.g. MySQLDatabaseBackup)
98-
"""
99-
100-
api_endpoint = ""
101-
derived_url_path = "backups"
102-
parent_id_name = "database_id"
103-
104-
properties = {
105-
"created": Property(is_datetime=True),
106-
"id": Property(identifier=True),
107-
"label": Property(),
108-
"type": Property(),
109-
}
110-
111-
def restore(self):
112-
"""
113-
Restore a backup to a Managed Database on your Account.
114-
115-
API Documentation:
116-
117-
- MySQL: https://techdocs.akamai.com/linode-api/reference/post-databases-mysql-instance-backup-restore
118-
- PostgreSQL: https://techdocs.akamai.com/linode-api/reference/post-databases-postgre-sql-instance-backup-restore
119-
"""
120-
121-
return self._client.post(
122-
"{}/restore".format(self.api_endpoint), model=self
123-
)
124-
125-
126-
@deprecated(
127-
reason="Backups are not supported for non-legacy database clusters."
128-
)
129-
class MySQLDatabaseBackup(DatabaseBackup):
130-
"""
131-
A backup for an accessible Managed MySQL Database.
132-
133-
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-mysql-instance-backup
134-
"""
135-
136-
api_endpoint = "/databases/mysql/instances/{database_id}/backups/{id}"
137-
138-
139-
@deprecated(
140-
reason="Backups are not supported for non-legacy database clusters."
141-
)
142-
class PostgreSQLDatabaseBackup(DatabaseBackup):
143-
"""
144-
A backup for an accessible Managed PostgreSQL Database.
145-
146-
API Documentation: https://techdocs.akamai.com/linode-api/reference/get-databases-postgresql-instance-backup
147-
"""
148-
149-
api_endpoint = "/databases/postgresql/instances/{database_id}/backups/{id}"
150-
151-
15286
@dataclass
15387
class MySQLDatabaseConfigMySQLOptions(JSONObject):
15488
"""
@@ -296,15 +230,13 @@ class MySQLDatabase(Base):
296230
"id": Property(identifier=True),
297231
"label": Property(mutable=True),
298232
"allow_list": Property(mutable=True, unordered=True),
299-
"backups": Property(derived_class=MySQLDatabaseBackup),
300233
"cluster_size": Property(mutable=True),
301234
"created": Property(is_datetime=True),
302235
"encrypted": Property(),
303236
"engine": Property(),
304237
"hosts": Property(),
305238
"port": Property(),
306239
"region": Property(),
307-
"replication_type": Property(),
308240
"ssl_connection": Property(),
309241
"status": Property(volatile=True),
310242
"type": Property(mutable=True),
@@ -393,28 +325,6 @@ def patch(self):
393325
"{}/patch".format(MySQLDatabase.api_endpoint), model=self
394326
)
395327

396-
@deprecated(
397-
reason="Backups are not supported for non-legacy database clusters."
398-
)
399-
def backup_create(self, label, **kwargs):
400-
"""
401-
Creates a snapshot backup of a Managed MySQL Database.
402-
403-
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-databases-mysql-instance-backup
404-
"""
405-
406-
params = {
407-
"label": label,
408-
}
409-
params.update(kwargs)
410-
411-
self._client.post(
412-
"{}/backups".format(MySQLDatabase.api_endpoint),
413-
model=self,
414-
data=params,
415-
)
416-
self.invalidate()
417-
418328
def invalidate(self):
419329
"""
420330
Clear out cached properties.
@@ -464,16 +374,13 @@ class PostgreSQLDatabase(Base):
464374
"id": Property(identifier=True),
465375
"label": Property(mutable=True),
466376
"allow_list": Property(mutable=True, unordered=True),
467-
"backups": Property(derived_class=PostgreSQLDatabaseBackup),
468377
"cluster_size": Property(mutable=True),
469378
"created": Property(is_datetime=True),
470379
"encrypted": Property(),
471380
"engine": Property(),
472381
"hosts": Property(),
473382
"port": Property(),
474383
"region": Property(),
475-
"replication_commit_type": Property(),
476-
"replication_type": Property(),
477384
"ssl_connection": Property(),
478385
"status": Property(volatile=True),
479386
"type": Property(mutable=True),
@@ -563,28 +470,6 @@ def patch(self):
563470
"{}/patch".format(PostgreSQLDatabase.api_endpoint), model=self
564471
)
565472

566-
@deprecated(
567-
reason="Backups are not supported for non-legacy database clusters."
568-
)
569-
def backup_create(self, label, **kwargs):
570-
"""
571-
Creates a snapshot backup of a Managed PostgreSQL Database.
572-
573-
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-databases-postgre-sql-instance-backup
574-
"""
575-
576-
params = {
577-
"label": label,
578-
}
579-
params.update(kwargs)
580-
581-
self._client.post(
582-
"{}/backups".format(PostgreSQLDatabase.api_endpoint),
583-
model=self,
584-
data=params,
585-
)
586-
self.invalidate()
587-
588473
def invalidate(self):
589474
"""
590475
Clear out cached properties.

test/fixtures/databases_mysql_instances_123_backups.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/fixtures/databases_mysql_instances_123_backups_456_restore.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/fixtures/databases_postgresql_instances_123_backups.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/fixtures/databases_postgresql_instances_123_backups_456_restore.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/unit/objects/database_test.py

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -116,63 +116,6 @@ def test_update(self):
116116
m.call_data["private_network"]["public_access"], True
117117
)
118118

119-
def test_list_backups(self):
120-
"""
121-
Test that MySQL backups list properly
122-
"""
123-
124-
db = MySQLDatabase(self.client, 123)
125-
backups = db.backups
126-
127-
self.assertEqual(len(backups), 1)
128-
129-
self.assertEqual(backups[0].id, 456)
130-
self.assertEqual(
131-
backups[0].label, "Scheduled - 02/04/22 11:11 UTC-XcCRmI"
132-
)
133-
self.assertEqual(backups[0].type, "auto")
134-
135-
def test_create_backup(self):
136-
"""
137-
Test that MySQL database backups can be updated
138-
"""
139-
140-
with self.mock_post("/databases/mysql/instances/123/backups") as m:
141-
db = MySQLDatabase(self.client, 123)
142-
143-
# We don't care about errors here; we just want to
144-
# validate the request.
145-
try:
146-
db.backup_create("mybackup", target="standby")
147-
except Exception as e:
148-
logger.warning(
149-
"An error occurred while validating the request: %s", e
150-
)
151-
152-
self.assertEqual(m.method, "post")
153-
self.assertEqual(
154-
m.call_url, "/databases/mysql/instances/123/backups"
155-
)
156-
self.assertEqual(m.call_data["label"], "mybackup")
157-
self.assertEqual(m.call_data["target"], "standby")
158-
159-
def test_backup_restore(self):
160-
"""
161-
Test that MySQL database backups can be restored
162-
"""
163-
164-
with self.mock_post(
165-
"/databases/mysql/instances/123/backups/456/restore"
166-
) as m:
167-
db = MySQLDatabase(self.client, 123)
168-
169-
db.backups[0].restore()
170-
171-
self.assertEqual(m.method, "post")
172-
self.assertEqual(
173-
m.call_url, "/databases/mysql/instances/123/backups/456/restore"
174-
)
175-
176119
def test_patch(self):
177120
"""
178121
Test MySQL Database patching logic.
@@ -383,64 +326,6 @@ def test_update(self):
383326
m.call_data["private_network"]["public_access"], True
384327
)
385328

386-
def test_list_backups(self):
387-
"""
388-
Test that PostgreSQL backups list properly
389-
"""
390-
391-
db = PostgreSQLDatabase(self.client, 123)
392-
backups = db.backups
393-
394-
self.assertEqual(len(backups), 1)
395-
396-
self.assertEqual(backups[0].id, 456)
397-
self.assertEqual(
398-
backups[0].label, "Scheduled - 02/04/22 11:11 UTC-XcCRmI"
399-
)
400-
self.assertEqual(backups[0].type, "auto")
401-
402-
def test_create_backup(self):
403-
"""
404-
Test that PostgreSQL database backups can be created
405-
"""
406-
407-
with self.mock_post("/databases/postgresql/instances/123/backups") as m:
408-
db = PostgreSQLDatabase(self.client, 123)
409-
410-
# We don't care about errors here; we just want to
411-
# validate the request.
412-
try:
413-
db.backup_create("mybackup", target="standby")
414-
except Exception as e:
415-
logger.warning(
416-
"An error occurred while validating the request: %s", e
417-
)
418-
419-
self.assertEqual(m.method, "post")
420-
self.assertEqual(
421-
m.call_url, "/databases/postgresql/instances/123/backups"
422-
)
423-
self.assertEqual(m.call_data["label"], "mybackup")
424-
self.assertEqual(m.call_data["target"], "standby")
425-
426-
def test_backup_restore(self):
427-
"""
428-
Test that PostgreSQL database backups can be restored
429-
"""
430-
431-
with self.mock_post(
432-
"/databases/postgresql/instances/123/backups/456/restore"
433-
) as m:
434-
db = PostgreSQLDatabase(self.client, 123)
435-
436-
db.backups[0].restore()
437-
438-
self.assertEqual(m.method, "post")
439-
self.assertEqual(
440-
m.call_url,
441-
"/databases/postgresql/instances/123/backups/456/restore",
442-
)
443-
444329
def test_patch(self):
445330
"""
446331
Test PostgreSQL Database patching logic.

0 commit comments

Comments
 (0)