CLI ============= PyEPP comes with a command line interface that allows the user to interact with the registry system. It will be installed the main library. .. code-block:: text sh> pip install pyepp How to get help --------------- To see the help page: .. code-block:: text sh> pyepp -h Usage: pyepp [OPTIONS] COMMAND [ARGS]... A command line interface to work with PyEpp library. Options: --server TEXT [required] --port TEXT [required] --user TEXT [required] --password TEXT [required] --client-cert TEXT [optional] --client-key TEXT [optional] -o, --output-format [XML|OBJECT|MIN] [default: XML] --no-pretty --dry-run -f, --file FILENAME If provided, the output will be written in the file. -v, --verbose -d, --debug --version Show the version and exit. -h, --help Show this message and exit. Commands: contact To work with Contact objects in the registry. domain To work with Domain name objects in the registry. host To work with Host objects in the registry. poll To manage registry service messages. run Receive an XML file containing an EPP XML command and execute it. And to get help for a specific command: .. code-block:: text sh> pyepp contact create -h Usage: pyepp contact create [OPTIONS] CONTACT_ID Creates a new contact in the registry. CONTACT_ID: A unique contact id Options: --email TEXT [required] --name TEXT [required] --city TEXT [required] --country-code TEXT [required] --organization TEXT --street-1 TEXT --street-2 TEXT --street-3 TEXT --province TEXT --postal-code TEXT --phone TEXT --fax TEXT --password TEXT --client-transaction-id TEXT -h, --help Show this message and exit. Enable shell autocomplete ------------------------- To enable shell autocompletion for your shell follow the below commands: Zsh ^^^^ .. code-block:: text mkdir -p ~/.pyepp _PYEPP_COMPLETE=zsh_source pyepp > ~/.pyepp/shell-complete.zsh Source the file in ``~/.zshrc``. .. code-block:: text . ~/.pyepp/shell-complete.zsh Bash ^^^^ .. code-block:: text mkdir -p ~/.pyepp _PYEPP_COMPLETE=bash_source pyepp > ~/.pyepp/shell-complete.bash Source the file in ``~/.bashrc``. .. code-block:: text . ~/.pyepp/shell-complete.bash How to configure ---------------- The epp server configuration and credentials can be passed to the cli in three different ways. It can be done either through the command line options, environment variables or a config file. NOTE: Client certificate and key are optional and only required if the server requires client authentication. Command line options ^^^^^^^^^^^^^^^^^^^^ The server configuration and credentials can be passed to the cli by command line options: .. code-block:: text sh> pyepp --server epp.test.net.nz \ --port 700 \ --user epp_user \ --password SecurePassWord \ --client-key /path/to/epp.key.pem \ --client-cert /path/to/epp.crt \ contact info ehsan-contact-1 Environment variables ^^^^^^^^^^^^^^^^^^^^^ The below environment variables can be used to pass the epp server configuration and credentials to the cli. By using this way you don't have to pass the parameters for running each command. .. code-block:: text PYEPP_SERVER=epp.test.net.nz PYEPP_PORT=700 PYEPP_USER=epp_user PYEPP_PASSWORD=SecurePassWord PYEPP_CLIENT_CERT=/path/to/epp.crt PYEPP_CLIENT_KEY=/path/to/epp.key.pem Config file ^^^^^^^^^^^ To configure the cli by a config file first the config file should be created in the below paths based on the operating system: .. code-block:: text Mac OS X (POSIX) and Unix (POSIX): ~/.pyepp/config.ini Windows (not roaming): C:\Users\\AppData\Local\pyepp\config.ini Then add the below lines to the file: .. code-block:: ini [pyepp] server = epp.test.net.nz port = 700 user = epp_user password = SecurePassWord client_cert = /path/to/epp.crt client_key = /path/to/epp.key.pem Examples --------------- contact ^^^^^^^^^^^ .. code-block:: text sh> pyepp contact create sh8014 --email jdoe@example.com --name Jonh --city Dulles --country-code US Command completed successfully sh8014 2024-04-12T00:41:59.977Z 09ac2c26-63f4-4aaf-8574-1add9e620044 CIRA-000232270901-0000000002 .. code-block:: text sh> pyepp -o OBJECT contact check sh8014 EppResultData(code=1000, message='Command completed successfully', raw_response=b'\n\n \n' b' \n Co' b'mmand completed successfully\n \n \n \n \n ' b' sh8014\n Selected' b' contact ID is not available\n ' b' \n \n \n ' b'\n 32ebe5a8-225b-4829-a8e0-aa1' b'a10602138\n CIRA-0002' b'32306101-0000000002\n \n ' b' \n', result_data={'sh8014': {'avail': False, 'reason': 'Selected contact ID is not ' 'available'}}, reason=None, client_transaction_id='32ebe5a8-225b-4829-a8e0-aa1a10602138', server_transaction_id='CIRA-000232306101-0000000002', repository_object_id=None) domain ^^^^^^^^^^^ .. code-block:: text sh> pyepp --no-pretty domain check test.nz Command completed successfully test.nz Registered 46c89b2a-617f-4d44-a2c1-340aa20a1358 CIRA-000232247104-0000000002 .. code-block:: text sh> pyepp -o MIN domain check test.co.nz {'test.co.nz': {'avail': False, 'reason': 'Registered'}} host ^^^^^^^^^^^ .. code-block:: text sh> pyepp host info test.co.nz Object does not exist 6010 Host does not exist 7bc656f8-32f0-42d3-ba55-79192cd3b654 CIRA-000232224702-0000000002 .. code-block:: text sh> pyepp --dry-run host info test.co.nz test.co.nz dab02e31-5658-44c4-bbd5-ff66b88539b5