Skip to content

Commit 7539a33

Browse files
committed
rebase + update deprecations
1 parent ad84357 commit 7539a33

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ package_dir =
3131
setup_requires = pyscaffold>=3.2a0,<3.3a0
3232
# Add here dependencies of your project (semicolon/line-separated), e.g.
3333
install_requires =
34-
aleph-sdk-python@git+https://github.com/aleph-im/aleph-sdk-python.git@863e1e2acc55b23885908adb2cb33cce0fa12773
34+
aleph-sdk-python@git+https://github.com/aleph-im/aleph-sdk-python.git@main
3535
aleph-message==0.4.0
3636
coincurve
3737
aiohttp>=3.8.3

src/aleph_client/commands/domain.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@
44

55
import typer
66
from aleph.sdk.account import _load_account
7-
from aleph.sdk.client import AlephClient, AuthenticatedAlephClient
7+
from aleph.sdk.client import AlephHttpClient, AuthenticatedAlephHttpClient
88
from aleph.sdk.conf import settings as sdk_settings
9-
from aleph.sdk.domain import DomainValidator, Hostname, TargetType, hostname_from_url
9+
from aleph.sdk.domain import (
10+
DomainValidator,
11+
Hostname,
12+
TargetType,
13+
get_target_type,
14+
hostname_from_url,
15+
)
1016
from aleph.sdk.exceptions import DomainConfigurationError
17+
from aleph.sdk.query.filters import MessageFilter
1118
from aleph.sdk.types import AccountFromPrivateKey
1219
from aleph_client.commands import help_strings
1320
from aleph_client.commands.utils import coro
@@ -20,12 +27,14 @@
2027

2128

2229
async def get_aggregate_domain_info(account, fqdn):
23-
async with AlephClient(api_server=sdk_settings.API_HOST) as client:
30+
async with AlephHttpClient(api_server=sdk_settings.API_HOST) as client:
2431
aggregates = await client.get_messages(
25-
addresses=[str(account.get_address())],
26-
message_type=MessageType.aggregate,
32+
message_filter=MessageFilter(
33+
message_types=[MessageType.aggregate],
34+
addresses=[str(account.get_address())],
35+
),
2736
page=1,
28-
pagination=1000
37+
page_size=1000
2938
)
3039

3140
for message in aggregates.messages:
@@ -59,20 +68,18 @@ async def detach_resource(account: AccountFromPrivateKey, fqdn: Hostname):
5968
table.add_column("New resource", justify="right", style="green", no_wrap=True)
6069
table.add_column("Resource type", style="magenta")
6170

62-
domain_validator = DomainValidator()
63-
6471
if domain_info is not None and domain_info.get("info"):
6572
current_resource = domain_info["info"]["message_id"]
6673

67-
resource_type = await domain_validator.get_target_type(fqdn)
74+
resource_type = await get_target_type(fqdn)
6875
table.add_row(f"{current_resource[:16]}...{current_resource[-16:]}", "", resource_type)
6976

7077
console.print(table)
7178

7279
if Confirm.ask("Continue"):
7380
"""Update aggregate message"""
7481

75-
async with AuthenticatedAlephClient(
82+
async with AuthenticatedAlephHttpClient(
7683
account=account, api_server=sdk_settings.API_HOST
7784
) as client:
7885
aggregate_content = {
@@ -102,12 +109,11 @@ async def attach_resource(account: AccountFromPrivateKey, fqdn: Hostname, item_h
102109
table.add_column("Resource type", style="magenta")
103110

104111
current_resource = "null"
105-
domain_validator = DomainValidator()
106112

107113
"""
108114
Detect target type on the fly to be able to switch to another type
109115
"""
110-
resource_type = await domain_validator.get_target_type(fqdn)
116+
resource_type = await get_target_type(fqdn)
111117

112118
if domain_info is not None and domain_info.get("info"):
113119
current_resource = domain_info["info"]["message_id"]
@@ -119,7 +125,7 @@ async def attach_resource(account: AccountFromPrivateKey, fqdn: Hostname, item_h
119125
if Confirm.ask("Continue"):
120126
"""Create aggregate message"""
121127

122-
async with AuthenticatedAlephClient(
128+
async with AuthenticatedAlephHttpClient(
123129
account=account, api_server=sdk_settings.API_HOST
124130
) as client:
125131
aggregate_content = {
@@ -177,7 +183,7 @@ async def add(
177183
owner = account.get_address()
178184
dns_rules = domain_validator.get_required_dns_rules(fqdn, target, owner)
179185
for rule_id, rule in enumerate(dns_rules):
180-
table.add_row(str(rule_id), rule["dns"]["type"], rule["dns"]["name"], rule["dns"]["value"])
186+
table.add_row(str(rule_id), rule.dns.get("type"), rule.dns.get("name"), rule.dns.get("value"))
181187

182188
console.print(table)
183189

@@ -191,7 +197,7 @@ async def add(
191197
checks = await check_domain_records(fqdn, target, owner)
192198
completed_rules = []
193199
for index, rule in enumerate(dns_rules):
194-
if checks[rule["rule_name"]] is True:
200+
if checks[rule.name] is True:
195201
"""Pass configured rules"""
196202
completed_rules.append(rule)
197203
console.log(f"record: {index} [bold green] OK")
@@ -202,8 +208,8 @@ async def add(
202208

203209
if dns_rules:
204210
rule = dns_rules[0]
205-
console.log(f"[green]{rule['info']}")
206-
status.update(f"{msg_status} [bold red]{rule['on_error']}")
211+
console.log(f"[green]{rule.info}")
212+
status.update(f"{msg_status} [bold red]{rule.on_error}")
207213

208214
max_retries -= 1
209215
sleep(10)

0 commit comments

Comments
 (0)