Skip to content

Commit e96f495

Browse files
committed
IDEV-1877: Refactor nad and nod implementation.
1 parent 6d16769 commit e96f495

File tree

4 files changed

+46
-8
lines changed

4 files changed

+46
-8
lines changed

domaintools/api.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,22 +1120,30 @@ def iris_detect_ignored_domains(
11201120
**kwargs,
11211121
)
11221122

1123-
def newly_observed_domains_feed(self, **kwargs):
1123+
def nod(self, **kwargs):
11241124
"""Returns back list of the newly observed domains feed"""
1125+
sessionID = kwargs.get("sessionID")
1126+
after = kwargs.get("after")
1127+
if (sessionID and after) or not (sessionID or after):
1128+
raise ValueError("sessionID or after (but not both) must be defined")
1129+
11251130
return self._results(
11261131
"newly-observed-domains-feed-(api)",
11271132
"v1/feed/nod/",
11281133
response_path=(),
1129-
after="-60",
11301134
**kwargs,
11311135
)
11321136

1133-
def newly_active_domains_feed(self, **kwargs):
1137+
def nad(self, **kwargs):
11341138
"""Returns back list of the newly active domains feed"""
1139+
sessionID = kwargs.get("sessionID")
1140+
after = kwargs.get("after")
1141+
if (sessionID and after) or not (sessionID or after):
1142+
raise ValueError("sessionID or after (but not both) must be defined")
1143+
11351144
return self._results(
11361145
"newly-active-domains-feed-(api)",
11371146
"v1/feed/nad/",
11381147
response_path=(),
1139-
after="-60",
11401148
**kwargs,
11411149
)

domaintools/cli/commands/feeds.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ def feeds_nad(
4848
"--no-sign-api-key",
4949
help="Skip signing of api key",
5050
),
51+
sessionID: str = typer.Option(
52+
None,
53+
"--session-id",
54+
help="Unique identifier for the session",
55+
),
56+
after: str = typer.Option(
57+
None,
58+
"--after",
59+
help="Start of the time window, relative to the current time in seconds, for which data will be provided",
60+
),
61+
top: str = typer.Option(
62+
None,
63+
"--top",
64+
help="Number of results to return in the response payload",
65+
),
5166
):
5267
DTCLICommand.run(name=c.FEEDS_NAD, params=ctx.params)
5368

@@ -92,5 +107,20 @@ def feeds_nod(
92107
"--no-sign-api-key",
93108
help="Skip signing of api key",
94109
),
110+
sessionID: str = typer.Option(
111+
None,
112+
"--session-id",
113+
help="Unique identifier for the session",
114+
),
115+
after: str = typer.Option(
116+
None,
117+
"--after",
118+
help="Start of the time window, relative to the current time in seconds, for which data will be provided",
119+
),
120+
top: str = typer.Option(
121+
None,
122+
"--top",
123+
help="Number of results to return in the response payload",
124+
),
95125
):
96126
DTCLICommand.run(name=c.FEEDS_NOD, params=ctx.params)

domaintools/cli/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@
4343
PHISHEYE_TERM_LIST = "phisheye_term_list"
4444

4545
# feeds
46-
FEEDS_NAD = "newly_active_domains_feed"
47-
FEEDS_NOD = "newly_observed_domains_feed"
46+
FEEDS_NAD = "nad"
47+
FEEDS_NOD = "nod"

tests/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def test_limit_exceeded():
517517

518518
@vcr.use_cassette
519519
def test_newly_observed_domains_feed():
520-
results = api.newly_observed_domains_feed()
520+
results = api.nod(after="-60")
521521
response = results.response()
522522
rows = response.strip().split("\n")
523523

@@ -533,7 +533,7 @@ def test_newly_observed_domains_feed():
533533

534534
@vcr.use_cassette
535535
def test_newly_active_domains_feed():
536-
results = api.newly_active_domains_feed()
536+
results = api.nad(after="-60")
537537
response = results.response()
538538
rows = response.strip().split("\n")
539539

0 commit comments

Comments
 (0)