<s> import boto <EOL> from boto . compat import json <EOL> from boto . connection import AWSQueryConnection <EOL> from boto . regioninfo import RegionInfo <EOL> from boto . exception import JSONResponseError <EOL> from boto . route53 . domains import exceptions <EOL> class Route53DomainsConnection ( AWSQueryConnection ) : <EOL> """<STR_LIT:U+0020>""" <EOL> APIVersion = "<STR_LIT>" <EOL> DefaultRegionName = "<STR_LIT>" <EOL> DefaultRegionEndpoint = "<STR_LIT>" <EOL> ServiceName = "<STR_LIT>" <EOL> TargetPrefix = "<STR_LIT>" <EOL> ResponseError = JSONResponseError <EOL> _faults = { <EOL> "<STR_LIT>" : exceptions . DuplicateRequest , <EOL> "<STR_LIT>" : exceptions . DomainLimitExceeded , <EOL> "<STR_LIT>" : exceptions . InvalidInput , <EOL> "<STR_LIT>" : exceptions . OperationLimitExceeded , <EOL> "<STR_LIT>" : exceptions . UnsupportedTLD , <EOL> "<STR_LIT>" : exceptions . TLDRulesViolation , <EOL> } <EOL> def __init__ ( self , ** kwargs ) : <EOL> region = kwargs . pop ( '<STR_LIT>' , None ) <EOL> if not region : <EOL> region = RegionInfo ( self , self . DefaultRegionName , <EOL> self . DefaultRegionEndpoint ) <EOL> if '<STR_LIT:host>' not in kwargs or kwargs [ '<STR_LIT:host>' ] is None : <EOL> kwargs [ '<STR_LIT:host>' ] = region . endpoint <EOL> super ( Route53DomainsConnection , self ) . __init__ ( ** kwargs ) <EOL> self . region = region <EOL> def _required_auth_capability ( self ) : <EOL> return [ '<STR_LIT>' ] <EOL> def check_domain_availability ( self , domain_name , idn_lang_code = None ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : domain_name , } <EOL> if idn_lang_code is not None : <EOL> params [ '<STR_LIT>' ] = idn_lang_code <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def disable_domain_transfer_lock ( self , domain_name ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : domain_name , } <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def enable_domain_transfer_lock ( self , domain_name ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : domain_name , } <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def get_domain_detail ( self , domain_name ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : domain_name , } <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def get_operation_detail ( self , operation_id ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : operation_id , } <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def list_domains ( self , marker = None , max_items = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if marker is not None : <EOL> params [ '<STR_LIT>' ] = marker <EOL> if max_items is not None : <EOL> params [ '<STR_LIT>' ] = max_items <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def list_operations ( self , marker = None , max_items = None ) : <EOL> """<STR_LIT>""" <EOL> params = { } <EOL> if marker is not None : <EOL> params [ '<STR_LIT>' ] = marker <EOL> if max_items is not None : <EOL> params [ '<STR_LIT>' ] = max_items <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def register_domain ( self , domain_name , duration_in_years , admin_contact , <EOL> registrant_contact , tech_contact , idn_lang_code = None , <EOL> auto_renew = None , privacy_protect_admin_contact = None , <EOL> privacy_protect_registrant_contact = None , <EOL> privacy_protect_tech_contact = None ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : domain_name , <EOL> '<STR_LIT>' : duration_in_years , <EOL> '<STR_LIT>' : admin_contact , <EOL> '<STR_LIT>' : registrant_contact , <EOL> '<STR_LIT>' : tech_contact , <EOL> } <EOL> if idn_lang_code is not None : <EOL> params [ '<STR_LIT>' ] = idn_lang_code <EOL> if auto_renew is not None : <EOL> params [ '<STR_LIT>' ] = auto_renew <EOL> if privacy_protect_admin_contact is not None : <EOL> params [ '<STR_LIT>' ] = privacy_protect_admin_contact <EOL> if privacy_protect_registrant_contact is not None : <EOL> params [ '<STR_LIT>' ] = privacy_protect_registrant_contact <EOL> if privacy_protect_tech_contact is not None : <EOL> params [ '<STR_LIT>' ] = privacy_protect_tech_contact <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def retrieve_domain_auth_code ( self , domain_name ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : domain_name , } <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def transfer_domain ( self , domain_name , duration_in_years , nameservers , <EOL> admin_contact , registrant_contact , tech_contact , <EOL> idn_lang_code = None , auth_code = None , auto_renew = None , <EOL> privacy_protect_admin_contact = None , <EOL> privacy_protect_registrant_contact = None , <EOL> privacy_protect_tech_contact = None ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : domain_name , <EOL> '<STR_LIT>' : duration_in_years , <EOL> '<STR_LIT>' : nameservers , <EOL> '<STR_LIT>' : admin_contact , <EOL> '<STR_LIT>' : registrant_contact , <EOL> '<STR_LIT>' : tech_contact , <EOL> } <EOL> if idn_lang_code is not None : <EOL> params [ '<STR_LIT>' ] = idn_lang_code <EOL> if auth_code is not None : <EOL> params [ '<STR_LIT>' ] = auth_code <EOL> if auto_renew is not None : <EOL> params [ '<STR_LIT>' ] = auto_renew <EOL> if privacy_protect_admin_contact is not None : <EOL> params [ '<STR_LIT>' ] = privacy_protect_admin_contact <EOL> if privacy_protect_registrant_contact is not None : <EOL> params [ '<STR_LIT>' ] = privacy_protect_registrant_contact <EOL> if privacy_protect_tech_contact is not None : <EOL> params [ '<STR_LIT>' ] = privacy_protect_tech_contact <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def update_domain_contact ( self , domain_name , admin_contact = None , <EOL> registrant_contact = None , tech_contact = None ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : domain_name , } <EOL> if admin_contact is not None : <EOL> params [ '<STR_LIT>' ] = admin_contact <EOL> if registrant_contact is not None : <EOL> params [ '<STR_LIT>' ] = registrant_contact <EOL> if tech_contact is not None : <EOL> params [ '<STR_LIT>' ] = tech_contact <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def update_domain_contact_privacy ( self , domain_name , admin_privacy = None , <EOL> registrant_privacy = None , <EOL> tech_privacy = None ) : <EOL> """<STR_LIT>""" <EOL> params = { '<STR_LIT>' : domain_name , } <EOL> if admin_privacy is not None : <EOL> params [ '<STR_LIT>' ] = admin_privacy <EOL> if registrant_privacy is not None : <EOL> params [ '<STR_LIT>' ] = registrant_privacy <EOL> if tech_privacy is not None : <EOL> params [ '<STR_LIT>' ] = tech_privacy <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def update_domain_nameservers ( self , domain_name , nameservers ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : domain_name , <EOL> '<STR_LIT>' : nameservers , <EOL> } <EOL> return self . make_request ( action = '<STR_LIT>' , <EOL> body = json . dumps ( params ) ) <EOL> def make_request ( self , action , body ) : <EOL> headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' % ( self . TargetPrefix , action ) , <EOL> '<STR_LIT>' : self . region . endpoint , <EOL> '<STR_LIT:Content-Type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : str ( len ( body ) ) , <EOL> } <EOL> http_request = self . build_base_http_request ( <EOL> method = '<STR_LIT:POST>' , path = '<STR_LIT:/>' , auth_path = '<STR_LIT:/>' , params = { } , <EOL> headers = headers , data = body ) <EOL> response = self . _mexe ( http_request , sender = None , <EOL> override_num_retries = <NUM_LIT:10> ) <EOL> response_body = response . read ( ) . decode ( '<STR_LIT:utf-8>' ) <EOL> boto . log . debug ( response_body ) <EOL> if response . status == <NUM_LIT:200> : <EOL> if response_body : <EOL> return json . loads ( response_body ) <EOL> else : <EOL> json_body = json . loads ( response_body ) <EOL> fault_name = json_body . get ( '<STR_LIT>' , None ) <EOL> exception_class = self . _faults . get ( fault_name , self . ResponseError ) <EOL> raise exception_class ( response . status , response . reason , <EOL> body = json_body ) </s>
