1# Copyright (c) 2013 Amazon.com, Inc. or its affiliates. 2# All Rights Reserved 3# 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- 10# lowing conditions: 11# 12# The above copyright notice and this permission notice shall be included 13# in all copies or substantial portions of the Software. 14# 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 21# IN THE SOFTWARE. 22 23""" 24Represents an OptionGroup 25""" 26 27from boto.rds.dbsecuritygroup import DBSecurityGroup 28from boto.resultset import ResultSet 29 30 31class OptionGroup(object): 32 """ 33 Represents an RDS option group 34 35 Properties reference available from the AWS documentation at 36 http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_OptionGroup.html 37 38 :ivar connection: :py:class:`boto.rds.RDSConnection` associated with the 39 current object 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 48 non-VPC instances. 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 57 """ 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): 61 self.name = name 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 66 self.vpc_id = vpc_id 67 self.options = [] 68 69 def __repr__(self): 70 return 'OptionGroup:%s' % self.name 71 72 def startElement(self, name, attrs, connection): 73 if name == 'Options': 74 self.options = ResultSet([ 75 ('Options', Option) 76 ]) 77 else: 78 return None 79 80 def endElement(self, name, value, connection): 81 if name == 'OptionGroupName': 82 self.name = value 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 92 else: 93 self.allow_both_vpc_and_nonvpc = False 94 elif name == 'VpcId': 95 self.vpc_id = value 96 else: 97 setattr(self, name, value) 98 99 def delete(self): 100 return self.connection.delete_option_group(self.name) 101 102 103class Option(object): 104 """ 105 Describes a Option for use in an OptionGroup 106 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 117 port. 118 """ 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): 122 self.name = name 123 self.description = description 124 self.permanent = permanent 125 self.persistent = persistent 126 self.port = port 127 self.settings = settings 128 self.db_security_groups = db_security_groups 129 self.vpc_security_groups = vpc_security_groups 130 131 if self.settings is None: 132 self.settings = [] 133 134 if self.db_security_groups is None: 135 self.db_security_groups = [] 136 137 if self.vpc_security_groups is None: 138 self.vpc_security_groups = [] 139 140 def __repr__(self): 141 return 'Option:%s' % self.name 142 143 def startElement(self, name, attrs, connection): 144 if name == 'OptionSettings': 145 self.settings = ResultSet([ 146 ('OptionSettings', OptionSetting) 147 ]) 148 elif name == 'DBSecurityGroupMemberships': 149 self.db_security_groups = ResultSet([ 150 ('DBSecurityGroupMemberships', DBSecurityGroup) 151 ]) 152 elif name == 'VpcSecurityGroupMemberships': 153 self.vpc_security_groups = ResultSet([ 154 ('VpcSecurityGroupMemberships', VpcSecurityGroup) 155 ]) 156 else: 157 return None 158 159 def endElement(self, name, value, connection): 160 if name == 'OptionName': 161 self.name = value 162 elif name == 'OptionDescription': 163 self.description = value 164 elif name == 'Permanent': 165 if value.lower() == 'true': 166 self.permenant = True 167 else: 168 self.permenant = False 169 elif name == 'Persistent': 170 if value.lower() == 'true': 171 self.persistent = True 172 else: 173 self.persistent = False 174 elif name == 'Port': 175 self.port = int(value) 176 else: 177 setattr(self, name, value) 178 179 180class OptionSetting(object): 181 """ 182 Describes a OptionSetting for use in an Option 183 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 194 collection. 195 """ 196 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): 200 self.name = name 201 self.description = description 202 self.value = value 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 209 210 def __repr__(self): 211 return 'OptionSetting:%s' % self.name 212 213 def startElement(self, name, attrs, connection): 214 return None 215 216 def endElement(self, name, value, connection): 217 if name == 'Name': 218 self.name = value 219 elif name == 'Description': 220 self.description = value 221 elif name == 'Value': 222 self.value = 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 234 else: 235 self.is_modifiable = False 236 elif name == 'IsCollection': 237 if value.lower() == 'true': 238 self.is_collection = True 239 else: 240 self.is_collection = False 241 else: 242 setattr(self, name, value) 243 244 245class VpcSecurityGroup(object): 246 """ 247 Describes a VPC security group for use in a OptionGroup 248 """ 249 def __init__(self, vpc_id=None, status=None): 250 self.vpc_id = vpc_id 251 self.status = status 252 253 def __repr__(self): 254 return 'VpcSecurityGroup:%s' % self.vpc_id 255 256 def startElement(self, name, attrs, connection): 257 pass 258 259 def endElement(self, name, value, connection): 260 if name == 'VpcSecurityGroupId': 261 self.vpc_id = value 262 elif name == 'Status': 263 self.status = value 264 else: 265 setattr(self, name, value) 266 267 268class OptionGroupOption(object): 269 """ 270 Describes a OptionGroupOption for use in an OptionGroup 271 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 283 port for the option. 284 :ivar settings: The option settings for this option. 285 :ivar depends_on: List of all options that are prerequisites for this 286 option. 287 """ 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): 292 self.name = name 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 303 304 if self.settings is None: 305 self.settings = [] 306 307 if self.depends_on is None: 308 self.depends_on = [] 309 310 def __repr__(self): 311 return 'OptionGroupOption:%s' % self.name 312 313 def startElement(self, name, attrs, connection): 314 if name == 'OptionGroupOptionSettings': 315 self.settings = ResultSet([ 316 ('OptionGroupOptionSettings', OptionGroupOptionSetting) 317 ]) 318 elif name == 'OptionsDependedOn': 319 self.depends_on = [] 320 else: 321 return None 322 323 def endElement(self, name, value, connection): 324 if name == 'Name': 325 self.name = value 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 337 else: 338 self.permenant = False 339 elif name == 'Persistent': 340 if value.lower() == 'true': 341 self.persistent = True 342 else: 343 self.persistent = False 344 elif name == 'PortRequired': 345 if value.lower() == 'true': 346 self.port_required = True 347 else: 348 self.port_required = False 349 elif name == 'DefaultPort': 350 self.default_port = int(value) 351 else: 352 setattr(self, name, value) 353 354 355class OptionGroupOptionSetting(object): 356 """ 357 Describes a OptionGroupOptionSetting for use in an OptionGroupOption. 358 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 369 collection. 370 """ 371 372 def __init__(self, name=None, description=None, default_value=False, 373 allowed_values=None, apply_type=None, is_modifiable=False): 374 self.name = name 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 380 381 def __repr__(self): 382 return 'OptionGroupOptionSetting:%s' % self.name 383 384 def startElement(self, name, attrs, connection): 385 return None 386 387 def endElement(self, name, value, connection): 388 if name == 'SettingName': 389 self.name = value 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 401 else: 402 self.is_modifiable = False 403 else: 404 setattr(self, name, value) 405