cloudns_sdk.mail
1class MailForwardingAPI: 2 """ 3 Provides methods for managing mail forwarding settings for domains. 4 5 This class facilitates operations related to adding, modifying, deleting, listing, and 6 managing the status of mail forwards for specific domains. 7 8 Args: 9 auth_params (callable): Function or callable object that provides authentication parameters for API requests. 10 make_request (callable): Function or callable object that executes HTTP requests to the API. 11 12 Methods: 13 get_mail_forward_stats(): 14 Retrieves statistics for mail forwarding. 15 16 get_mail_forward_servers(): 17 Retrieves available mail forwarding servers. 18 19 add_mail_forward(domain_name, box='', host='', destination=''): 20 Adds a new mail forward for a domain. 21 22 modify_mail_forward(domain_name, box='', host='', destination='', mail_forward_id=None): 23 Modifies an existing mail forward for a domain. 24 25 delete_mail_forward(domain_name, mail_forward_id): 26 Deletes a mail forward for a domain. 27 28 list_mail_forwards(domain_name): 29 Lists all mail forwards for a specific domain. 30 31 change_mail_forward_status(domain_name, mail_forward_id, status=True): 32 Changes the status of a mail forward for a domain. 33 34 """ 35 def __init__(self, auth_params, make_request): 36 self._auth_params = auth_params 37 self.make_request = make_request 38 39 def get_mail_forward_stats(self): 40 """ 41 Retrieves statistics for mail forwarding. 42 43 Returns: 44 dict: Response from the API containing statistics for mail forwarding. 45 """ 46 params = self._auth_params() 47 return self.make_request('dns/get-mail-forwards-stats.json', method='GET', params=params) 48 49 def get_mail_forward_servers(self): 50 """ 51 Retrieves available mail forwarding servers. 52 53 Returns: 54 dict: Response from the API containing available mail forwarding servers. 55 """ 56 params = self._auth_params() 57 return self.make_request('dns/get-mailforward-servers.json', method='GET', params=params) 58 59 def add_mail_forward(self, domain_name, box='', host='', destination=''): 60 """ 61 Adds a new mail forward for a domain. 62 63 Args: 64 domain_name (str): Domain name for which the mail forward will be added. 65 box (str, optional): Name of the mail box to forward. 66 host (str, optional): Host of the mailbox. Should be empty for main domain name forwarding. 67 destination (str, optional): Email address to which incoming mails will be forwarded. 68 69 Returns: 70 dict: Response from the API indicating success or failure of the operation. 71 """ 72 params = self._auth_params({'domain-name': domain_name, 'box': box, 'host': host, 'destination': destination}) 73 return self.make_request('dns/add-mail-forward.json', method='POST', data=params) 74 75 def modify_mail_forward(self, domain_name, box='', host='', destination='', mail_forward_id=None): 76 """ 77 Modifies an existing mail forward for a domain. 78 79 Args: 80 domain_name (str): Domain name for which the mail forward will be modified. 81 box (str, optional): Name of the mail box to forward. 82 host (str, optional): Host of the mailbox. Should be empty for main domain name forwarding. 83 destination (str, optional): Email address to which incoming mails will be forwarded. 84 mail_forward_id (int, optional): ID of the mail forward to modify. 85 86 Returns: 87 dict: Response from the API indicating success or failure of the modification. 88 """ 89 params = self._auth_params({'domain-name': domain_name, 'box': box, 'host': host, 'destination': destination, 90 'mail-forward-id': mail_forward_id}) 91 return self.make_request('dns/modify-mail-forward.json', method='POST', data=params) 92 93 def delete_mail_forward(self, domain_name, mail_forward_id): 94 """ 95 Deletes a mail forward for a domain. 96 97 Args: 98 domain_name (str): Domain name for which the mail forward will be deleted. 99 mail_forward_id (int): ID of the mail forward to delete. 100 101 Returns: 102 dict: Response from the API indicating success or failure of the deletion. 103 """ 104 params = self._auth_params({'domain-name': domain_name, 'mail-forward-id': mail_forward_id}) 105 return self.make_request('dns/delete-mail-forward.json', method='POST', data=params) 106 107 def list_mail_forwards(self, domain_name): 108 """ 109 Lists all mail forwards for a specific domain. 110 111 Args: 112 domain_name (str): Domain name for which to list mail forwards. 113 114 Returns: 115 dict: Response from the API containing the list of mail forwards for the specified domain. 116 """ 117 params = self._auth_params({'domain-name': domain_name}) 118 return self.make_request('dns/mail-forwards.json', method='GET', params=params) 119 120 def change_mail_forward_status(self, domain_name, mail_forward_id, status=True): 121 """ 122 Changes the status of a mail forward for a domain. 123 124 Args: 125 domain_name (str): Domain name for which the mail forward status will be changed. 126 mail_forward_id (int): ID of the mail forward to modify. 127 status (bool, optional): Desired status of the mail forward. Defaults to True (active). Use False to pause mail forwarding. 128 129 Returns: 130 dict: Response from the API indicating success or failure of changing the mail forward status. 131 """ 132 params = self._auth_params( 133 {'domain-name': domain_name, 'mail-forward-id': mail_forward_id, 'status': 1 if status else 0}) 134 return self.make_request('dns/modify-mail-forward-status.json', method='POST', data=params)
2class MailForwardingAPI: 3 """ 4 Provides methods for managing mail forwarding settings for domains. 5 6 This class facilitates operations related to adding, modifying, deleting, listing, and 7 managing the status of mail forwards for specific domains. 8 9 Args: 10 auth_params (callable): Function or callable object that provides authentication parameters for API requests. 11 make_request (callable): Function or callable object that executes HTTP requests to the API. 12 13 Methods: 14 get_mail_forward_stats(): 15 Retrieves statistics for mail forwarding. 16 17 get_mail_forward_servers(): 18 Retrieves available mail forwarding servers. 19 20 add_mail_forward(domain_name, box='', host='', destination=''): 21 Adds a new mail forward for a domain. 22 23 modify_mail_forward(domain_name, box='', host='', destination='', mail_forward_id=None): 24 Modifies an existing mail forward for a domain. 25 26 delete_mail_forward(domain_name, mail_forward_id): 27 Deletes a mail forward for a domain. 28 29 list_mail_forwards(domain_name): 30 Lists all mail forwards for a specific domain. 31 32 change_mail_forward_status(domain_name, mail_forward_id, status=True): 33 Changes the status of a mail forward for a domain. 34 35 """ 36 def __init__(self, auth_params, make_request): 37 self._auth_params = auth_params 38 self.make_request = make_request 39 40 def get_mail_forward_stats(self): 41 """ 42 Retrieves statistics for mail forwarding. 43 44 Returns: 45 dict: Response from the API containing statistics for mail forwarding. 46 """ 47 params = self._auth_params() 48 return self.make_request('dns/get-mail-forwards-stats.json', method='GET', params=params) 49 50 def get_mail_forward_servers(self): 51 """ 52 Retrieves available mail forwarding servers. 53 54 Returns: 55 dict: Response from the API containing available mail forwarding servers. 56 """ 57 params = self._auth_params() 58 return self.make_request('dns/get-mailforward-servers.json', method='GET', params=params) 59 60 def add_mail_forward(self, domain_name, box='', host='', destination=''): 61 """ 62 Adds a new mail forward for a domain. 63 64 Args: 65 domain_name (str): Domain name for which the mail forward will be added. 66 box (str, optional): Name of the mail box to forward. 67 host (str, optional): Host of the mailbox. Should be empty for main domain name forwarding. 68 destination (str, optional): Email address to which incoming mails will be forwarded. 69 70 Returns: 71 dict: Response from the API indicating success or failure of the operation. 72 """ 73 params = self._auth_params({'domain-name': domain_name, 'box': box, 'host': host, 'destination': destination}) 74 return self.make_request('dns/add-mail-forward.json', method='POST', data=params) 75 76 def modify_mail_forward(self, domain_name, box='', host='', destination='', mail_forward_id=None): 77 """ 78 Modifies an existing mail forward for a domain. 79 80 Args: 81 domain_name (str): Domain name for which the mail forward will be modified. 82 box (str, optional): Name of the mail box to forward. 83 host (str, optional): Host of the mailbox. Should be empty for main domain name forwarding. 84 destination (str, optional): Email address to which incoming mails will be forwarded. 85 mail_forward_id (int, optional): ID of the mail forward to modify. 86 87 Returns: 88 dict: Response from the API indicating success or failure of the modification. 89 """ 90 params = self._auth_params({'domain-name': domain_name, 'box': box, 'host': host, 'destination': destination, 91 'mail-forward-id': mail_forward_id}) 92 return self.make_request('dns/modify-mail-forward.json', method='POST', data=params) 93 94 def delete_mail_forward(self, domain_name, mail_forward_id): 95 """ 96 Deletes a mail forward for a domain. 97 98 Args: 99 domain_name (str): Domain name for which the mail forward will be deleted. 100 mail_forward_id (int): ID of the mail forward to delete. 101 102 Returns: 103 dict: Response from the API indicating success or failure of the deletion. 104 """ 105 params = self._auth_params({'domain-name': domain_name, 'mail-forward-id': mail_forward_id}) 106 return self.make_request('dns/delete-mail-forward.json', method='POST', data=params) 107 108 def list_mail_forwards(self, domain_name): 109 """ 110 Lists all mail forwards for a specific domain. 111 112 Args: 113 domain_name (str): Domain name for which to list mail forwards. 114 115 Returns: 116 dict: Response from the API containing the list of mail forwards for the specified domain. 117 """ 118 params = self._auth_params({'domain-name': domain_name}) 119 return self.make_request('dns/mail-forwards.json', method='GET', params=params) 120 121 def change_mail_forward_status(self, domain_name, mail_forward_id, status=True): 122 """ 123 Changes the status of a mail forward for a domain. 124 125 Args: 126 domain_name (str): Domain name for which the mail forward status will be changed. 127 mail_forward_id (int): ID of the mail forward to modify. 128 status (bool, optional): Desired status of the mail forward. Defaults to True (active). Use False to pause mail forwarding. 129 130 Returns: 131 dict: Response from the API indicating success or failure of changing the mail forward status. 132 """ 133 params = self._auth_params( 134 {'domain-name': domain_name, 'mail-forward-id': mail_forward_id, 'status': 1 if status else 0}) 135 return self.make_request('dns/modify-mail-forward-status.json', method='POST', data=params)
Provides methods for managing mail forwarding settings for domains.
This class facilitates operations related to adding, modifying, deleting, listing, and managing the status of mail forwards for specific domains.
Args: auth_params (callable): Function or callable object that provides authentication parameters for API requests. make_request (callable): Function or callable object that executes HTTP requests to the API.
Methods: get_mail_forward_stats(): Retrieves statistics for mail forwarding.
get_mail_forward_servers():
Retrieves available mail forwarding servers.
add_mail_forward(domain_name, box='', host='', destination=''):
Adds a new mail forward for a domain.
modify_mail_forward(domain_name, box='', host='', destination='', mail_forward_id=None):
Modifies an existing mail forward for a domain.
delete_mail_forward(domain_name, mail_forward_id):
Deletes a mail forward for a domain.
list_mail_forwards(domain_name):
Lists all mail forwards for a specific domain.
change_mail_forward_status(domain_name, mail_forward_id, status=True):
Changes the status of a mail forward for a domain.
40 def get_mail_forward_stats(self): 41 """ 42 Retrieves statistics for mail forwarding. 43 44 Returns: 45 dict: Response from the API containing statistics for mail forwarding. 46 """ 47 params = self._auth_params() 48 return self.make_request('dns/get-mail-forwards-stats.json', method='GET', params=params)
Retrieves statistics for mail forwarding.
Returns: dict: Response from the API containing statistics for mail forwarding.
50 def get_mail_forward_servers(self): 51 """ 52 Retrieves available mail forwarding servers. 53 54 Returns: 55 dict: Response from the API containing available mail forwarding servers. 56 """ 57 params = self._auth_params() 58 return self.make_request('dns/get-mailforward-servers.json', method='GET', params=params)
Retrieves available mail forwarding servers.
Returns: dict: Response from the API containing available mail forwarding servers.
60 def add_mail_forward(self, domain_name, box='', host='', destination=''): 61 """ 62 Adds a new mail forward for a domain. 63 64 Args: 65 domain_name (str): Domain name for which the mail forward will be added. 66 box (str, optional): Name of the mail box to forward. 67 host (str, optional): Host of the mailbox. Should be empty for main domain name forwarding. 68 destination (str, optional): Email address to which incoming mails will be forwarded. 69 70 Returns: 71 dict: Response from the API indicating success or failure of the operation. 72 """ 73 params = self._auth_params({'domain-name': domain_name, 'box': box, 'host': host, 'destination': destination}) 74 return self.make_request('dns/add-mail-forward.json', method='POST', data=params)
Adds a new mail forward for a domain.
Args: domain_name (str): Domain name for which the mail forward will be added. box (str, optional): Name of the mail box to forward. host (str, optional): Host of the mailbox. Should be empty for main domain name forwarding. destination (str, optional): Email address to which incoming mails will be forwarded.
Returns: dict: Response from the API indicating success or failure of the operation.
76 def modify_mail_forward(self, domain_name, box='', host='', destination='', mail_forward_id=None): 77 """ 78 Modifies an existing mail forward for a domain. 79 80 Args: 81 domain_name (str): Domain name for which the mail forward will be modified. 82 box (str, optional): Name of the mail box to forward. 83 host (str, optional): Host of the mailbox. Should be empty for main domain name forwarding. 84 destination (str, optional): Email address to which incoming mails will be forwarded. 85 mail_forward_id (int, optional): ID of the mail forward to modify. 86 87 Returns: 88 dict: Response from the API indicating success or failure of the modification. 89 """ 90 params = self._auth_params({'domain-name': domain_name, 'box': box, 'host': host, 'destination': destination, 91 'mail-forward-id': mail_forward_id}) 92 return self.make_request('dns/modify-mail-forward.json', method='POST', data=params)
Modifies an existing mail forward for a domain.
Args: domain_name (str): Domain name for which the mail forward will be modified. box (str, optional): Name of the mail box to forward. host (str, optional): Host of the mailbox. Should be empty for main domain name forwarding. destination (str, optional): Email address to which incoming mails will be forwarded. mail_forward_id (int, optional): ID of the mail forward to modify.
Returns: dict: Response from the API indicating success or failure of the modification.
94 def delete_mail_forward(self, domain_name, mail_forward_id): 95 """ 96 Deletes a mail forward for a domain. 97 98 Args: 99 domain_name (str): Domain name for which the mail forward will be deleted. 100 mail_forward_id (int): ID of the mail forward to delete. 101 102 Returns: 103 dict: Response from the API indicating success or failure of the deletion. 104 """ 105 params = self._auth_params({'domain-name': domain_name, 'mail-forward-id': mail_forward_id}) 106 return self.make_request('dns/delete-mail-forward.json', method='POST', data=params)
Deletes a mail forward for a domain.
Args: domain_name (str): Domain name for which the mail forward will be deleted. mail_forward_id (int): ID of the mail forward to delete.
Returns: dict: Response from the API indicating success or failure of the deletion.
108 def list_mail_forwards(self, domain_name): 109 """ 110 Lists all mail forwards for a specific domain. 111 112 Args: 113 domain_name (str): Domain name for which to list mail forwards. 114 115 Returns: 116 dict: Response from the API containing the list of mail forwards for the specified domain. 117 """ 118 params = self._auth_params({'domain-name': domain_name}) 119 return self.make_request('dns/mail-forwards.json', method='GET', params=params)
Lists all mail forwards for a specific domain.
Args: domain_name (str): Domain name for which to list mail forwards.
Returns: dict: Response from the API containing the list of mail forwards for the specified domain.
121 def change_mail_forward_status(self, domain_name, mail_forward_id, status=True): 122 """ 123 Changes the status of a mail forward for a domain. 124 125 Args: 126 domain_name (str): Domain name for which the mail forward status will be changed. 127 mail_forward_id (int): ID of the mail forward to modify. 128 status (bool, optional): Desired status of the mail forward. Defaults to True (active). Use False to pause mail forwarding. 129 130 Returns: 131 dict: Response from the API indicating success or failure of changing the mail forward status. 132 """ 133 params = self._auth_params( 134 {'domain-name': domain_name, 'mail-forward-id': mail_forward_id, 'status': 1 if status else 0}) 135 return self.make_request('dns/modify-mail-forward-status.json', method='POST', data=params)
Changes the status of a mail forward for a domain.
Args: domain_name (str): Domain name for which the mail forward status will be changed. mail_forward_id (int): ID of the mail forward to modify. status (bool, optional): Desired status of the mail forward. Defaults to True (active). Use False to pause mail forwarding.
Returns: dict: Response from the API indicating success or failure of changing the mail forward status.