Skip to content

Commit 8b56a58

Browse files
Added documentation for objects/database.py. (#255)
## 📝 Description Added documentation for `objects/database.py`. ## ✔️ How to Test `tox` Ticket: TPT-1923
1 parent 98ebfd2 commit 8b56a58

1 file changed

Lines changed: 157 additions & 2 deletions

File tree

linode_api4/objects/database.py

Lines changed: 157 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33

44
class DatabaseType(Base):
5+
"""
6+
The type of a managed database.
7+
8+
API Documentation: https://www.linode.com/docs/api/databases/#managed-database-type-view
9+
"""
10+
511
api_endpoint = "/databases/types/{id}"
612

713
properties = {
@@ -28,6 +34,16 @@ def _populate(self, json):
2834

2935

3036
class DatabaseEngine(Base):
37+
"""
38+
A managed database engine. The following database engines are available on Linode’s platform:
39+
40+
- MySQL
41+
- PostgreSQL
42+
- MongoDB
43+
44+
API Documentation: https://www.linode.com/docs/api/databases/#managed-database-engine-view
45+
"""
46+
3147
api_endpoint = "/databases/engines/{id}"
3248

3349
properties = {
@@ -70,6 +86,12 @@ class DatabaseBackup(DerivedBase):
7086
def restore(self):
7187
"""
7288
Restore a backup to a Managed Database on your Account.
89+
90+
API Documentation:
91+
92+
- MongoDB: https://www.linode.com/docs/api/databases/#managed-mongodb-database-backup-restore
93+
- MySQL: https://www.linode.com/docs/api/databases/#managed-mysql-database-backup-restore
94+
- PostgreSQL: https://www.linode.com/docs/api/databases/#managed-postgresql-database-backup-restore
7395
"""
7496

7597
return self._client.post(
@@ -78,18 +100,42 @@ def restore(self):
78100

79101

80102
class MySQLDatabaseBackup(DatabaseBackup):
103+
"""
104+
A backup for an accessible Managed MySQL Database.
105+
106+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mysql-database-backup-view
107+
"""
108+
81109
api_endpoint = "/databases/mysql/instances/{database_id}/backups/{id}"
82110

83111

84112
class MongoDBDatabaseBackup(DatabaseBackup):
113+
"""
114+
A backup for an accessible Managed MongoDB Database.
115+
116+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mongodb-database-backup-view
117+
"""
118+
85119
api_endpoint = "/databases/mongodb/instances/{database_id}/backups/{id}"
86120

87121

88122
class PostgreSQLDatabaseBackup(DatabaseBackup):
123+
"""
124+
A backup for an accessible Managed PostgreSQL Database.
125+
126+
API Documentation: https://www.linode.com/docs/api/databases/#managed-postgresql-database-backup-view
127+
"""
128+
89129
api_endpoint = "/databases/postgresql/instances/{database_id}/backups/{id}"
90130

91131

92132
class MySQLDatabase(Base):
133+
"""
134+
An accessible Managed MySQL Database.
135+
136+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mysql-database-view
137+
"""
138+
93139
api_endpoint = "/databases/mysql/instances/{id}"
94140

95141
properties = {
@@ -115,6 +161,16 @@ class MySQLDatabase(Base):
115161

116162
@property
117163
def credentials(self):
164+
"""
165+
Display the root username and password for an accessible Managed MySQL Database.
166+
The Database must have an active status to perform this command.
167+
168+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mysql-database-credentials-view
169+
170+
:returns: MappedObject containing credntials for this DB
171+
:rtype: MappedObject
172+
"""
173+
118174
if not hasattr(self, "_credentials"):
119175
resp = self._client.get(
120176
"{}/credentials".format(MySQLDatabase.api_endpoint), model=self
@@ -125,6 +181,15 @@ def credentials(self):
125181

126182
@property
127183
def ssl(self):
184+
"""
185+
Display the SSL CA certificate for an accessible Managed MySQL Database.
186+
187+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mysql-database-ssl-certificate-view
188+
189+
:returns: MappedObject containing SSL CA certificate for this DB
190+
:rtype: MappedObject
191+
"""
192+
128193
if not hasattr(self, "_ssl"):
129194
resp = self._client.get(
130195
"{}/ssl".format(MySQLDatabase.api_endpoint), model=self
@@ -136,6 +201,11 @@ def ssl(self):
136201
def credentials_reset(self):
137202
"""
138203
Reset the root password for a Managed MySQL Database.
204+
205+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mysql-database-credentials-reset
206+
207+
:returns: Response from the API call to reset credentials
208+
:rtype: dict
139209
"""
140210

141211
self.invalidate()
@@ -148,6 +218,11 @@ def credentials_reset(self):
148218
def patch(self):
149219
"""
150220
Apply security patches and updates to the underlying operating system of the Managed MySQL Database.
221+
222+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mysql-database-patch
223+
224+
:returns: Response from the API call to apply security patches
225+
:rtype: dict
151226
"""
152227

153228
self.invalidate()
@@ -160,8 +235,7 @@ def backup_create(self, label, **kwargs):
160235
"""
161236
Creates a snapshot backup of a Managed MySQL Database.
162237
163-
:param label: The name for this backup
164-
:type label: str
238+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mysql-database-backup-snapshot-create
165239
"""
166240

167241
params = {
@@ -189,6 +263,12 @@ def invalidate(self):
189263

190264

191265
class PostgreSQLDatabase(Base):
266+
"""
267+
An accessible Managed PostgreSQL Database.
268+
269+
API Documentation: https://www.linode.com/docs/api/databases/#managed-postgresql-database-view
270+
"""
271+
192272
api_endpoint = "/databases/postgresql/instances/{id}"
193273

194274
properties = {
@@ -215,6 +295,16 @@ class PostgreSQLDatabase(Base):
215295

216296
@property
217297
def credentials(self):
298+
"""
299+
Display the root username and password for an accessible Managed PostgreSQL Database.
300+
The Database must have an active status to perform this command.
301+
302+
API Documentation: https://www.linode.com/docs/api/databases/#managed-postgresql-database-credentials-view
303+
304+
:returns: MappedObject containing credntials for this DB
305+
:rtype: MappedObject
306+
"""
307+
218308
if not hasattr(self, "_credentials"):
219309
resp = self._client.get(
220310
"{}/credentials".format(PostgreSQLDatabase.api_endpoint),
@@ -226,6 +316,15 @@ def credentials(self):
226316

227317
@property
228318
def ssl(self):
319+
"""
320+
Display the SSL CA certificate for an accessible Managed PostgreSQL Database.
321+
322+
API Documentation: https://www.linode.com/docs/api/databases/#managed-postgresql-database-ssl-certificate-view
323+
324+
:returns: MappedObject containing SSL CA certificate for this DB
325+
:rtype: MappedObject
326+
"""
327+
229328
if not hasattr(self, "_ssl"):
230329
resp = self._client.get(
231330
"{}/ssl".format(PostgreSQLDatabase.api_endpoint), model=self
@@ -237,6 +336,11 @@ def ssl(self):
237336
def credentials_reset(self):
238337
"""
239338
Reset the root password for a Managed PostgreSQL Database.
339+
340+
API Documentation: https://www.linode.com/docs/api/databases/#managed-postgresql-database-credentials-reset
341+
342+
:returns: Response from the API call to reset credentials
343+
:rtype: dict
240344
"""
241345

242346
self.invalidate()
@@ -249,6 +353,11 @@ def credentials_reset(self):
249353
def patch(self):
250354
"""
251355
Apply security patches and updates to the underlying operating system of the Managed PostgreSQL Database.
356+
357+
API Documentation: https://www.linode.com/docs/api/databases/#managed-postgresql-database-patch
358+
359+
:returns: Response from the API call to apply security patches
360+
:rtype: dict
252361
"""
253362

254363
self.invalidate()
@@ -260,6 +369,8 @@ def patch(self):
260369
def backup_create(self, label, **kwargs):
261370
"""
262371
Creates a snapshot backup of a Managed PostgreSQL Database.
372+
373+
API Documentation: https://www.linode.com/docs/api/databases/#managed-postgresql-database-backup-snapshot-create
263374
"""
264375

265376
params = {
@@ -287,6 +398,12 @@ def invalidate(self):
287398

288399

289400
class MongoDBDatabase(Base):
401+
"""
402+
An accessible Managed MongoDB Database.
403+
404+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mongodb-database-view
405+
"""
406+
290407
api_endpoint = "/databases/mongodb/instances/{id}"
291408

292409
properties = {
@@ -315,6 +432,16 @@ class MongoDBDatabase(Base):
315432

316433
@property
317434
def credentials(self):
435+
"""
436+
Display the root username and password for an accessible Managed MongoDB Database.
437+
The Database must have an active status to perform this command.
438+
439+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mongodb-database-credentials-view
440+
441+
:returns: MappedObject containing credntials for this DB
442+
:rtype: MappedObject
443+
"""
444+
318445
if not hasattr(self, "_credentials"):
319446
resp = self._client.get(
320447
"{}/credentials".format(MongoDBDatabase.api_endpoint),
@@ -326,6 +453,15 @@ def credentials(self):
326453

327454
@property
328455
def ssl(self):
456+
"""
457+
Display the SSL CA certificate for an accessible Managed MongoDB Database.
458+
459+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mongodb-database-ssl-certificate-view
460+
461+
:returns: MappedObject containing SSL CA certificate for this DB
462+
:rtype: MappedObject
463+
"""
464+
329465
if not hasattr(self, "_ssl"):
330466
resp = self._client.get(
331467
"{}/ssl".format(MongoDBDatabase.api_endpoint), model=self
@@ -337,6 +473,11 @@ def ssl(self):
337473
def credentials_reset(self):
338474
"""
339475
Reset the root password for a Managed MongoDB Database.
476+
477+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mongodb-database-credentials-reset
478+
479+
:returns: Response from the API call to reset credentials
480+
:rtype: dict
340481
"""
341482

342483
self.invalidate()
@@ -349,6 +490,11 @@ def credentials_reset(self):
349490
def patch(self):
350491
"""
351492
Apply security patches and updates to the underlying operating system of the Managed MongoDB Database.
493+
494+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mongodb-database-patch
495+
496+
:returns: Response from the API call to apply security patches
497+
:rtype: dict
352498
"""
353499

354500
self.invalidate()
@@ -360,6 +506,8 @@ def patch(self):
360506
def backup_create(self, label, **kwargs):
361507
"""
362508
Creates a snapshot backup of a Managed MongoDB Database.
509+
510+
API Documentation: https://www.linode.com/docs/api/databases/#managed-mongodb-database-backup-snapshot-create
363511
"""
364512

365513
params = {
@@ -396,6 +544,9 @@ def invalidate(self):
396544
class Database(Base):
397545
"""
398546
A generic Database instance.
547+
548+
Note: This class does not have a corresponding GET endpoint. For detailed information
549+
about the database, use the .instance() property method instead.
399550
"""
400551

401552
api_endpoint = "/databases/instances/{id}"
@@ -444,3 +595,7 @@ def instance(self):
444595
)
445596

446597
return self._instance
598+
599+
# Since this class doesn't have a corresponding GET endpoint, this prevents an accidental call to the nonexisting endpoint.
600+
def _api_get(self):
601+
return

0 commit comments

Comments
 (0)