README.rst 1.95 KB
Newer Older
Ondrej Fikar's avatar
Ondrej Fikar committed
1
2
3
4
===========
Fred-epplib
===========

Ondrej Fikar's avatar
Ondrej Fikar committed
5
Fred EPP library provides the means to communicate with an EPP server. It consists from four main modules: `client`,
6
`commands`, `responses`, and `models`.
Ondrej Fikar's avatar
Ondrej Fikar committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

The `Client` class in the `client` module is used to exchange the messages with the server. Module `commands` contains
the dataclasses representing the commands which may be sent to the server. `responses` module contains the dataclasses
representing the responses received from the server. `models` module contains dataclasses which are used to compose both
requests and responses.

For more details plese refer to the source code documentation. We suggest starting with the `Client` class in
the `client` module.

Usage
=====

In order to exchange messages with the server a `Transport` instance has to be created and passed to the init of
the `Client`. Then the `Client` is connected to the server using context manager or manually by calling the `connect`
method. The commands are created as the instances of the `Request` base class and send via the `send` method of
the `Client` instance. The response from the server is returned by `send` as an instance of the `Response` class. After
response is received its data may be examined.

See the example below

.. code-block:: python

Filip Uradnik's avatar
Filip Uradnik committed
29
30
31
32
    from epplib.client import Client
    from epplib.commands import InfoDomain, Login, Logout
    from epplib.transport import SocketTransport

Ondrej Fikar's avatar
Ondrej Fikar committed
33
34
35
36
    hostname = 'localhost'
    cert_file = 'path/to/cert.pem'
    key_file = 'path/to/key.pem'

Vlastimil Zima's avatar
Vlastimil Zima committed
37
    transport = SocketTransport(hostname, cert_file=cert_file, key_file=key_file)
Ondrej Fikar's avatar
Ondrej Fikar committed
38
39
40
41
42
43
44
45

    with Client(transport) as client:
        login = Login(cl_id='my_id', password='passwd', obj_uris=['http://www.nic.cz/xml/epp/contact-1.6'])
        response_login = client.send(login)
        print(response_login.code)

        info = InfoDomain(name='mydomain.cz')
        response_info = client.send(info)
Filip Uradnik's avatar
Filip Uradnik committed
46
        print(response_info.res_data[0].ex_date)
Ondrej Fikar's avatar
Ondrej Fikar committed
47
48

        client.send(Logout())