Skip to content

Commit 96cc5c1

Browse files
committed
Update CHANGELOG.md; add sample code snippet for newly added ouput filtering in api wrapper
1 parent ded8152 commit 96cc5c1

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog
22

3+
### 2.0.0
4+
- [NEW] Modernize package - migrate package settings to pyproject.toml
5+
- [NEW] Migrate CLI wrapper to use `typer` library. (CLI comes now with new interface.)
6+
- [NEW] Add support for making `api_url` and `api_port` configurable.
7+
- [NEW] Add `--source-file` or `-s` cli parameter in `iris_investigate` and `iris_enrich` command to support file input instead of long comma-separated domains when typing the domains. Max of **100** domains in a single file.
8+
- [NEW] Add output filtering in `iris_investigate` and `iris_enrich` function in API wrapper (see sample code in `examples/iris_investigate_filter_output.py` folder). Changes includes the ff:
9+
- Filtering of results "**>=**" to a given `risk_score`.
10+
- Filtering of results based on `expiration_date` field. (`younger_than_date`, `older_than_date`)
11+
- Filtering of results based on `updated_after` field.
12+
- Filtering of results based on a missing field. (include_domains_with_missing_field` or `exclude_domains_with_missing_field`).
13+
- [NEW] Add support on removing/stripping colon in when passing a value in `--ssl_hash` in `iris_investigate` cli command.
14+
- [UPDATE] replace use of upcoming deprecated `datetime.uctnow()` to `timezone.utc`
15+
- [UPDATE] Improve help text in CLI commands.
16+
- [UPDATE] Remove `dateparser` dependency and use native python `datetime` library.
17+
- [FIX] Fix error in `-o` or `--out-file` parameter.
18+
19+
320
### 1.0.1
421

522
- Adds support for the hourly query limit on the Account API endpoint
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
from domaintools import API
2+
3+
4+
dt_api = API(USER_NAME, KEY)
5+
domains = "int-chase.com, google.com"
6+
7+
8+
def sample_filter_by_risk_score():
9+
"""
10+
Sample code snippet on how to use the output filtering by a given riskscore
11+
"""
12+
response = dt_api.iris_investigate(domains=domains, risk_score=68)
13+
output_domains = [
14+
(result.get("domain"), result.get("domain_risk", {}).get("risk_score"))
15+
for result in response.get("results") or []
16+
]
17+
# this will output [('int-chase.com', 71)], assuming that this domain has a >= to the given riskscore
18+
print(f"Filter by `risk_score` result: {output_domains}")
19+
20+
21+
def sample_filter_by_younger_than_date():
22+
"""
23+
Sample code snippet on how to use the output filtering by younger_than_date.
24+
The field being used in this filter is the `expiration_date`.
25+
"""
26+
response = dt_api.iris_investigate(domains=domains, younger_than_date="2024-02-24")
27+
28+
output_domains = [
29+
(result.get("domain"), result.get("expiration_date"))
30+
for result in response.get("results") or []
31+
]
32+
# this will output [('google.com', {'value': '2028-09-14', 'count': 9972})],
33+
# assuming that this domain has a expiration_date <= to the given date.
34+
print(f"Filter by `younger_than_date` result: {output_domains}")
35+
36+
37+
def sample_filter_by_older_than_date():
38+
"""
39+
Sample code snippet on how to use the output filtering by older_than_date.
40+
The field being used in this filter is the `expiration_date`.
41+
"""
42+
response = dt_api.iris_investigate(domains=domains, older_than_date="2024-02-24")
43+
44+
output_domains = [
45+
(result.get("domain"), result.get("expiration_date"))
46+
for result in response.get("results") or []
47+
]
48+
# this will output [('int-chase.com', {'value': '2021-10-13', 'count': 118259})],
49+
# assuming that this domain has a expiration_date <= to the given date.
50+
print(f"Filter by `older_than_date` result: {output_domains}")
51+
52+
53+
def sample_filter_by_updated_after():
54+
"""
55+
Sample code snippet on how to use the output filtering by updated_after.
56+
The field being used in this filter is the `data_updated_timestamp`.
57+
"""
58+
response = dt_api.iris_investigate(domains=domains, updated_after="2024-02-24")
59+
60+
output_domains = [
61+
(result.get("domain"), result.get("data_updated_timestamp"))
62+
for result in response.get("results") or []
63+
]
64+
# this will output [('google.com', {'value': '2028-09-14', 'count': 9972})],
65+
# assuming that this domain has a data_updated_timestamp >= to the given `updated_after` date.
66+
print(f"Filter by `updated_after` result: {output_domains}")
67+
68+
69+
def sample_filter_by_include_domains_with_missing_field():
70+
"""
71+
Sample code snippet on how to use the output filtering to include
72+
the domain even the given field is missing or empty in the result set.
73+
"""
74+
response = dt_api.iris_investigate(
75+
domains=domains, include_domains_with_missing_field="popularity_rank"
76+
)
77+
78+
# this will output [('google.com', 1), ('int-chase.com', '')]
79+
output_domains = [
80+
(result.get("domain"), result.get("popularity_rank"))
81+
for result in response.get("results") or []
82+
]
83+
print(f"Filter by `include_domains_with_missing_field` result: {output_domains}")
84+
85+
86+
def sample_filter_by_exclude_domains_with_missing_field():
87+
"""
88+
Sample code snippet on how to use the output filtering to exclude
89+
the domain even the given field is missing or empty in the result set.
90+
"""
91+
response = dt_api.iris_investigate(
92+
domains=domains, exclude_domains_with_missing_field="popularity_rank"
93+
)
94+
95+
# this will only output [('google.com', 1)] as the popularity rank in other domain is missing/empty
96+
output_domains = [
97+
(result.get("domain"), result.get("popularity_rank"))
98+
for result in response.get("results") or []
99+
]
100+
print(f"Filter by `exclude_domains_with_missing_field` result: {output_domains}")
101+
102+
103+
sample_filter_by_risk_score()
104+
sample_filter_by_younger_than_date()
105+
sample_filter_by_older_than_date()
106+
sample_filter_by_updated_after()
107+
sample_filter_by_include_domains_with_missing_field()
108+
sample_filter_by_exclude_domains_with_missing_field()

0 commit comments

Comments
 (0)