diff --git a/.coveragerc b/.coveragerc index 3c5378a..438fe87 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,5 +3,5 @@ concurrency = multiprocessing parallel = true sigterm = true omit = - hexonet/__init__.py - hexonet/apiconnector/__init__.py + centralnicreseller/__init__.py + centralnicreseller/apiconnector/__init__.py diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cafd040..51fc77f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,7 +13,8 @@ "ms-vscode-remote.remote-containers", "mrmlnc.vscode-apache", "ms-azuretools.vscode-docker", - "eamodio.gitlens" + "eamodio.gitlens", + "GitHub.copilot" ], "settings": { "terminal.integrated.defaultProfile.linux": "zsh", diff --git a/.devcontainer/supporting_files/scripts/post-create.sh b/.devcontainer/supporting_files/scripts/post-create.sh index 113c288..f2ecad0 100755 --- a/.devcontainer/supporting_files/scripts/post-create.sh +++ b/.devcontainer/supporting_files/scripts/post-create.sh @@ -10,7 +10,7 @@ source ~/.zshrc pip install --upgrade pip pip install --upgrade setuptools pip -V -pip install -r requirements.txt +#pip install -r requirements.txt echo "=> Generating Symlinks for Zsh History and Git config" # Create symlink for gitconfig and zsh history file diff --git a/.releaserc.json b/.releaserc.json index 36296e8..6005cb3 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -11,7 +11,7 @@ [ "@semantic-release/exec", { - "prepareCmd": "./scripts/generatedocs.sh && ./scripts/createdistribution.sh", + "prepareCmd": "./scripts/createdistribution.sh", "publishCmd": "./scripts/uploaddistribution_test.sh && ./scripts/uploaddistribution_live.sh" } ], @@ -21,8 +21,8 @@ "replacements": [ { "files": [ - "hexonet/apiconnector/apiclient.py", - "hexonet/apiconnector/__init__.py", + "centralnicreseller/apiconnector/apiclient.py", + "centralnicreseller/apiconnector/__init__.py", "pyproject.toml" ], "from": "\"\\d+\\.\\d+\\.\\d+\"", @@ -40,8 +40,8 @@ "HISTORY.md", "package?(-lock).json", "docs", - "hexonet/apiconnector/__init__.py", - "hexonet/apiconnector/apiclient.py", + "centralnicreseller/apiconnector/__init__.py", + "centralnicreseller/apiconnector/apiclient.py", "htmlcov" ] } @@ -52,8 +52,8 @@ { "assets": [ { - "label": "hexonet.apiconnector (tar.gz)", - "path": "dist/hexonet.apiconnector-${nextRelease.version}.tar.gz" + "label": "centralnicreseller.apiconnector (tar.gz)", + "path": "dist/centralnicreseller.apiconnector-${nextRelease.version}.tar.gz" } ] } diff --git a/AUTHORS.md b/AUTHORS.md index 890a246..5903fe7 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -1,4 +1,4 @@ -> ⚠ This document _only_ reflects the responsible developers at HEXONET GmbH. For a list of MUCH-APPRECIATED CONTRIBUTORS -- people who helped developing and extending this library, applying patches, adding helpful comments +> ⚠ This document _only_ reflects the responsible developers at Team Internet Group PLC. For a list of MUCH-APPRECIATED CONTRIBUTORS -- people who helped developing and extending this library, applying patches, adding helpful comments > and thus generally made it that much better, see [GitHub's list of contributors](https://github.com/centralnicgroup-opensource/rtldev-middleware-python-sdk/contributors). - [Kai Schwarz](//github.com/KaiSchwarz-cnic) - Development Lead diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ac89420..3503508 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,10 +5,6 @@ email, or any other method with the owners of this repository before making a ch Please note we have a code of conduct, please follow it in all your interactions with the project. -## Pull Request Process - -Read [here](https://hexonet-python-sdk.readthedocs.io/en/latest/developmentguide.html#pull-request-pr-procedure). - ## Code of Conduct ### Our Pledge diff --git a/LICENSE b/LICENSE index c65316d..3064713 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 HEXONET +Copyright (c) 2024 CentralNic Reseller, Team Internet Group PLC. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index e3ffd2e..21aa1d2 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,45 @@ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Build Status](https://github.com/centralnicgroup-opensource/rtldev-middleware-python-sdk/workflows/Release/badge.svg?branch=master)](https://github.com/centralnicgroup-opensource/rtldev-middleware-python-sdk/workflows/Release/badge.svg?branch=master) -[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hexonet.apiconnector.svg)](https://www.python.org/) -[![PyPI](https://img.shields.io/pypi/v/hexonet.apiconnector.svg)](https://pypi.org/project/hexonet.apiconnector/) -[![Documentation Status](https://readthedocs.org/projects/hexonet-python-sdk/badge/?version=latest)](https://hexonet-python-sdk.readthedocs.io/en/latest/?badge=latest) +[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/centralnicreseller.apiconnector.svg)](https://www.python.org/) +[![PyPI](https://img.shields.io/pypi/v/centralnicreseller.apiconnector.svg)](https://pypi.org/project/centralnicreseller.apiconnector/) +[![Documentation Status](https://readthedocs.org/projects/centralnicreseller-python-sdk/badge/?version=latest)](https://centralnicreseller-python-sdk.readthedocs.io/en/latest/?badge=latest) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/centralnicgroup-opensource/rtldev-middleware-python-sdk/blob/master/CONTRIBUTING.md) -This module is a connector library for the insanely fast HEXONET Backend API. For further informations visit our [homepage](http://hexonet.net) and do not hesitate to [contact us](https://www.hexonet.net/contact). +This module is a connector library for the insanely fast CentralNic Reseller Backend API. For further informations visit our [homepage](https://www.centralnicreseller.com) and do not hesitate to [contact us](https://www.centralnicreseller.com/contact). + +## Deprecation Notice: Hexonet Python SDK + +This SDK succeeds the deprecated Hexonet Python SDK. It is an enhanced version that builds upon the foundation laid by the Hexonet SDK, offering improved features and performance. Hexonet is migrating to CentralNic Reseller, ensuring continued support and development under the new branding. ## Resources -- Documentation: - - [HEXONET](https://www.hexonet.support/hc/en-gb/articles/13648020541981-Self-Development-Kit-for-Python) +- [Documentation](https://support.centralnicreseller.com/hc/en-gb/articles/5714403954333-Self-Development-Kit-for-Python) - [Release Notes](https://github.com/centralnicgroup-opensource/rtldev-middleware-python-sdk/releases) +## Running the Demo Application + +To run the demo application, follow these steps: + +1. **Set Your Credentials**: Ensure your credentials are available. You can either: + - Replace them directly in the application file. + - Set the environment variables `CNR_TEST_USER` and `CNR_TEST_PASSWORD` in your terminal. + +2. **Execute the Demo**: Once your credentials are set, run the following command in the terminal: + + ```sh + npm run test-demo + ``` + +3. **Update Demo Contents**: If you need to update the contents of the demo file, you can find it at: + + ```plaintext + tests/app.py + ``` + +By following these steps, you can successfully run and update the demo application. + ## Authors List of responsible developers can be found [here](https://github.com/centralnicgroup-opensource/rtldev-middleware-python-sdk/blob/master/AUTHORS.md) diff --git a/hexonet/__init__.py b/centralnicreseller/__init__.py similarity index 100% rename from hexonet/__init__.py rename to centralnicreseller/__init__.py diff --git a/centralnicreseller/apiconnector/__init__.py b/centralnicreseller/apiconnector/__init__.py new file mode 100755 index 0000000..fd07753 --- /dev/null +++ b/centralnicreseller/apiconnector/__init__.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +""" + centralnicreseller.apiconnector + ~~~~~~~~~~~~~~~~~~~~ + A connector library for the insanely fast CentralNicReseller (fka. RRPProxy) Backend API. + :copyright: © 2024 Team Internet Group PLC. + :license: MIT, see LICENSE for more details. +""" + +__version__ = "4.0.3" +name = "centralnicreseller.apiconnector" diff --git a/hexonet/apiconnector/apiclient.py b/centralnicreseller/apiconnector/apiclient.py similarity index 66% rename from hexonet/apiconnector/apiclient.py rename to centralnicreseller/apiconnector/apiclient.py index 610bd3e..8273a5f 100644 --- a/hexonet/apiconnector/apiclient.py +++ b/centralnicreseller/apiconnector/apiclient.py @@ -1,17 +1,18 @@ # -*- coding: utf-8 -*- """ - hexonet.apiconnector.apiclient + centralnicreseller.apiconnector.apiclient ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module covers all necessary functionality for http communicatiton with our Backend System. - :copyright: © 2018 by HEXONET GmbH. + :copyright: © 2024 Team Internet Group PLC. :license: MIT, see LICENSE for more details. """ -from hexonet.apiconnector.logger import Logger -from hexonet.apiconnector.response import Response -from hexonet.apiconnector.responsetemplatemanager import ResponseTemplateManager as RTM -from hexonet.apiconnector.socketconfig import SocketConfig +from centralnicreseller.apiconnector.logger import Logger +from centralnicreseller.apiconnector.response import Response +from centralnicreseller.apiconnector.responsetemplatemanager import ResponseTemplateManager as RTM +from centralnicreseller.apiconnector.socketconfig import SocketConfig +from centralnicreseller.apiconnector.idnaconverter import IDNAConverter from urllib.parse import quote, unquote, urlparse, urlencode from urllib.request import urlopen, Request import re @@ -20,21 +21,21 @@ rtm = RTM() -ISPAPI_CONNECTION_URL_PROXY = "http://127.0.0.1/api/call.cgi" -ISPAPI_CONNECTION_URL_LIVE = "https://api.ispapi.net/api/call.cgi" -ISPAPI_CONNECTION_URL_OTE = "https://api-ote.ispapi.net/api/call.cgi" +CNR_CONNECTION_URL_PROXY = "http://127.0.0.1/api/call.cgi" +CNR_CONNECTION_URL_LIVE = "https://api.rrpproxy.net/api/call.cgi" +CNR_CONNECTION_URL_OTE = "https://api-ote.rrpproxy.net/api/call.cgi" class APIClient(object): def __init__(self): # API connection url - self.setURL(ISPAPI_CONNECTION_URL_LIVE) + self.setURL(CNR_CONNECTION_URL_LIVE) # Object covering API connection data self.__socketConfig = SocketConfig() # activity flag for debug mode self.__debugMode = False # API connection timeout setting - self.__socketTimeout = 300000 + self.__socketTimeout = 300 * 1000 self.useLIVESystem() # user agent setting self.__ua = "" @@ -42,6 +43,10 @@ def __init__(self): self.__curlopts = {} # logger class instance self.setDefaultLogger() + # subuser account name (subuser specific data view) + self.__subUser = None + # login role seperator + self.__roleSeparator = ":" def setCustomLogger(self, logger): """ @@ -114,27 +119,22 @@ def getPOSTData(self, cmd, secured=False): data = self.__socketConfig.getPOSTData() if secured: data = re.sub(r"s_pw=[^&]+", "s_pw=***", data) - tmp = "" - if not isinstance(cmd, str): - for key in sorted(cmd.keys()): - if cmd[key] is not None: - tmp += ("{0}={1}\n").format( - key, re.sub("[\r\n]", "", str(cmd[key])) - ) + + if isinstance(cmd, str): + tmp = cmd.rstrip("\n") else: - tmp = cmd - tmp = tmp.rstrip("\n") + tmp = "\n".join( + "{}={}".format(key, re.sub(r'[\r\n]', '', str(cmd[key]))) + for key in sorted(cmd.keys()) if cmd[key] is not None + ) + if secured: tmp = re.sub(r"PASSWORD=[^\n]+", "PASSWORD=***", tmp) - return ("{0}{1}={2}").format( - data, quote("s_command"), quote(re.sub("\n$", "", tmp)) - ) - def getSession(self): - """ - Get the API Session that is currently set - """ - return self.__socketConfig.getSession() + if tmp: + return f"{data}{quote('s_command')}={quote(tmp)}" + else: + return data if not data.endswith('&') else data.rstrip('&') def getURL(self): """ @@ -190,10 +190,10 @@ def getVersion(self): def saveSession(self, session): """ - Apply session data (session id and system entity) to given client request session + Apply session data (session id and user login) to given client request session """ session["socketcfg"] = { - "entity": self.__socketConfig.getSystemEntity(), + "login": self.__socketConfig.getLogin(), "session": self.__socketConfig.getSession(), } return self @@ -203,8 +203,10 @@ def reuseSession(self, session): Use existing configuration out of session to rebuild and reuse connection settings """ - self.__socketConfig.setSystemEntity(session["socketcfg"]["entity"]) - self.setSession(session["socketcfg"]["session"]) + if not session or "socketcfg" not in session or "login" not in session["socketcfg"] or "session" not in session["socketcfg"]: + return self + self.setCredentials(session["socketcfg"]["login"]) + self.__socketConfig.setSession(session["socketcfg"]["session"]) return self def setURL(self, value): @@ -214,29 +216,14 @@ def setURL(self, value): self.__socketURL = value return self - def setOTP(self, value): + def setPersistent(self): + """echo + Set persistent connection to be used for API communication """ - Set one time password to be used for API communication - """ - self.__socketConfig.setOTP(value) + self.__socketConfig.setPersistent() return self - def setSession(self, value): - """ - Set an API session id to be used for API communication - """ - self.__socketConfig.setSession(value) - return self - - def setRemoteIPAddress(self, value): - """ - Set an Remote IP Address to be used for API communication. - To be used in case you have an active ip filter setting. - """ - self.__socketConfig.setRemoteAddress(value) - return self - - def setCredentials(self, uid, pw): + def setCredentials(self, uid, pw=""): """ Set Credentials to be used for API communication """ @@ -244,37 +231,24 @@ def setCredentials(self, uid, pw): self.__socketConfig.setPassword(pw) return self - def setRoleCredentials(self, uid, role, pw): + def setRoleCredentials(self, uid, role, pw = ""): """ Set Credentials to be used for API communication """ if role == "": return self.setCredentials(uid, pw) - return self.setCredentials(("{0}!{1}").format(uid, role), pw) + return self.setCredentials(("{0}{1}{2}").format(uid, self.__roleSeparator, role), pw) - def login(self, otp=""): + def login(self): """ Perform API login to start session-based communication """ - self.setOTP(otp) - rr = self.request({"COMMAND": "StartSession"}) - if rr.isSuccess(): - col = rr.getColumn("SESSION") - self.setSession(col.getData()[0] if (col is not None) else None) - return rr - - def loginExtended(self, params, otp=""): - """ - Perform API login to start session-based communication. - Use given specific command parameters. - """ - self.setOTP(otp) - cmd = {"COMMAND": "StartSession"} - cmd.update(params) - rr = self.request(cmd) + self.setPersistent() + rr = self.request([], False) + self.__socketConfig.setSession(None) # clean up all session related data if rr.isSuccess(): - col = rr.getColumn("SESSION") - self.setSession(col.getData()[0] if (col is not None) else None) + col = rr.getColumn("SESSIONID") + self.__socketConfig.setSession(col.getData()[0] if (col is not None) else None) return rr def logout(self): @@ -283,21 +257,27 @@ def logout(self): """ rr = self.request( { - "COMMAND": "EndSession", + "COMMAND": "StopSession", } ) if rr.isSuccess(): - self.setSession(None) + self.__socketConfig.setSession(None) # clean up all session related data return rr - def request(self, cmd): + def request(self, cmd=[], setUserView=True): """ Perform API request using the given command """ - # flatten nested api command bulk parameters - newcmd = self.__flattenCommand(cmd) - # auto convert umlaut names to punycode - newcmd = self.__autoIDNConvert(newcmd) + newcmd = {} + if (cmd is not None) and (len(cmd) > 0): + # if subuser is set, add it to the command + if setUserView and self.__subUser is not None: + cmd["SUBUSER"] = self.__subUser + + # flatten nested api command bulk parameters + newcmd = self.__flattenCommand(cmd) + # auto convert umlaut names to punycode + newcmd = self.__autoIDNConvert(newcmd) # request command to API cfg = {"CONNECTION_URL": self.__socketURL} @@ -364,44 +344,42 @@ def setUserView(self, uid): """ Set a data view to a given subuser """ - self.__socketConfig.setUser(uid) + self.__subUser = uid return self def resetUserView(self): """ Reset data view back from subuser to user """ - self.__socketConfig.setUser(None) + self.__subUser = None return self def useHighPerformanceConnectionSetup(self): """ Activate High Performance Setup """ - self.setURL(ISPAPI_CONNECTION_URL_PROXY) + self.setURL(CNR_CONNECTION_URL_PROXY) return self def useDefaultConnectionSetup(self): """ Activate Default Connection Setup (which is the default anyways) """ - self.setURL(ISPAPI_CONNECTION_URL_LIVE) + self.setURL(CNR_CONNECTION_URL_LIVE) return self def useOTESystem(self): """ Set OT&E System for API communication """ - self.setURL(ISPAPI_CONNECTION_URL_OTE) - self.__socketConfig.setSystemEntity("1234") + self.setURL(CNR_CONNECTION_URL_OTE) return self def useLIVESystem(self): """ Set LIVE System for API communication (this is the default setting) """ - self.setURL(ISPAPI_CONNECTION_URL_LIVE) - self.__socketConfig.setSystemEntity("54cd") + self.setURL(CNR_CONNECTION_URL_LIVE) return self def __flattenCommand(self, cmd): @@ -425,32 +403,28 @@ def __flattenCommand(self, cmd): def __autoIDNConvert(self, cmd): """ - Auto convert API command parameters to punycode, if necessary. + Converts domain names in the cmd dictionary to their ASCII (Punycode) representations. """ - # don't convert for convertidn command to avoid endless loop - # and ignore commands in string format(even deprecated) - if isinstance(cmd, str) or re.match( - r"^CONVERTIDN$", cmd["COMMAND"], re.IGNORECASE - ): - return cmd + key_pattern = re.compile(r"(?i)^(NAMESERVER|NS|DNSZONE)([0-9]*)$") + obj_class_pattern = re.compile( + r"(?i)^(DOMAIN(APPLICATION|BLOCKING)?|NAMESERVER|NS|DNSZONE)$") + ascii_pattern = re.compile(r"^[A-Za-z0-9.\-]+$") - toconvert = [] - keys = [] - for key in cmd: - if re.match(r"^(DOMAIN|NAMESERVER|DNSZONE)([0-9]*)$", key, re.IGNORECASE): - keys.append(key) + to_convert = [] idxs = [] - for key in keys: - if not re.match(r"^[a-z0-9.-]+$", cmd[key], re.IGNORECASE): - toconvert.append(cmd[key]) + + for key, val in cmd.items(): + if ((key_pattern.match(key) or + (key.upper() == "OBJECTID" and obj_class_pattern.match(cmd.get("OBJECTCLASS", "")))) + and not ascii_pattern.match(val)): + to_convert.append(val) idxs.append(key) - if not toconvert: - return cmd - - r = self.request({"COMMAND": "ConvertIDN", "DOMAIN": toconvert}) - if r.isSuccess(): - col = r.getColumn("ACE") - if col is not None: - for idx, pc in enumerate(col.getData()): - cmd[idxs[idx]] = pc + + if to_convert: + result = IDNAConverter.convert_list(to_convert) + pc_list = result.get_pc_list() + + for idx, converted_value in zip(idxs, pc_list): + cmd[idx] = converted_value + return cmd diff --git a/hexonet/apiconnector/column.py b/centralnicreseller/apiconnector/column.py similarity index 91% rename from hexonet/apiconnector/column.py rename to centralnicreseller/apiconnector/column.py index e0cf958..fdc9a3c 100644 --- a/hexonet/apiconnector/column.py +++ b/centralnicreseller/apiconnector/column.py @@ -1,14 +1,13 @@ # -*- coding: utf-8 -*- """ - hexonet.apiconnector.column + centralnicreseller.apiconnector.column ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module covers all necessary functionality to work with a column and wrapped data. - :copyright: © 2018 by HEXONET GmbH. + :copyright: © 2024 Team Internet Group PLC. :license: MIT, see LICENSE for more details. """ - class Column(object): """ The Column class covers all you need to access column data of a Backend API response. diff --git a/hexonet/apiconnector/customlogger.py b/centralnicreseller/apiconnector/customlogger.py similarity index 61% rename from hexonet/apiconnector/customlogger.py rename to centralnicreseller/apiconnector/customlogger.py index c77b64b..35e6ff4 100644 --- a/hexonet/apiconnector/customlogger.py +++ b/centralnicreseller/apiconnector/customlogger.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- """ - hexonet.apiconnector.customlogger + centralnicreseller.apiconnector.customlogger ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module provides all necessary functionality for debug outputs - :copyright: © 2020 by HEXONET GmbH. + :copyright: © 2024 Team Internet Group PLC. :license: MIT, see LICENSE for more details. """ -from hexonet.apiconnector.logger import Logger +from centralnicreseller.apiconnector.logger import Logger import sys @@ -27,11 +27,12 @@ def log(self, post, r, error): """ output/log given data """ - # - # implement your own logic here - # + super().log(post, r, error) # Call the parent log method + + # Implement your own logic here + # For example, you can uncomment the following lines to print additional information # print(r.getCommandPlain()) # print(post) # if error: - # print("HTTP communication failed: %s" % (error), sys.stderr) + # print("HTTP communication failed: %s" % (error), file=sys.stderr) # print(r.getPlain()) diff --git a/centralnicreseller/apiconnector/idnaconverter.py b/centralnicreseller/apiconnector/idnaconverter.py new file mode 100644 index 0000000..f7eb021 --- /dev/null +++ b/centralnicreseller/apiconnector/idnaconverter.py @@ -0,0 +1,43 @@ +from centralnicreseller.apiconnector.idnaprocessor import IDNAProcessor +class IDNAConverter: + def __init__(self, idn=None, pc=None, idn_list=None, pc_list=None): + self.idn = idn + self.pc = pc + self.idn_list = idn_list if idn_list is not None else [] + self.pc_list = pc_list if pc_list is not None else [] + + @staticmethod + def convert(domain_name, use_transitional=None): + try: + pc = IDNAProcessor.to_ascii(domain_name, use_transitional) + idn = IDNAProcessor.to_unicode(domain_name, use_transitional) + return IDNAConverter(idn=idn, pc=pc) + except Exception: + return IDNAConverter(idn=domain_name, pc=domain_name) + + @staticmethod + def convert_list(domain_names, use_transitional=None): + idn_results = [] + pc_results = [] + + for domain_name in domain_names: + try: + pc_results.append(IDNAProcessor.to_ascii(domain_name, use_transitional)) + idn_results.append(IDNAProcessor.to_unicode(domain_name, use_transitional)) + except Exception: + pc_results.append(domain_name) + idn_results.append(domain_name) + + return IDNAConverter(idn_list=idn_results, pc_list=pc_results) + + def get_idn(self): + return self.idn + + def get_pc(self): + return self.pc + + def get_idn_list(self): + return self.idn_list + + def get_pc_list(self): + return self.pc_list \ No newline at end of file diff --git a/centralnicreseller/apiconnector/idnaprocessor.py b/centralnicreseller/apiconnector/idnaprocessor.py new file mode 100644 index 0000000..0fcd744 --- /dev/null +++ b/centralnicreseller/apiconnector/idnaprocessor.py @@ -0,0 +1,37 @@ +import idna +import re + +class IDNAProcessor: + NON_TRANSITIONAL_TLDS = re.compile( + r"\.(?:art|be|ca|de|swiss|fr|pm|re|tf|wf|yt)\.?$" + ) + + @staticmethod + def is_transitional_processing(domain_name: str) -> bool: + """ + Determines if the domain name's TLD should use transitional processing. + """ + return bool(IDNAProcessor.NON_TRANSITIONAL_TLDS.search(domain_name)) + + @staticmethod + def to_ascii(domain_name, use_transitional=None): + if use_transitional is None: + use_transitional = IDNAProcessor.is_transitional_processing(domain_name) + try: + if use_transitional: + domain_name = idna.uts46_remap(domain_name, transitional=True) + return idna.encode(domain_name).decode('ascii') + except idna.IDNAError as e: + raise ValueError(f"Unable to translate {domain_name} to ASCII: {e}") + + @staticmethod + def to_unicode(domain_name, use_transitional=None): + if use_transitional is None: + use_transitional = IDNAProcessor.is_transitional_processing(domain_name) + try: + if use_transitional: + return idna.decode(domain_name, uts46=True) + else: + return idna.decode(domain_name) + except idna.IDNAError as e: + raise ValueError(f"Unable to translate {domain_name} to Unicode: {e}") diff --git a/hexonet/apiconnector/logger.py b/centralnicreseller/apiconnector/logger.py similarity index 87% rename from hexonet/apiconnector/logger.py rename to centralnicreseller/apiconnector/logger.py index cecc91a..b3dd3cd 100644 --- a/hexonet/apiconnector/logger.py +++ b/centralnicreseller/apiconnector/logger.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ - hexonet.apiconnector.logger + centralnicreseller.apiconnector.logger ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module provides all necessary functionality for debug outputs see the customlogger class on how to override this - :copyright: © 2018 by HEXONET GmbH. + :copyright: © 2024 Team Internet Group PLC. :license: MIT, see LICENSE for more details. """ diff --git a/hexonet/apiconnector/record.py b/centralnicreseller/apiconnector/record.py similarity index 89% rename from hexonet/apiconnector/record.py rename to centralnicreseller/apiconnector/record.py index 2e202fe..0d9afd2 100644 --- a/hexonet/apiconnector/record.py +++ b/centralnicreseller/apiconnector/record.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ - hexonet.apiconnector.record + centralnicreseller.apiconnector.record ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module covers all necessary functionality to work with a record and wrapped data. - :copyright: © 2018 by HEXONET GmbH. + :copyright: © 2024 Team Internet Group PLC. :license: MIT, see LICENSE for more details. """ diff --git a/hexonet/apiconnector/response.py b/centralnicreseller/apiconnector/response.py similarity index 90% rename from hexonet/apiconnector/response.py rename to centralnicreseller/apiconnector/response.py index d19f480..4b1f814 100755 --- a/hexonet/apiconnector/response.py +++ b/centralnicreseller/apiconnector/response.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- """ - hexonet.apiconnector.response + centralnicreseller.apiconnector.response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module covers all necessary functionality to work with Backend API responses. - :copyright: © 2018 by HEXONET GmbH. + :copyright: © 2024 Team Internet Group PLC. :license: MIT, see LICENSE for more details. """ -from hexonet.apiconnector.responsetemplate import ResponseTemplate as RT -from hexonet.apiconnector.column import Column -from hexonet.apiconnector.record import Record +from centralnicreseller.apiconnector.responsetemplate import ResponseTemplate as RT +from centralnicreseller.apiconnector.column import Column +from centralnicreseller.apiconnector.record import Record import math import re @@ -138,7 +138,8 @@ def getCurrentRecord(self): Get Record of current record index """ return ( - self.__records[self.__recordIndex] if (self.__hasCurrentRecord()) else None + self.__records[self.__recordIndex] if ( + self.__hasCurrentRecord()) else None ) def getFirstRecordIndex(self): @@ -345,3 +346,21 @@ def __hasPreviousRecord(self): current record index in use """ return self.__recordIndex > 0 and self.__hasCurrentRecord() + + def isPending(self): + """ + Check if current operation is returned as pending + """ + # Check if the COMMAND is AddDomain (case-insensitive) + cmd = self.getCommand() + if cmd is None or not cmd.get("COMMAND") or cmd["COMMAND"].lower() != "adddomain": + return False + + # Retrieve the STATUS column and check if its data equals REQUESTED (case-insensitive) + status = self.getColumn("STATUS") + if status: + status_data = status.getDataByIndex(0) + if status_data and status_data.lower() == "requested": + return True + + return False diff --git a/hexonet/apiconnector/responseparser.py b/centralnicreseller/apiconnector/responseparser.py similarity index 62% rename from hexonet/apiconnector/responseparser.py rename to centralnicreseller/apiconnector/responseparser.py index 6458e76..5c3ab06 100644 --- a/hexonet/apiconnector/responseparser.py +++ b/centralnicreseller/apiconnector/responseparser.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- """ - hexonet.apiconnector.responseparser + centralnicreseller.apiconnector.responseparser ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module covers all necessary functionality to parse a raw Backend API response and to serialize it back. - :copyright: © 2018 by HEXONET GmbH. + :copyright: © 2024 Team Internet Group PLC. :license: MIT, see LICENSE for more details. """ @@ -39,20 +39,4 @@ def parse(raw): r["PROPERTY"][prop].append(value) else: r[attr.upper()] = value - return r - - -def serialize(r): - """ - Returns the dictionary represenation serialized back to plain text - """ - d = "" - if "PROPERTY" in r: - keys = sorted(r["PROPERTY"].keys()) - for key in keys: - for index, val in enumerate(r["PROPERTY"][key]): - d += ("\r\nPROPERTY[{0}][{1}]={2}").format(key, index, val) - for prop in ["CODE", "DESCRIPTION", "QUEUETIME", "RUNTIME"]: - if prop in r: - d += ("\r\n{0}={1}").format(prop, r[prop]) - return ("[RESPONSE]{0}\r\nEOF\r\n").format(d) + return r \ No newline at end of file diff --git a/hexonet/apiconnector/responsetemplate.py b/centralnicreseller/apiconnector/responsetemplate.py similarity index 87% rename from hexonet/apiconnector/responsetemplate.py rename to centralnicreseller/apiconnector/responsetemplate.py index 6141eb8..df43c37 100644 --- a/hexonet/apiconnector/responsetemplate.py +++ b/centralnicreseller/apiconnector/responsetemplate.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- """ - hexonet.apiconnector.responsetemplate + centralnicreseller.apiconnector.responsetemplate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module covers all basic functionality to deal with Backend API responses. - :copyright: © 2018 by HEXONET GmbH. + :copyright: © 2024 Team Internet Group PLC. :license: MIT, see LICENSE for more details. """ -import hexonet.apiconnector.responseparser as RP +import centralnicreseller.apiconnector.responseparser as RP class ResponseTemplate(object): @@ -22,7 +22,8 @@ def __init__(self, response=""): self._raw = response if (response == "") or (response is None): descr = "Empty API response. Probably unreachable API end point {CONNECTION_URL}" - self._raw = "[RESPONSE]\r\nCODE=423\r\nDESCRIPTION=%s\r\nEOF\r\n" % (descr) + self._raw = "[RESPONSE]\r\nCODE=423\r\nDESCRIPTION=%s\r\nEOF\r\n" % ( + descr) # try/except to support old versions of python (python2.5) try: @@ -101,12 +102,4 @@ def isTmpError(self): """ Check if current API response represents a temporary error case (4xx) """ - return self.__hash["CODE"][0] == "4" - - def isPending(self): - """ - Check if current operation is returned as pending - """ - if "PENDING" in self.__hash: - return self.__hash["PENDING"] == "1" - return False + return self.__hash["CODE"][0] == "4" \ No newline at end of file diff --git a/hexonet/apiconnector/responsetemplatemanager.py b/centralnicreseller/apiconnector/responsetemplatemanager.py similarity index 88% rename from hexonet/apiconnector/responsetemplatemanager.py rename to centralnicreseller/apiconnector/responsetemplatemanager.py index 2831c79..49c3872 100644 --- a/hexonet/apiconnector/responsetemplatemanager.py +++ b/centralnicreseller/apiconnector/responsetemplatemanager.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- """ - hexonet.apiconnector.responsetemplatemanager + centralnicreseller.apiconnector.responsetemplatemanager ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module covers all functionality to manage response templates. - :copyright: © 2018 by HEXONET GmbH. + :copyright: © 2024 Team Internet Group PLC. :license: MIT, see LICENSE for more details. """ -import hexonet.apiconnector.responseparser as RP -from hexonet.apiconnector.responsetemplate import ResponseTemplate as RT +import centralnicreseller.apiconnector.responseparser as RP +from centralnicreseller.apiconnector.responsetemplate import ResponseTemplate as RT class ResponseTemplateManager(object): @@ -44,7 +44,8 @@ def __new__(cls): "invalid": rtm.generateTemplate( "423", "Invalid API response. Contact Support" ), - "unauthorized": rtm.generateTemplate("530", "Unauthorized"), + "unauthorized": rtm.generateTemplate("500", "Unauthorized"), + "notfound": rtm.generateTemplate("500", "Response Template not found"), } return rtm @@ -76,7 +77,7 @@ def getTemplate(self, id): """ if self.hasTemplate(id): return RT(self.__templates[id]) - return RT(self.generateTemplate("500", "Response Template not found")) + return RT(self.__templates["notfound"]) def getTemplates(self): """ diff --git a/centralnicreseller/apiconnector/socketconfig.py b/centralnicreseller/apiconnector/socketconfig.py new file mode 100644 index 0000000..13421c9 --- /dev/null +++ b/centralnicreseller/apiconnector/socketconfig.py @@ -0,0 +1,89 @@ +# -*- coding: utf-8 -*- +""" + centralnicreseller.apiconnector.socketconfig + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + This module covers all necessary functionality to + pre-configure http communication with our Backend System. + :copyright: © 2024 Team Internet Group PLC. + :license: MIT, see LICENSE for more details. +""" + +from urllib.parse import quote, unquote + + +class SocketConfig(object): + """ + The SocketConfig class helps to configure the http communcation with our Backend System. + """ + + def __init__(self): + # account name + self.__login = None + # account password + self.__pw = None + # API session id + self.__sessionid = None + # API persistent connection for session + self.__persistent = None + + def getPOSTData(self): + """ + Create POST data string out of connection data + """ + data = [] + tpl = "{0}={1}&" + keys = ["__login", "__pw", "__sessionid", "__persistent"] + + for key in keys: + item = getattr(self, "_SocketConfig" + key) + if item: + if key == "__persistent": + data.append(tpl.format(quote(key[2:]), quote(item))) + else: + data.append(tpl.format(quote("s_" + key[2:]), quote(item))) + + return "".join(data) + + def getSession(self): + """ + Get API Session ID in use + """ + return self.__sessionid + + def getLogin(self): + """ + get account login to use + """ + return self.__login + + def setLogin(self, value): + """ + Set account name to use + """ + self.__login = value + return self + + def setPassword(self, value): + """ + Set account password to use + """ + self.__sessionid = None + self.__pw = value + return self + + def setSession(self, value): + """ + Set API Session ID to use + """ + self.__pw = None + self.__persistent = None + self.__sessionid = value + return self + + def setPersistent(self): + """ + Set API persistent connection for session + """ + self.__sessionid = None + self.__persistent = "1" + return self diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index cb0b29b..0000000 --- a/docs/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -PYTHON ?= python3 - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -SPHINXPROJ = hexonet.apiconnector -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/docs/_build/doctrees/api.doctree b/docs/_build/doctrees/api.doctree deleted file mode 100644 index 067aa88..0000000 Binary files a/docs/_build/doctrees/api.doctree and /dev/null differ diff --git a/docs/_build/doctrees/api/hexonet.apiconnector.doctree b/docs/_build/doctrees/api/hexonet.apiconnector.doctree deleted file mode 100644 index 6b43915..0000000 Binary files a/docs/_build/doctrees/api/hexonet.apiconnector.doctree and /dev/null differ diff --git a/docs/_build/doctrees/api/hexonet.doctree b/docs/_build/doctrees/api/hexonet.doctree deleted file mode 100644 index 44075a9..0000000 Binary files a/docs/_build/doctrees/api/hexonet.doctree and /dev/null differ diff --git a/docs/_build/doctrees/changelog.doctree b/docs/_build/doctrees/changelog.doctree deleted file mode 100644 index b5a25ca..0000000 Binary files a/docs/_build/doctrees/changelog.doctree and /dev/null differ diff --git a/docs/_build/doctrees/config.doctree b/docs/_build/doctrees/config.doctree deleted file mode 100644 index 964250e..0000000 Binary files a/docs/_build/doctrees/config.doctree and /dev/null differ diff --git a/docs/_build/doctrees/contactus.doctree b/docs/_build/doctrees/contactus.doctree deleted file mode 100644 index e33222e..0000000 Binary files a/docs/_build/doctrees/contactus.doctree and /dev/null differ diff --git a/docs/_build/doctrees/contributing.doctree b/docs/_build/doctrees/contributing.doctree deleted file mode 100644 index 5bde402..0000000 Binary files a/docs/_build/doctrees/contributing.doctree and /dev/null differ diff --git a/docs/_build/doctrees/debugging.doctree b/docs/_build/doctrees/debugging.doctree deleted file mode 100644 index 890154f..0000000 Binary files a/docs/_build/doctrees/debugging.doctree and /dev/null differ diff --git a/docs/_build/doctrees/developmentguide.doctree b/docs/_build/doctrees/developmentguide.doctree deleted file mode 100644 index d32ab3f..0000000 Binary files a/docs/_build/doctrees/developmentguide.doctree and /dev/null differ diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle deleted file mode 100644 index 81965cd..0000000 Binary files a/docs/_build/doctrees/environment.pickle and /dev/null differ diff --git a/docs/_build/doctrees/foreword.doctree b/docs/_build/doctrees/foreword.doctree deleted file mode 100644 index ca2a98e..0000000 Binary files a/docs/_build/doctrees/foreword.doctree and /dev/null differ diff --git a/docs/_build/doctrees/index.doctree b/docs/_build/doctrees/index.doctree deleted file mode 100644 index c281c9f..0000000 Binary files a/docs/_build/doctrees/index.doctree and /dev/null differ diff --git a/docs/_build/doctrees/installation.doctree b/docs/_build/doctrees/installation.doctree deleted file mode 100644 index d80e473..0000000 Binary files a/docs/_build/doctrees/installation.doctree and /dev/null differ diff --git a/docs/_build/doctrees/license.doctree b/docs/_build/doctrees/license.doctree deleted file mode 100644 index 20a8eee..0000000 Binary files a/docs/_build/doctrees/license.doctree and /dev/null differ diff --git a/docs/_build/doctrees/quickstart.doctree b/docs/_build/doctrees/quickstart.doctree deleted file mode 100644 index a647013..0000000 Binary files a/docs/_build/doctrees/quickstart.doctree and /dev/null differ diff --git a/docs/_build/doctrees/upgrading.doctree b/docs/_build/doctrees/upgrading.doctree deleted file mode 100644 index e7d9358..0000000 Binary files a/docs/_build/doctrees/upgrading.doctree and /dev/null differ diff --git a/docs/_static/hexonet-favicon.ico b/docs/_static/hexonet-favicon.ico deleted file mode 100644 index 78d7f01..0000000 Binary files a/docs/_static/hexonet-favicon.ico and /dev/null differ diff --git a/docs/_static/hexonet.png b/docs/_static/hexonet.png deleted file mode 100644 index 996f5b5..0000000 Binary files a/docs/_static/hexonet.png and /dev/null differ diff --git a/docs/_static/yes.png b/docs/_static/yes.png deleted file mode 100644 index 56917ab..0000000 Binary files a/docs/_static/yes.png and /dev/null differ diff --git a/docs/api.rst b/docs/api.rst deleted file mode 100644 index ec9f5b5..0000000 --- a/docs/api.rst +++ /dev/null @@ -1,11 +0,0 @@ -.. _api: - -SDK Documentation -================= - -Information on specific functions, classes, and methods. - -.. toctree:: - :glob: - - api/* diff --git a/docs/api/hexonet.apiconnector.rst b/docs/api/hexonet.apiconnector.rst deleted file mode 100644 index 2fe4f7d..0000000 --- a/docs/api/hexonet.apiconnector.rst +++ /dev/null @@ -1,70 +0,0 @@ -hexonet.apiconnector package -============================ - -.. automodule:: hexonet.apiconnector - :members: - :undoc-members: - :show-inheritance: - -Submodules ----------- - - -.. automodule:: hexonet.apiconnector.apiclient - :members: - :undoc-members: - :show-inheritance: - - -.. automodule:: hexonet.apiconnector.column - :members: - :undoc-members: - :show-inheritance: - - -.. automodule:: hexonet.apiconnector.customlogger - :members: - :undoc-members: - :show-inheritance: - - -.. automodule:: hexonet.apiconnector.logger - :members: - :undoc-members: - :show-inheritance: - - -.. automodule:: hexonet.apiconnector.record - :members: - :undoc-members: - :show-inheritance: - - -.. automodule:: hexonet.apiconnector.response - :members: - :undoc-members: - :show-inheritance: - - -.. automodule:: hexonet.apiconnector.responseparser - :members: - :undoc-members: - :show-inheritance: - - -.. automodule:: hexonet.apiconnector.responsetemplate - :members: - :undoc-members: - :show-inheritance: - - -.. automodule:: hexonet.apiconnector.responsetemplatemanager - :members: - :undoc-members: - :show-inheritance: - - -.. automodule:: hexonet.apiconnector.socketconfig - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/api/hexonet.rst b/docs/api/hexonet.rst deleted file mode 100644 index 21270c3..0000000 --- a/docs/api/hexonet.rst +++ /dev/null @@ -1,15 +0,0 @@ -hexonet package -=============== - -.. automodule:: hexonet - :members: - :undoc-members: - :show-inheritance: - -Subpackages ------------ - -.. toctree:: - :maxdepth: 2 - - hexonet.apiconnector diff --git a/docs/changelog.rst b/docs/changelog.rst deleted file mode 100644 index 8893214..0000000 --- a/docs/changelog.rst +++ /dev/null @@ -1,7 +0,0 @@ -.. _changelog: - -Changelog -========= - -.. mdinclude:: ../HISTORY.md -.. mdinclude:: ../HISTORY.old.md diff --git a/docs/conf.py b/docs/conf.py deleted file mode 100644 index bf9e881..0000000 --- a/docs/conf.py +++ /dev/null @@ -1,83 +0,0 @@ -# -*- coding: utf-8 -*- - -import sys -import os -import io -import re - -sys.path.append("~/.local/lib") - - -def read(*names, **kwargs): - with io.open( - os.path.join(os.path.dirname(__file__), *names), - encoding=kwargs.get("encoding", "utf8"), - ) as fp: - return fp.read() - - -def find_version(*file_paths): - version_file = read(*file_paths) - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) - if version_match: - return version_match.group(1) - raise RuntimeError("Unable to find version string.") - - -# Project -------------------------------------------------------------- - - -project = "hexonet.apiconnector" -copyright = "2023 by HEXONET" -author = "Kai Schwarz" -version = find_version("..", "hexonet", "apiconnector", "__init__.py") -release = re.sub(r"\.[0-9]+$", "", version) - -# General -------------------------------------------------------------- - -master_doc = "index" - -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.intersphinx", - "sphinxcontrib.log_cabinet", - "m2r2", - "sphinx_rtd_theme" -] -exclude_patterns = ["_build", "/docs/api/*.rst"] - -source_suffix = [".rst", ".md"] - -intersphinx_mapping = {} - -html_theme = "sphinx_rtd_theme" - -# sphinx_rtd_theme config options -# https://sphinx-rtd-theme.readthedocs.io/en/stable/configuring.html#theme-options -html_theme_options = { - 'logo_only': False, - 'display_version': True, - 'prev_next_buttons_location': 'bottom', - 'style_external_links': False, - 'vcs_pageview_mode': '', - 'style_nav_header_background': 'white', - # Toc options - 'collapse_navigation': True, - 'sticky_navigation': True, - 'navigation_depth': 4, - 'includehidden': True, - 'titles_only': False -} - -html_sidebars = { - "**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"] -} - -html_static_path = ["_static"] -html_favicon = "_static/hexonet-favicon.ico" -html_logo = "_static/hexonet.png" -html_show_sourcelink = True - -# linkcheck ------------------------------------------------------------ - -linkcheck_anchors = False diff --git a/docs/config.rst b/docs/config.rst deleted file mode 100644 index 65a79a8..0000000 --- a/docs/config.rst +++ /dev/null @@ -1,70 +0,0 @@ -.. _config: - -Configuration Handling -====================== - -Applications need some kind of configuration. There are different settings -you might want to change depending on the application environment like -toggling the debug mode, setting credentials etc. - -The way hexonet.apiconnector is designed usually requires the configuration -to be provided at runtime when connecting to the HEXONET Backend API. You -can hardcode the configuration in the code, which for many small scripts is -for sure sufficient. Realtime applications and frontends need to cover some -application logic around using this SDK like a login form and session -management. - - -Configuration Basics --------------------- - -The configuration can be provided in two ways. -Using the :class:`~hexonet.apiconnector.APIClient`: - -.. literalinclude:: app.py - :language: python - :encoding: utf-8 - :caption: Python SDK Demo App - -Environment and Debug Features ------------------------------- - -Debug Features are also available in our Python SDK:: - - # activate debug mode - cl.enableDebugMode() - - # disable debug mode - cl.disableDebugMode() - -HEXONET provides two different Backend Systems that you might consider to use. -Both require a separate Registration: -- `Live System Registration `_ and -- `OT&E System Registration `_. - -OT&E System -^^^^^^^^^^^ - -OT&E Sytem stands for Operational Test & Evaluation System. -No costs, just for playing around with things. This system can be seen as a -kind of sandbox system that allows to test your integration first before going -live with it. This system and the use of our products and services is -completely free of charge. -To use this system, use APIClient's method `cl.useOTESystem()`. -Otherwise Live System will be used by default. - -LIVE System -^^^^^^^^^^^ - -The real world system - This system and the use our services and products can -lead to real costs depending on what you're exactly doing. -Live System will be used by default, but you can also use APIClient's method -`cl.useLIVESystem()` to add it in source code for reference. - -Builtin Configuration Values ----------------------------- - -The following configuration values are used internally by hexonet.apiconnector: - -Up to now - none, but this might change in future as we are continously -improving our SDKs. diff --git a/docs/contactus.rst b/docs/contactus.rst deleted file mode 100644 index eb8220b..0000000 --- a/docs/contactus.rst +++ /dev/null @@ -1,25 +0,0 @@ -.. _contact-us: - -Contact Us -========== - -There are several possibilities to get in touch with us, we list them -in our preferred order. - -- `Slack`_ - -- `Stack Overflow`_ - -- The listed authors in :ref:`authors` - -- our `Support`_ - -.. _Slack: https://hexonet-sdk.slack.com/messages/CBF4RM7KK -.. _Stack Overflow: https://stackoverflow.com/questions/tagged/python-sdk -.. _Support: https://hexonet.support - -Please file Bugs / Issues / Problems as `new github issue`_ to us. -Please read our :ref:`contributing` first and use the search to check -if this is already a known issue. - -.. _new github issue: https://github.com/centralnicgroup-opensource/rtldev-middleware-python-sdk/issues/new diff --git a/docs/contents.rst.inc b/docs/contents.rst.inc deleted file mode 100644 index cd83382..0000000 --- a/docs/contents.rst.inc +++ /dev/null @@ -1,42 +0,0 @@ -Usage Guide ------------ - -This part of the documentation, which is mostly prose, begins with some -background information about HEXONET and it's Backend API, then focuses -on step-by-step instructions for getting started with our connector library -hexonet.apiconnector. - -.. toctree:: - :maxdepth: 2 - - foreword - installation - quickstart - debugging - config - -SDK Documentation ------------------ - -If you are looking for information on a specific function, class or -method, this part of the documentation is for you. - -.. toctree:: - :maxdepth: 2 - - api - -Additional Notes ----------------- - -Design notes, legal information and changelog are here for the interested. - -.. toctree:: - :maxdepth: 2 - - upgrading - changelog - contributing - developmentguide - license - contactus diff --git a/docs/contributing.rst b/docs/contributing.rst deleted file mode 100644 index a0ad0a8..0000000 --- a/docs/contributing.rst +++ /dev/null @@ -1,3 +0,0 @@ -.. _contributing: - -.. mdinclude:: ../CONTRIBUTING.md diff --git a/docs/debugging.rst b/docs/debugging.rst deleted file mode 100644 index b43510e..0000000 --- a/docs/debugging.rst +++ /dev/null @@ -1,15 +0,0 @@ -.. _debugging: - -Debugging -========= - -Debug Features are also available in our Python SDK:: - - # activate debug mode - cl.enableDebugMode() - - # disable debug mode - cl.disableDebugMode() - -This results in displaying the API Connection's used http url, -POST data and plain text response. diff --git a/docs/developmentguide.rst b/docs/developmentguide.rst deleted file mode 100644 index b033210..0000000 --- a/docs/developmentguide.rst +++ /dev/null @@ -1,114 +0,0 @@ -.. _developmentguide: - -Development Guide -================= - -Please read our :ref:`Contributing guide lines ` first. - -.. _requirements: - -Requirements ------------- - -You can find any required library for this project listed in the *pyproject.toml*: - -.. literalinclude:: ../pyproject.toml - -You can install all you need by - -.. code-block:: bash - - pip install --user --upgrade -e . - -Consider doing that using a virtual environment. Read the `docs`. - -.. _docs: https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/. - -NOTE: Make sure to have also all the extensions listed in the `docs/conf.py` -that are required for the SDK Documentation. - -.. _docs/conf.py: https://rawgit.com/centralnicgroup-opensource/rtldev-middleware-python-sdk/master/docs/conf.py - -We suggest to use `Visual Studio Code`_ with installed plugins for Python -Development described here_. But if you prefer any other IDE / Editor, it -is fine. - -.. _Visual Studio Code: https://code.visualstudio.com -.. _here: https://code.visualstudio.com/docs/languages/python - -.. _testsnvalidation: - -Run Tests and Code Validation ------------------------------ - -If you open a Pull Request (PR), we will trigger automated tests and pep8 style -check in CI process. So nothing you have to worry about in your development. -You can open your PR and prefix its title with WIP "Work In Progress" to access -these checks in advance. - -If there's anything breaking, be so kind to fix it. If you're not able to do it -- feel free to ask for help. - -Try to auto-fix pep8 styling issues by - -.. code-block:: bash - - # to autofix possible issues - ./scripts/pep8fix.sh - - # to check for issues left - ./scripts/pep8check.sh - - # run unit tests - ./scripts/coverage.sh - -Pull Request (PR) Procedure ---------------------------- -* fork our project and create a new branch -* clone it and check this branch out -* apply your desired changes / extensions -* commit and push it to remote. Please follow these [commit guidelines](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines). We suggest to use [commitizen](https://github.com/commitizen/cz-cli/blob/master/README.md). -* open a pull request (PR). -* check if the CI process fails. If so, review your code (feel free to ask for help). -* squash your commits as far as it makes sense -* rebase your branch - -**We care then about the rest** - no need to worry about things like -building current realease and versioning. - -**You can stop here.** - -TIA for your PR and thus for your support of this project. As we have -further SDKs in other languages, it might take a bit of time to check -if we can role out that PR as we want to keep all our SDKs aligned. - -.. _rules: https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) -.. _commitizen: https://github.com/commitizen/cz-cli/blob/master/README.md - -Changes to the documentation will be auto-deployed by a webhook to -readthedocs.org_. - -.. _readthedocs.org: https://hexonet-python-sdk.readthedocs.io -.. _github pages: https://hexonet.github.io/python-sdk - -The module can be accessed on the `PyPi (Live) Index`_ and the -`PyPi (Test) Index`_. - -.. _PyPi (Live) Index: https://pypi.org/project/hexonet.apiconnector/ -.. _PyPi (Test) Index: https://test.pypi.org/project/hexonet.apiconnector/ - -SDK Documentation ------------------ - -Have an eye on the generated :ref:`api`. - -If you want to generate it from scratch out of the sources, please use -the below script: - -.. code-block:: bash - - ./scripts/generatedocs.sh - -The generated files are then available in subfolder "docs/_build/html". -We regenerate the SDK Documentation whenever a new tag commit reaches -the master branch. diff --git a/docs/foreword.rst b/docs/foreword.rst deleted file mode 100644 index 64280c3..0000000 --- a/docs/foreword.rst +++ /dev/null @@ -1,32 +0,0 @@ -Foreword -======== - -Read this before you get started with hexonet.apiconnector. This -hopefully answers some questions about the purpose and goals of -the project. - -HEXONET -------- -We're known as leading developers of domain technologies and as -the worldwide experts in domain names. Our team is focused, and -continually driven to bring customers the best technological -solutions, TLD offerings, customer support, and domain products -to make their internet goals a reality. Whether you have one -domain or tens of thousands with us, we appreciate your business. - -Read more about us and our products and service on our homepage_. - -.. _homepage: https://www.hexonet.net/aboutus - -HEXONET Backend API -------------------- - -HEXONET provides his products and services through a Backend System -that is accessible by different options. One of these options is a -HTTP API for which we provide SDKs in different programming languages -such as go/golang, nodejs, php, python, java and perl. The -hexonet.apiconnector (aka python-sdk) is one of these connector -libraries that help implementors to connect their systems to the -HEXONET Backend System. - -Continue to :ref:`installation` or the :ref:`quickstart`. diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 3e2374b..0000000 --- a/docs/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -:orphan: - -Welcome to hexonet.apiconnector -=============================== - -.. image:: _static/hexonet.png - :alt: hexonet.apiconnector: Connector library for the insanely fast HEXONET Backend API - :align: right - -Welcome to hexonet.apiconnector's documentation. Get started with -:ref:`installation` and then get an overview with the :ref:`quickstart`. -There is also a Demo App available for any of our SDK libraries. The -one for hexonet.apiconnector (python-sdk) is available at github_. - -.. _github: https://github.com/centralnicgroup-opensource/rtldev-middleware-python-sdk-demo - -The rest of the docs describe each component of hexonet.apiconnector in -detail, with a full reference in the :ref:`api` section. - -.. include:: contents.rst.inc diff --git a/docs/installation.rst b/docs/installation.rst deleted file mode 100644 index 1c6655f..0000000 --- a/docs/installation.rst +++ /dev/null @@ -1,38 +0,0 @@ -.. _installation: - -Installation -============ - -Python Version --------------- - -We recommend using the latest version of Python 3. hexonet.apiconnector -supports Python 3.x and 2.7. - -NOTE: Since v3.x (2019-04-01, yes no joke!), we removed python 2.7 - compatibility. - - -Dependencies ------------- - -There are NO dependencies to install. If this changes, we will list them -here and they will be installed automatically when hexonet.apiconnector -is getting installed. - -There are :ref:`dependencies` that we just need in steps of -our build process. - -Installation -------------- - -Within your environment, use the following command to install -hexonet.apiconnector: - -.. code-block:: sh - - pip3 install hexonet.apiconnector - -The connector library is now installed. Check out the -:doc:`/quickstart` or go to the -:doc:`Documentation Overview `. diff --git a/docs/license.rst b/docs/license.rst deleted file mode 100644 index ed02e58..0000000 --- a/docs/license.rst +++ /dev/null @@ -1,36 +0,0 @@ -License -======= - -hexonet.apiconnector is licensed under MIT License. -A short, permissive software license. Basically, you can do whatever you -want as long as you include the original copyright and license notice in -any copy of the software/source. - -The full license text can be found below (:ref:`mit-license`). - -.. _authors: - -Authors -------- - -.. mdinclude:: ../AUTHORS.md - -General License Definitions ---------------------------- - -The following section contains the full license texts for this module and the -documentation. - -- "AUTHORS" hereby refers to all the authors listed in the - :ref:`authors` section. - -- The ":ref:`mit-license`" applies to all the source code shipped as - part of hexonet.apiconnector (the module itself as well as the examples and - the unittests) as well as documentation. - -.. _mit-license: - -MIT License -------------- - -.. include:: ../LICENSE diff --git a/docs/quickstart.rst b/docs/quickstart.rst deleted file mode 100644 index 6746e4a..0000000 --- a/docs/quickstart.rst +++ /dev/null @@ -1,45 +0,0 @@ -.. _quickstart: - -Quickstart -========== - -Eager to get started? This page gives a good introduction to -hexonet.apiconnector. It assumes you already have it installed. -If you do not, head over to the :ref:`installation` section. - - -A Minimal Application ---------------------- - -A minimal application using hexonet.apiconnector looks something like follows. -We provided two short examples: one for sessionless communication and one for -session-based communication. - -.. literalinclude:: app.py - :language: python - :encoding: utf-8 - :caption: Python SDK Demo App - -You can find this code also on github_. - -.. _github: https://github.com/centralnicgroup-opensource/rtldev-middleware-python-sdk-demo - -What to do if the backend system just returns an error ------------------------------------------------------- - -Well this in general needs some further analysis. Reasons might be that you -have an ip filter defined and you do not provide your ip address through -configuration option "remoteaddr". -It could also be that you provided an ip address that is blocked. -Another issue can be that you connect using a role user that is not allowed -to request this command as it got blocked by role user configuration. - -Feel free to :ref:`contact-us` if you need help. - -Sessions --------- - -Session-based communication is available in this SDK, see above. -Use :meth:`~hexonet.apiconnector.apiclient.APIClient.saveSession` and -:meth:`~hexonet.apiconnector.apiclient.APIClient.reuseSession` if you -plan to build your own frontend on top using session handling. diff --git a/docs/upgrading.rst b/docs/upgrading.rst deleted file mode 100644 index f33a2b4..0000000 --- a/docs/upgrading.rst +++ /dev/null @@ -1,22 +0,0 @@ -Upgrading to Newer Releases -=========================== - -hexonet.apiconnector itself is changing like any software is changing over -time. Most of the changes are the nice kind, the kind where you don't have -to change anything in your code to profit from a new release. These are in -general changes that are released as patch or minor release. - -However every once in a while there are changes that do require some -changes in your code or there are changes that make it possible for you to -improve your own code quality by taking advantage of new features in -hexonet.apiconnector. Such breaking changes are covered through major releases. - -Use the :command:`pip` command to upgrade your existing hexonet.apiconnector -installation by providing the ``--upgrade`` parameter:: - - $ pip3 install --upgrade hexonet.apiconnector - -See the how to migrate your code by reading the `release notes`_. -We publish there any information on how to migrate. - -.. _release notes: https://github.com/centralnicgroup-opensource/rtldev-middleware-python-sdk/releases diff --git a/hexonet/apiconnector/__init__.py b/hexonet/apiconnector/__init__.py deleted file mode 100755 index a78f579..0000000 --- a/hexonet/apiconnector/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -""" - hexonet.apiconnector - ~~~~~~~~~~~~~~~~~~~~ - A connector library for the insanely fast HEXONET Backend API. - :copyright: © 2018 by HEXONET GmbH. - :license: MIT, see LICENSE for more details. -""" - -__version__ = "4.0.4" -name = "hexonet.apiconnector" diff --git a/hexonet/apiconnector/socketconfig.py b/hexonet/apiconnector/socketconfig.py deleted file mode 100644 index 01a83ad..0000000 --- a/hexonet/apiconnector/socketconfig.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: utf-8 -*- -""" - hexonet.apiconnector.socketconfig - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - This module covers all necessary functionality to - pre-configure http communication with our Backend System. - :copyright: © 2018 by HEXONET GmbH. - :license: MIT, see LICENSE for more details. -""" - -from urllib.parse import quote, unquote - - -class SocketConfig(object): - """ - The SocketConfig class helps to configure the http communcation with our Backend System. - """ - - def __init__(self): - # API system entity. "54cd" for LIVE system; "1234" for OT&E system - self.__entity = None - # account name - self.__login = None - # one time password (2FA) - self.__otp = None - # account password - self.__pw = None - # remote ip address (ip filter) - self.__remoteaddr = None - # API session id - self.__session = None - # subuser account name (subuser specific data view) - self.__user = None - - def getPOSTData(self): - """ - Create POST data string out of connection data - """ - data = "" - tpl = "{0}={1}&" - for key in [ - "__entity", - "__login", - "__otp", - "__pw", - "__remoteaddr", - "__session", - "__user", - ]: - item = getattr(self, "_SocketConfig" + key) - if item is not None and item != "": - data += tpl.format(quote("s_" + key[2:]), quote(item)) - return data - - def getSession(self): - """ - Get API Session ID in use - """ - return self.__session - - def getSystemEntity(self): - """ - Get API System Entity in use - """ - return self.__entity - - def setLogin(self, value): - """ - Set account name to use - """ - self.__session = None - self.__login = value - return self - - def setOTP(self, value): - """ - Set one time password to use - """ - self.__session = None - self.__otp = value - return self - - def setPassword(self, value): - """ - Set account password to use - """ - self.__session = None - self.__pw = value - return self - - def setRemoteAddress(self, value): - """ - Set Remote IP Address to use - """ - self.__remoteaddr = value - return self - - def setSession(self, value): - """ - Set API Session ID to use - """ - self.__login = None - self.__pw = None - self.__otp = None - self.__session = value - return self - - def setSystemEntity(self, value): - """ - Set API System Entity to use. This is set to 54cd / LIVE System by default. - """ - self.__entity = value - return self - - def setUser(self, value): - """ - Set subuser account name (for subuser data view) - """ - self.__user = value - return self diff --git a/htmlcov/class_index.html b/htmlcov/class_index.html index 57050ec..1f3e350 100644 --- a/htmlcov/class_index.html +++ b/htmlcov/class_index.html @@ -11,7 +11,7 @@

Coverage report: - 96% + 78%

@@ -73,166 +73,198 @@

- hexonet/apiconnector/apiclient.py - APIClient - 194 - 10 + centralnicreseller/apiconnector/apiclient.py + APIClient + 181 + 9 0 - 95% + 95% - hexonet/apiconnector/apiclient.py - (no class) - 51 + centralnicreseller/apiconnector/apiclient.py + (no class) + 49 0 0 - 100% + 100% - hexonet/apiconnector/column.py - Column + centralnicreseller/apiconnector/column.py + Column 7 + 1 0 - 0 - 100% + 86% - hexonet/apiconnector/column.py - (no class) + centralnicreseller/apiconnector/column.py + (no class) 6 0 0 100% - hexonet/apiconnector/customlogger.py - CustomLogger - 1 - 1 + centralnicreseller/apiconnector/customlogger.py + CustomLogger + 2 + 2 0 - 0% + 0% - hexonet/apiconnector/customlogger.py - (no class) + centralnicreseller/apiconnector/customlogger.py + (no class) 5 5 0 0% - hexonet/apiconnector/logger.py - Logger + centralnicreseller/apiconnector/idnaconverter.py + IDNAConverter + 24 + 12 + 0 + 50% + + + centralnicreseller/apiconnector/idnaconverter.py + (no class) + 11 + 0 + 0 + 100% + + + centralnicreseller/apiconnector/idnaprocessor.py + IDNAProcessor + 17 + 6 + 0 + 65% + + + centralnicreseller/apiconnector/idnaprocessor.py + (no class) + 10 + 0 + 0 + 100% + + + centralnicreseller/apiconnector/logger.py + Logger 5 - 1 0 - 80% + 0 + 100% - hexonet/apiconnector/logger.py - (no class) + centralnicreseller/apiconnector/logger.py + (no class) 3 0 0 100% - hexonet/apiconnector/record.py - Record + centralnicreseller/apiconnector/record.py + Record 6 + 2 0 - 0 - 100% + 67% - hexonet/apiconnector/record.py - (no class) + centralnicreseller/apiconnector/record.py + (no class) 5 0 0 100% - hexonet/apiconnector/response.py - Response - 140 - 2 + centralnicreseller/apiconnector/response.py + Response + 149 + 83 0 - 99% + 44% - hexonet/apiconnector/response.py - (no class) - 38 + centralnicreseller/apiconnector/response.py + (no class) + 39 0 0 - 100% + 100% - hexonet/apiconnector/responseparser.py - (no class) - 35 + centralnicreseller/apiconnector/responseparser.py + (no class) + 24 0 0 - 100% + 100% - hexonet/apiconnector/responsetemplate.py - ResponseTemplate - 33 - 5 + centralnicreseller/apiconnector/responsetemplate.py + ResponseTemplate + 30 + 16 0 - 85% + 47% - hexonet/apiconnector/responsetemplate.py - (no class) - 13 + centralnicreseller/apiconnector/responsetemplate.py + (no class) + 12 0 0 - 100% + 100% - hexonet/apiconnector/responsetemplatemanager.py - ResponseTemplateManager + centralnicreseller/apiconnector/responsetemplatemanager.py + ResponseTemplateManager 22 - 1 + 11 0 - 95% + 50% - hexonet/apiconnector/responsetemplatemanager.py - (no class) + centralnicreseller/apiconnector/responsetemplatemanager.py + (no class) 15 0 0 100% - hexonet/apiconnector/socketconfig.py - SocketConfig - 36 + centralnicreseller/apiconnector/socketconfig.py + SocketConfig + 28 0 0 - 100% + 100% - hexonet/apiconnector/socketconfig.py - (no class) - 13 + centralnicreseller/apiconnector/socketconfig.py + (no class) + 10 0 0 - 100% + 100% Total   - 628 - 25 + 660 + 147 0 - 96% + 78% @@ -244,7 +276,7 @@

coverage.py v7.6.1, - created at 2024-10-21 11:43 +0000 + created at 2024-10-17 19:05 +0200