Esempio n. 1
0
 def request_delete(self, domain: Domain):
     del_req = E.deleteDomainRequest(self._xml_domain(domain),
                                     E.type('delete'))
     self.api_request(data=del_req)
     domain.status = DomainStatus.deleted
     domain.save(update_fields=['status'])
     return _('Domain successfully deleted')
Esempio n. 2
0
 def transfer(self, domain: Domain):
     if domain.epp_code is None:
         raise RegistrarConnectorException('EPP Code is missing')
     contact = domain.contact or domain.service.client
     owner_handle = self.find_or_create_customer(client=contact)
     nameserver_list = self._get_domain_nameservers_as_xml(domain)
     if not nameserver_list:
         raise RegistrarConnectorException(
             _('Nameservers for domain are required'))
     dom_req = E.createDomainRequest(
         self._xml_domain(domain), E.period(domain.registration_period),
         E.authCode(DomainUtils.decode_epp_code(domain.epp_code)),
         E.ownerHandle(owner_handle), E.adminHandle(owner_handle),
         E.techHandle(owner_handle), E.billingHandle(owner_handle),
         E.resellerHandle(''), E.nameServers(E.array(*nameserver_list)))
     response = self.api_request(data=dom_req)
     if response.data.status == 'ACT':
         domain.status = DomainStatus.active
         domain.registration_date = datetime.strptime(
             str(response.data.activationDate), '%Y-%m-%d %H:%M:%S').date()
         domain.expiry_date = datetime.strptime(
             str(response.data.expirationDate), '%Y-%m-%d %H:%M:%S').date()
         domain.epp_code = DomainUtils.encode_epp_code(
             str(response.data.authCode))
         domain.save(update_fields=[
             'status', 'registration_date', 'expiry_date', 'epp_code'
         ])
         return _('Domain transfered')
     elif response.data.status == 'REQ':
         domain.status = DomainStatus.pending
         domain.save(update_fields=['status'])
         return _('Domain pending registration')
     else:
         raise RegistrarConnectorException(_('Domain registration unknown'))
Esempio n. 3
0
 def registrar_unlock(self, domain: Domain) -> str:
     """ Disable the registrar lock (theft protection)."""
     order_id = self.get_active_domain_orderid(domain.name)
     api_params = {'order-id': order_id}
     api_response = self.api_request('POST', self.DISABLE_LOCK_URL, api_params)
     domain.registrar_locked = False
     domain.save(update_fields=['registrar_locked'])
     return self.get_actionstatusdesc(api_response)
Esempio n. 4
0
 def transfer(self, domain: Domain) -> str:
     api_params = self._prepare_register_params(domain, years=1)
     api_params['auth-code'] = DomainUtils.decode_epp_code(domain.epp_code)
     api_response = self.api_request('POST', self.TRANSFER_DOMAIN_URL, api_params)
     message = self.get_actionstatusdesc(api_response)
     domain.status = DomainStatus.active
     domain.save(update_fields=['status'])
     return message
Esempio n. 5
0
 def release_domain(self, domain: Domain) -> str:
     """Delete the order associated with an active domain.
     Release a .uk domain name.
     """
     order_id = self.get_active_domain_orderid(domain.name)
     api_params = {'order-id': order_id}
     if domain.tld == 'uk':
         api_params['new-tag'] = '#VI'  # TODO(tomo): set a proper tag ?
         self.api_request('POST', self.RELEASE_UK_DOMAIN_URL, api_params)
     else:
         self.api_request('POST', self.DELETE_DOMAIN_URL, api_params)
     domain.status = DomainStatus.deleted
     domain.save(update_fields=['status'])
     return _('{} deleted successfully').format(domain.name)
Esempio n. 6
0
    def register(self, domain: Domain) -> (bool, str):
        """ Register a domain name."""
        api_params = self._prepare_register_params(domain, years=domain.registration_period)
        # TODO: Handle .asia .ca .coop .es .nl .pro .ru .us .au and others

        api_response = self.api_request('POST', self.REGISTER_DOMAIN_URL, api_params)
        # TODO(tomo): status can be Success, InvoicePaid and others. Fail if not Success ?
        message = self.get_actionstatusdesc(api_response)
        domain.status = DomainStatus.active

        # TODO: maybe we should set registration and expiry date based on information from registrar
        domain.registration_date = utcnow().date()
        domain.expiry_date = domain.registration_date + relativedelta(years=domain.registration_period)
        domain.save()
        return message
    def registrar_unlock(domain: Domain):
        if domain.status != DomainStatus.active and domain.registrar_locked:
            return False

        domain.registrar_locked = False
        domain.save()

        plugin_dispatcher.call_function(
            'todo',
            'create_todo',
            title=_('Registrar lock deactivated for domain {}').format(domain.name),
            description=_('Registrar lock has been deactivated for domain {}.').format(domain.name),
        )

        return True
    def transfer_domain(domain: Domain):
        if domain.status != DomainStatus.pending_transfer:
            return False

        domain.status = DomainStatus.active
        domain.save()

        plugin_dispatcher.call_function(
            'todo',
            'create_todo',
            title=_('New domain transfer {} order').format(domain.name),
            description=_('A new order to transfer domain {} has been placed.').format(domain.name),
        )

        return True
Esempio n. 9
0
    def renew(self, domain: Domain) -> str:
        domain_name = domain.name
        years = domain.registration_period

        order_details = self.search_orders_by_domain(domain_name, options='OrderDetails')

        api_params = {'order-id': order_details.get('orderid'),
                      'exp-date': order_details.get('endtime'),
                      'years': str(years),
                      'invoice-option': 'NoInvoice'
                      }
        api_response = self.api_request('POST', self.RENEW_DOMAIN_URL, api_params)
        # TODO: maybe we should set expiry date based on information from registrar
        domain.expiry_date = domain.expiry_date + relativedelta(years=domain.registration_period)
        domain.save()
        return self.get_actionstatusdesc(api_response)
    def renew_domain(domain: Domain):
        if domain.status != DomainStatus.active:
            return False

        domain.expiry_date = domain.expiry_date + relativedelta(years=domain.registration_period)
        domain.status = DomainStatus.active
        domain.save()

        plugin_dispatcher.call_function(
            'todo',
            'create_todo',
            title=_('New domain renew {} order').format(domain.name),
            description=_('A new order to renew domain {} has been placed.').format(domain.name),
        )

        return True
Esempio n. 11
0
 def renew(self, domain: Domain) -> str:
     """Renews a domain, adding the domain registration period years to the expiration date"""
     years = domain.registration_period
     json_response = self.api_request(
         request_method=RotldActions.RENEW_DOMAIN,
         params={
             'domain': domain.name,
             'domain_period': years
         })
     response_data = json_response.get('data', {})
     new_expiry_date = response_data.get('expiration_date', None)
     # set the new expiration date based on the one received
     if new_expiry_date:
         new_expiry_date = parser.parse(new_expiry_date)
         domain.expiry_date = new_expiry_date
         domain.save()
     return _('Success')
Esempio n. 12
0
    def register(self, domain: Domain) -> Union[str, dict]:
        """Register a domain name"""
        if domain.status != DomainStatus.pending:
            return _(
                'Cannot register domain that is not pending registration.')
        # check if the domain is available before creating contact and trying to register it
        is_available_for_registration, message = self.check_availability(
            domain=domain)
        if not is_available_for_registration:
            return message
        # try to create the registrant
        try:
            contact_id = self.create_contact(domain=domain)
        except RegistrarConnectorException as e:
            LOG.debug(e)
            return '{}'.format(e)
        params = {
            'domain': domain.name,
            'reservation': 0,  # NOTE: use 1 for reservation
            'c_registrant': contact_id,
            # 'domain_password': generated by rotld api if not provided,
            'domain_period': domain.registration_period
        }
        try:
            json_response = self.api_request(
                request_method=RotldActions.REGISTER_DOMAIN, params=params)
        except RegistrarConnectorException as e:
            LOG.debug(e)
            return '{}'.format(e)
        response_data = json_response.get('data', {})

        domain.status = DomainStatus.active
        domain.registration_date = utcnow().date()
        # set the expiration date based on the one received
        expiration_date = response_data.get('expiration_date', None)
        if expiration_date:
            expiration_date = parser.parse(expiration_date)
            domain.expiry_date = expiration_date
            domain.save()
        return response_data
Esempio n. 13
0
 def get_epp_code(self, domain: Domain):
     response = self._retrieve_domain(domain)
     auth_code = str(response.data.authCode)
     domain.epp_code = DomainUtils.encode_epp_code(auth_code)
     domain.save(update_fields=['epp_code'])
     return auth_code
Esempio n. 14
0
 def restore(self, domain: Domain):
     restore_req = E.restoreDomainRequest(self._xml_domain(domain))
     self.api_request(data=restore_req)
     domain.status = DomainStatus.active
     domain.save(update_fields=['status'])
     return _('Domain restored successfully')