Beispiel #1
0
 def contact_info(self, name, api_call_properties={}):
     api_call_properties = self._parse_api_call_properties(api_call_properties)
     _task = {'code': self.fun_codes['contact_info'], 'handle': {'id': str(name), }, }
     task = Helper.convert_json2xml(doc=_task, root='task')
     server_response = self._call(task)
     result = self._contact_parse_response(server_response.find('./result/data/handle'))
     return result
Beispiel #2
0
 def zone_info(self, name, api_call_properties={}):
     api_call_properties = self._parse_api_call_properties(api_call_properties)
     _task = {'code': self.fun_codes['zone_info'], 'zone': {'name': name, }, }
     task = Helper.convert_json2xml(doc=_task, root='task')
     server_response = self._call(task)
     result = self._zone_parse_response(server_response.find('./result/data/zone'))
     return result
Beispiel #3
0
    def domain_transfer_in(self, params, api_call_properties={}):
        api_call_properties = self._parse_api_call_properties(api_call_properties)
        if isinstance(params, dict):
            _task = {
                'code': self.fun_codes['domain_transfer_in'],
                'default': {
                    'ownerc': params['ownerc'],
                    'adminc': params['adminc'],
                    'techc': params['techc'],
                    'zonec': params['zonec'],
                    'nserver': params['nserver'],
                    'confirm_order': int(True),
                },
                'domain': {
                    'name': params['name'],
                    'authinfo': params['authinfo'],
                },
            }
        else:
            pass  # TODO

        task = Helper.convert_json2xml(doc=_task, root='task')
        server_response = self._call(task)
        result = self._domain_parse_response(server_response.find('./result'))
        return result
Beispiel #4
0
    def _call(self, task):
        _request = {'auth': {'user': self.username, 'password': self.password, 'context': self.context, }, 'language': self.language, }

        if self.owner:
            _request['owner'] = self.owner

        request = Helper.convert_json2xml(doc=_request, root='request')
        request.append(task)

        http_data = ET.tostring(request)
        print('==> request', http_data, '\n')

        headers = {'Content-Type': 'application/xml'}

        http_response = requests.post(self.url, data=http_data, headers=headers)

        response_tree = ET.fromstring(http_response.text)
        #response_tree = BeautifulSoup(http_response.text, 'lxml-xml')
        print('==> response', ET.tostring(response_tree), '\n')

        return response_tree
Beispiel #5
0
    def zone_create(self, params, api_call_properties={}):
        api_call_properties = self._parse_api_call_properties(api_call_properties)
        if isinstance(params, dict):
            _task = {
                'code': self.fun_codes['zone_create'],
                'zone': {
                    'name': params['name'],
                    'ns_action': 'complete',
                    'nserver': params['nserver'],
                    'soa': params['soa'],
                    'rr': params['rr'],
                    'www_include': int(False),
                },
            }
        else:
            pass  # TODO

        task = Helper.convert_json2xml(doc=_task, root='task')
        server_response = self._call(task)
        result = self._zone_parse_response(server_response.find('./result'))
        return result
Beispiel #6
0
    def contact_list(self, api_call_properties={}):
        api_call_properties = self._parse_api_call_properties(api_call_properties)
        _task = {
            'code': self.fun_codes['contact_info'],
            'view': {
                'offset': api_call_properties['offset'],
                'limit': api_call_properties['limit'],
                'children': int(api_call_properties['subusers']),
            },
            'order': {
                'key': 'created',
                'mode': 'asc',
            },
        }
        task = Helper.convert_json2xml(doc=_task, root='task')
        server_response = self._call(task)

        result = []
        for object_xml in server_response.findall('./result/data/handle'):
            fields = self._domain_parse_response(object_xml)
            result.append(fields)
        return result