def set_hosts(sld, tld, hosts):
 opts = salt.utils.namecheap.get_opts('namecheap.domains.dns.setHosts')
 opts['SLD'] = sld
 opts['TLD'] = tld
 i = 1
 for hostrecord in hosts:
  str_i = str(i)
  opts[('HostName' + str_i)] = hostrecord['hostname']
  opts[('RecordType' + str_i)] = hostrecord['recordtype']
  opts[('Address' + str_i)] = hostrecord['address']
  if ('ttl' in hostrecord):
   opts[('TTL' + str_i)] = hostrecord['ttl']
  if ('mxpref' in hostrecord):
   opts[('MXPref' + str_i)] = hostrecord['mxpref']
   opts['EmailType'] = hostrecord['emailtype']
  i += 1
 response_xml = salt.utils.namecheap.post_request(opts)
 if (response_xml is None):
  return False
 dnsresult = response_xml.getElementsByTagName('DomainDNSSetHostsResult')[0]
 return salt.utils.namecheap.string_to_value(dnsresult.getAttribute('IsSuccess'))

def set_hosts ( sld , tld , hosts ) : opts = salt . utils . namecheap . get_opts ( 'namecheap.domains.dns.setHosts' ) opts [ 'SLD' ] = sld opts [ 'TLD' ] = tld i = 1 for hostrecord in hosts : str_i = str ( i ) opts [ ( 'HostName' + str_i ) ] = hostrecord [ 'hostname' ] opts [ ( 'RecordType' + str_i ) ] = hostrecord [ 'recordtype' ] opts [ ( 'Address' + str_i ) ] = hostrecord [ 'address' ] if ( 'ttl' in hostrecord ) : opts [ ( 'TTL' + str_i ) ] = hostrecord [ 'ttl' ] if ( 'mxpref' in hostrecord ) : opts [ ( 'MXPref' + str_i ) ] = hostrecord [ 'mxpref' ] opts [ 'EmailType' ] = hostrecord [ 'emailtype' ] i += 1 response_xml = salt . utils . namecheap . post_request ( opts ) if ( response_xml is None ) : return False dnsresult = response_xml . getElementsByTagName ( 'DomainDNSSetHostsResult' ) [ 0 ] return salt . utils . namecheap . string_to_value ( dnsresult . getAttribute ( 'IsSuccess' ) )
sets dns host records settings for the requested domain .