2015-01-18 20:38:10 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2017-01-12 02:02:51 +00:00
|
|
|
from jinja2 import Template
|
2015-01-18 20:38:10 +00:00
|
|
|
from werkzeug.exceptions import BadRequest
|
|
|
|
|
|
|
|
|
|
|
|
class RDSClientError(BadRequest):
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2015-01-18 20:38:10 +00:00
|
|
|
def __init__(self, code, message):
|
|
|
|
super(RDSClientError, self).__init__()
|
2017-01-12 02:02:51 +00:00
|
|
|
template = Template("""
|
|
|
|
<RDSClientError>
|
|
|
|
<Error>
|
|
|
|
<Code>{{ code }}</Code>
|
|
|
|
<Message>{{ message }}</Message>
|
|
|
|
<Type>Sender</Type>
|
|
|
|
</Error>
|
|
|
|
<RequestId>6876f774-7273-11e4-85dc-39e55ca848d1</RequestId>
|
|
|
|
</RDSClientError>""")
|
|
|
|
self.description = template.render(code=code, message=message)
|
2015-01-18 20:38:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DBInstanceNotFoundError(RDSClientError):
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2015-01-18 20:38:10 +00:00
|
|
|
def __init__(self, database_identifier):
|
|
|
|
super(DBInstanceNotFoundError, self).__init__(
|
|
|
|
'DBInstanceNotFound',
|
|
|
|
"Database {0} not found.".format(database_identifier))
|
|
|
|
|
|
|
|
|
2017-06-20 20:51:25 +00:00
|
|
|
class DBSnapshotNotFoundError(RDSClientError):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(DBSnapshotNotFoundError, self).__init__(
|
|
|
|
'DBSnapshotNotFound',
|
|
|
|
"DBSnapshotIdentifier does not refer to an existing DB snapshot.")
|
|
|
|
|
|
|
|
|
2015-01-18 20:38:10 +00:00
|
|
|
class DBSecurityGroupNotFoundError(RDSClientError):
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2015-01-18 20:38:10 +00:00
|
|
|
def __init__(self, security_group_name):
|
|
|
|
super(DBSecurityGroupNotFoundError, self).__init__(
|
|
|
|
'DBSecurityGroupNotFound',
|
|
|
|
"Security Group {0} not found.".format(security_group_name))
|
|
|
|
|
|
|
|
|
|
|
|
class DBSubnetGroupNotFoundError(RDSClientError):
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2015-01-18 20:38:10 +00:00
|
|
|
def __init__(self, subnet_group_name):
|
|
|
|
super(DBSubnetGroupNotFoundError, self).__init__(
|
|
|
|
'DBSubnetGroupNotFound',
|
|
|
|
"Subnet Group {0} not found.".format(subnet_group_name))
|
2015-01-19 06:03:14 +00:00
|
|
|
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2017-01-12 02:02:51 +00:00
|
|
|
class DBParameterGroupNotFoundError(RDSClientError):
|
2017-02-24 02:37:43 +00:00
|
|
|
|
2017-01-12 02:02:51 +00:00
|
|
|
def __init__(self, db_parameter_group_name):
|
|
|
|
super(DBParameterGroupNotFoundError, self).__init__(
|
|
|
|
'DBParameterGroupNotFound',
|
|
|
|
'DB Parameter Group {0} not found.'.format(db_parameter_group_name))
|
2017-08-13 14:27:15 +00:00
|
|
|
|
2017-08-13 14:41:26 +00:00
|
|
|
|
2017-08-13 14:27:15 +00:00
|
|
|
class InvalidDBClusterStateFaultError(RDSClientError):
|
|
|
|
|
|
|
|
def __init__(self, database_identifier):
|
|
|
|
super(InvalidDBClusterStateFaultError, self).__init__(
|
|
|
|
'InvalidDBClusterStateFault',
|
|
|
|
'Invalid DB type, when trying to perform StopDBInstance on {0}e. See AWS RDS documentation on rds.stop_db_instance'.format(database_identifier))
|
|
|
|
|
2017-08-13 14:41:26 +00:00
|
|
|
|
2017-08-13 14:27:15 +00:00
|
|
|
class InvalidDBInstanceStateError(RDSClientError):
|
|
|
|
|
|
|
|
def __init__(self, database_identifier, istate):
|
|
|
|
estate = "in available state" if istate == 'stop' else "stopped, it cannot be started"
|
|
|
|
super(InvalidDBInstanceStateError, self).__init__(
|
|
|
|
'InvalidDBInstanceState',
|
2017-08-14 14:55:09 +00:00
|
|
|
'Instance {} is not {}.'.format(database_identifier, estate))
|
|
|
|
|
|
|
|
|
|
|
|
class SnapshotQuotaExceededError(RDSClientError):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(SnapshotQuotaExceededError, self).__init__(
|
|
|
|
'SnapshotQuotaExceeded',
|
|
|
|
'The request cannot be processed because it would exceed the maximum number of snapshots.')
|
|
|
|
|
|
|
|
|
|
|
|
class DBSnapshotAlreadyExistsError(RDSClientError):
|
|
|
|
|
|
|
|
def __init__(self, database_snapshot_identifier):
|
|
|
|
super(DBSnapshotAlreadyExistsError, self).__init__(
|
|
|
|
'DBSnapshotAlreadyExists',
|
|
|
|
'Cannot create the snapshot because a snapshot with the identifier {} already exists.'.format(database_snapshot_identifier))
|