Skip to content

Commit

Permalink
add poll commands to cli (#65)
Browse files Browse the repository at this point in the history
* add poll commands to cli

* increase version
  • Loading branch information
ehsan-fj authored Oct 25, 2023
1 parent ab50303 commit 0b91b05
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 23 deletions.
2 changes: 1 addition & 1 deletion pyepp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
PyEPP Package
"""
__version__ = "0.0.7-alpha.1"
__version__ = "0.0.7-alpha.2"

from pyepp.epp import EppCommunicator, EppResultCode, EppCommunicatorException
3 changes: 2 additions & 1 deletion pyepp/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pyepp.cli import cli
from pyepp.cli.contact import contact_group
from pyepp.cli.domain import domain_group
from pyepp.cli.poll import poll_group

logging.basicConfig(level=logging.ERROR)

Expand Down Expand Up @@ -57,4 +58,4 @@ def run_xml(ctx, xml):
pyepp_cli.add_command(contact_group)
pyepp_cli.add_command(domain_group)
pyepp_cli.add_command(host_group)
pyepp_cli.add_command(cli.poll)
pyepp_cli.add_command(poll_group)
29 changes: 9 additions & 20 deletions pyepp/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,15 @@ def transfer(self, *args, **kwargs):
result = self.registry_object.transfer(*args, **kwargs)
return self.format_output(result)

@login_logout
def request(self, *args, **kwargs):
result = self.registry_object.request(*args, **kwargs)
return self.format_output(result)

pass_pyepp_cli = click.make_pass_decorator(PyEppCli)


@click.group()
@click.pass_context
def domain(ctx):
"""To work with Domain objects in the registry."""
ctx.obj.registry_object = Domain(ctx.obj.epp)


@click.group()
@click.pass_context
def host(ctx):
"""To work with Host objects in the registry."""
ctx.obj.registry_object = Host(ctx.obj.epp)
@login_logout
def acknowledge(self, *args, **kwargs):
result = self.registry_object.acknowledge(*args, **kwargs)
return self.format_output(result)


@click.group()
@click.pass_context
def poll(ctx):
"""To request or acknowledge registry service messages."""
pass
pass_pyepp_cli = click.make_pass_decorator(PyEppCli)
2 changes: 1 addition & 1 deletion pyepp/cli/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def host_update(ctx, host_name, add_ip, remove_ip, add_status, remove_status, ne


@click.command(name='create')
@click.argument('host_name')
@click.argument('host-name')
@click.option('--ip-address', multiple=True, nargs=2, type=click.Tuple([str, str]),
help="Add IP address to host. At least one required. <ADDRESS IP[v4, v6]>", required=True)
@click.option('--client-transaction-id')
Expand Down
42 changes: 42 additions & 0 deletions pyepp/cli/poll.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
EPP Poll cli module
"""
import click

from pyepp.poll import Poll


@click.group(name='poll')
@click.pass_context
def poll_group(ctx):
""" To manage registry service messages."""
ctx.obj.registry_object = Poll(ctx.obj.epp)


@click.command(name='request')
@click.option('--client-transaction-id')
@click.pass_context
def poll_request(ctx, client_transaction_id):
"""This command is to check and retrieve queued service messages as wel as keep the
connection alive."""
result = ctx.obj.request(client_transaction_id=client_transaction_id)
click.echo(result)


@click.command(name='acknowledge')
@click.argument('message-id')
@click.option('--client-transaction-id')
@click.pass_context
def poll_acknowledge(ctx, message_id,client_transaction_id):
"""This command will acknowledge and remove a message from the poll queue so that registrars can run another
poll request to get the next message in line if one exists.
MESSAGE_ID: Request message id
"""
result = ctx.obj.acknowledge(message_id,
client_transaction_id=client_transaction_id)
click.echo(result)


poll_group.add_command(poll_request)
poll_group.add_command(poll_acknowledge)

0 comments on commit 0b91b05

Please sign in to comment.