1
# Copyright (c) 2013 Amazon.com, Inc. or its affiliates.
4
# Permission is hereby granted, free of charge, to any person obtaining a
5
# copy of this software and associated documentation files (the
6
# "Software"), to deal in the Software without restriction, including
7
# without limitation the rights to use, copy, modify, merge, publish, dis-
8
# tribute, sublicense, and/or sell copies of the Software, and to permit
9
# persons to whom the Software is furnished to do so, subject to the fol-
12
# The above copyright notice and this permission notice shall be included
13
# in all copies or substantial portions of the Software.
15
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
Represents an OptionGroup
27
from boto.rds.dbsecuritygroup import DBSecurityGroup
28
from boto.resultset import ResultSet
31
class OptionGroup(object):
33
Represents an RDS option group
35
Properties reference available from the AWS documentation at
36
http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_OptionGroup.html
38
:ivar connection: :py:class:`boto.rds.RDSConnection` associated with the
40
:ivar name: Name of the option group
41
:ivar description: The description of the option group
42
:ivar engine_name: The name of the database engine to use
43
:ivar major_engine_version: The major version number of the engine to use
44
:ivar allow_both_vpc_and_nonvpc: Indicates whether this option group can be
45
applied to both VPC and non-VPC instances.
46
The value ``True`` indicates the option
47
group can be applied to both VPC and
49
:ivar vpc_id: If AllowsVpcAndNonVpcInstanceMemberships is 'false', this
50
field is blank. If AllowsVpcAndNonVpcInstanceMemberships is
51
``True`` and this field is blank, then this option group can
52
be applied to both VPC and non-VPC instances. If this field
53
contains a value, then this option group can only be applied
54
to instances that are in the VPC indicated by this field.
55
:ivar options: The list of :py:class:`boto.rds.optiongroup.Option` objects
56
associated with the group
58
def __init__(self, connection=None, name=None, engine_name=None,
59
major_engine_version=None, description=None,
60
allow_both_vpc_and_nonvpc=False, vpc_id=None):
62
self.engine_name = engine_name
63
self.major_engine_version = major_engine_version
64
self.description = description
65
self.allow_both_vpc_and_nonvpc = allow_both_vpc_and_nonvpc
70
return 'OptionGroup:%s' % self.name
72
def startElement(self, name, attrs, connection):
74
self.options = ResultSet([
80
def endElement(self, name, value, connection):
81
if name == 'OptionGroupName':
83
elif name == 'EngineName':
84
self.engine_name = value
85
elif name == 'MajorEngineVersion':
86
self.major_engine_version = value
87
elif name == 'OptionGroupDescription':
88
self.description = value
89
elif name == 'AllowsVpcAndNonVpcInstanceMemberships':
90
if value.lower() == 'true':
91
self.allow_both_vpc_and_nonvpc = True
93
self.allow_both_vpc_and_nonvpc = False
97
setattr(self, name, value)
100
return self.connection.delete_option_group(self.name)
103
class Option(object):
105
Describes a Option for use in an OptionGroup
107
:ivar name: The name of the option
108
:ivar description: The description of the option.
109
:ivar permanent: Indicate if this option is permanent.
110
:ivar persistent: Indicate if this option is persistent.
111
:ivar port: If required, the port configured for this option to use.
112
:ivar settings: The option settings for this option.
113
:ivar db_security_groups: If the option requires access to a port, then
114
this DB Security Group allows access to the port.
115
:ivar vpc_security_groups: If the option requires access to a port, then
116
this VPC Security Group allows access to the
119
def __init__(self, name=None, description=None, permanent=False,
120
persistent=False, port=None, settings=None,
121
db_security_groups=None, vpc_security_groups=None):
123
self.description = description
124
self.permanent = permanent
125
self.persistent = persistent
127
self.settings = settings
128
self.db_security_groups = db_security_groups
129
self.vpc_security_groups = vpc_security_groups
131
if self.settings is None:
134
if self.db_security_groups is None:
135
self.db_security_groups = []
137
if self.vpc_security_groups is None:
138
self.vpc_security_groups = []
141
return 'Option:%s' % self.name
143
def startElement(self, name, attrs, connection):
144
if name == 'OptionSettings':
145
self.settings = ResultSet([
146
('OptionSettings', OptionSetting)
148
elif name == 'DBSecurityGroupMemberships':
149
self.db_security_groups = ResultSet([
150
('DBSecurityGroupMemberships', DBSecurityGroup)
152
elif name == 'VpcSecurityGroupMemberships':
153
self.vpc_security_groups = ResultSet([
154
('VpcSecurityGroupMemberships', VpcSecurityGroup)
159
def endElement(self, name, value, connection):
160
if name == 'OptionName':
162
elif name == 'OptionDescription':
163
self.description = value
164
elif name == 'Permanent':
165
if value.lower() == 'true':
166
self.permenant = True
168
self.permenant = False
169
elif name == 'Persistent':
170
if value.lower() == 'true':
171
self.persistent = True
173
self.persistent = False
175
self.port = int(value)
177
setattr(self, name, value)
180
class OptionSetting(object):
182
Describes a OptionSetting for use in an Option
184
:ivar name: The name of the option that has settings that you can set.
185
:ivar description: The description of the option setting.
186
:ivar value: The current value of the option setting.
187
:ivar default_value: The default value of the option setting.
188
:ivar allowed_values: The allowed values of the option setting.
189
:ivar data_type: The data type of the option setting.
190
:ivar apply_type: The DB engine specific parameter type.
191
:ivar is_modifiable: A Boolean value that, when true, indicates the option
192
setting can be modified from the default.
193
:ivar is_collection: Indicates if the option setting is part of a
197
def __init__(self, name=None, description=None, value=None,
198
default_value=False, allowed_values=None, data_type=None,
199
apply_type=None, is_modifiable=False, is_collection=False):
201
self.description = description
203
self.default_value = default_value
204
self.allowed_values = allowed_values
205
self.data_type = data_type
206
self.apply_type = apply_type
207
self.is_modifiable = is_modifiable
208
self.is_collection = is_collection
211
return 'OptionSetting:%s' % self.name
213
def startElement(self, name, attrs, connection):
216
def endElement(self, name, value, connection):
219
elif name == 'Description':
220
self.description = value
221
elif name == 'Value':
223
elif name == 'DefaultValue':
224
self.default_value = value
225
elif name == 'AllowedValues':
226
self.allowed_values = value
227
elif name == 'DataType':
228
self.data_type = value
229
elif name == 'ApplyType':
230
self.apply_type = value
231
elif name == 'IsModifiable':
232
if value.lower() == 'true':
233
self.is_modifiable = True
235
self.is_modifiable = False
236
elif name == 'IsCollection':
237
if value.lower() == 'true':
238
self.is_collection = True
240
self.is_collection = False
242
setattr(self, name, value)
245
class VpcSecurityGroup(object):
247
Describes a VPC security group for use in a OptionGroup
249
def __init__(self, vpc_id=None, status=None):
254
return 'VpcSecurityGroup:%s' % self.vpc_id
256
def startElement(self, name, attrs, connection):
259
def endElement(self, name, value, connection):
260
if name == 'VpcSecurityGroupId':
262
elif name == 'Status':
265
setattr(self, name, value)
268
class OptionGroupOption(object):
270
Describes a OptionGroupOption for use in an OptionGroup
272
:ivar name: The name of the option
273
:ivar description: The description of the option.
274
:ivar engine_name: Engine name that this option can be applied to.
275
:ivar major_engine_version: Indicates the major engine version that the
276
option is available for.
277
:ivar min_minor_engine_version: The minimum required engine version for the
278
option to be applied.
279
:ivar permanent: Indicate if this option is permanent.
280
:ivar persistent: Indicate if this option is persistent.
281
:ivar port_required: Specifies whether the option requires a port.
282
:ivar default_port: If the option requires a port, specifies the default
284
:ivar settings: The option settings for this option.
285
:ivar depends_on: List of all options that are prerequisites for this
288
def __init__(self, name=None, description=None, engine_name=None,
289
major_engine_version=None, min_minor_engine_version=None,
290
permanent=False, persistent=False, port_required=False,
291
default_port=None, settings=None, depends_on=None):
293
self.description = description
294
self.engine_name = engine_name
295
self.major_engine_version = major_engine_version
296
self.min_minor_engine_version = min_minor_engine_version
297
self.permanent = permanent
298
self.persistent = persistent
299
self.port_required = port_required
300
self.default_port = default_port
301
self.settings = settings
302
self.depends_on = depends_on
304
if self.settings is None:
307
if self.depends_on is None:
311
return 'OptionGroupOption:%s' % self.name
313
def startElement(self, name, attrs, connection):
314
if name == 'OptionGroupOptionSettings':
315
self.settings = ResultSet([
316
('OptionGroupOptionSettings', OptionGroupOptionSetting)
318
elif name == 'OptionsDependedOn':
323
def endElement(self, name, value, connection):
326
elif name == 'Description':
327
self.description = value
328
elif name == 'EngineName':
329
self.engine_name = value
330
elif name == 'MajorEngineVersion':
331
self.major_engine_version = value
332
elif name == 'MinimumRequiredMinorEngineVersion':
333
self.min_minor_engine_version = value
334
elif name == 'Permanent':
335
if value.lower() == 'true':
336
self.permenant = True
338
self.permenant = False
339
elif name == 'Persistent':
340
if value.lower() == 'true':
341
self.persistent = True
343
self.persistent = False
344
elif name == 'PortRequired':
345
if value.lower() == 'true':
346
self.port_required = True
348
self.port_required = False
349
elif name == 'DefaultPort':
350
self.default_port = int(value)
352
setattr(self, name, value)
355
class OptionGroupOptionSetting(object):
357
Describes a OptionGroupOptionSetting for use in an OptionGroupOption.
359
:ivar name: The name of the option that has settings that you can set.
360
:ivar description: The description of the option setting.
361
:ivar value: The current value of the option setting.
362
:ivar default_value: The default value of the option setting.
363
:ivar allowed_values: The allowed values of the option setting.
364
:ivar data_type: The data type of the option setting.
365
:ivar apply_type: The DB engine specific parameter type.
366
:ivar is_modifiable: A Boolean value that, when true, indicates the option
367
setting can be modified from the default.
368
:ivar is_collection: Indicates if the option setting is part of a
372
def __init__(self, name=None, description=None, default_value=False,
373
allowed_values=None, apply_type=None, is_modifiable=False):
375
self.description = description
376
self.default_value = default_value
377
self.allowed_values = allowed_values
378
self.apply_type = apply_type
379
self.is_modifiable = is_modifiable
382
return 'OptionGroupOptionSetting:%s' % self.name
384
def startElement(self, name, attrs, connection):
387
def endElement(self, name, value, connection):
388
if name == 'SettingName':
390
elif name == 'SettingDescription':
391
self.description = value
392
elif name == 'DefaultValue':
393
self.default_value = value
394
elif name == 'AllowedValues':
395
self.allowed_values = value
396
elif name == 'ApplyType':
397
self.apply_type = value
398
elif name == 'IsModifiable':
399
if value.lower() == 'true':
400
self.is_modifiable = True
402
self.is_modifiable = False
404
setattr(self, name, value)