Skip to content

Commit fe900ae

Browse files
authored
261 add extra parameters in the query api calls (#264)
* chore: Format correctly several files * feat: Add ip_as_string feature * doc: Update docs * fix: Fix tests
1 parent 1d47ee8 commit fe900ae

28 files changed

+605
-223
lines changed

.github/workflows/python-pull-request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ jobs:
3030
version: ["3.8", "3.9"]
3131
runs-on: ubuntu-latest
3232
steps:
33-
- uses: actions/checkout@v3
33+
- uses: actions/checkout@v4
3434
- name: Set up Python
35-
uses: actions/setup-python@v3
35+
uses: actions/setup-python@v5
3636
with:
3737
python-version: ${{ matrix.version }}
3838
- name: Install dependencies
3939
run: |
4040
python -m pip install --upgrade pip
41-
pip install -r requirements.txt
4241
pip install -r requirements-test.txt
42+
pip install -e .
4343
- name: Install certificates
4444
run: |
4545
mkdir -p certs/us

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [5.2.0] - 2024-04-10
8+
9+
### Added
10+
11+
- Add ip-as-string flag to the API client to return the IP address as a string instead of an integer.
12+
13+
### Changed
14+
15+
- `cryptography` dependency upgraded from `cryptography~=42.0.2` to `cryptography~=42.0.5`
16+
- `msgpack` dependency upgraded from `msgpack~=1.0.7` to `msgpack~=1.0.8`
17+
- `pipdeptree` dependency upgraded from `pipdeptree~=2.14.0` to `pipdeptree~=2.17.0`
18+
- `pyopenssl` dependency upgraded from `pyopenssl~=24.0` to `pyopenssl~=24.1.0`
19+
- `pytest-cov` dependency upgraded from `pytest-cov~=4.1.0` to `pytest-cov~=5.0.0`
20+
- `pytest` dependency upgraded from `pytest~=7.4.4` to `pytest~=8.1.1`
21+
- `responses` dependency upgraded from `responses~=0.24` to `responses~=0.25.0`
22+
723
## [5.1.10] - 2024-02-16
824

925
### Changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ The Devo SDK for Python requires Python 3.8+
2727
You can install the Devo SDK by using `easy_install` or `pip`:
2828

2929
```console
30-
#option 1
30+
# option 1
3131
easy_install devo-sdk
3232

33-
#option 2
33+
# option 2
3434
pip install devo-sdk
3535
```
3636

3737
You can use sources files, cloning the project too:
3838

3939
```console
40-
#option 3
40+
# option 3
4141
python setup.py install
4242

43-
#option 4
43+
# option 4
4444
pip install .
4545

46-
#option 5 - dev option
46+
# option 5 - dev option
4747
pip install -e .
4848
```
4949

@@ -120,21 +120,21 @@ The SDK uses Pytest for testing. This is a powerful tool for testing Python code
120120
Install the testing requirements:
121121

122122
```console
123-
~/projects/devo-python-sdk > pip install -r requirements-test.txt
123+
pip install -r requirements-test.txt
124124
```
125125

126126
You can run tests from the `tests` folder of SDK
127127

128128
```console
129-
~/projects/devo-python-sdk/tests > pytest
129+
pytest
130130
```
131131

132132
Its normal that TCP tests fails in clients or not Devo developers systems.
133133

134134
You can add the option `--cov` to create a coverage report.
135135

136136
```console
137-
~/projects/devo-python-sdk/tests > pytest --cov
137+
pytest --cov
138138
```
139139

140140
Check the [pytest-cov documentation](https://pytest-cov.readthedocs.io/) for more details.
@@ -144,19 +144,19 @@ The tests are divided into unit and integration tests. The integration tests req
144144
To run the unit tests only, you can use the `unit` folder:
145145

146146
```console
147-
~/projects/devo-python-sdk/tests > pytest unit
147+
pytest unit
148148
```
149149

150150
To run the integration tests only, you can use the `integration` folder:
151151

152152
```console
153-
~/projects/devo-python-sdk/tests > pytest integration
153+
pytest integration
154154
```
155155

156156
You can also run the test for just one module. This is a useful feature if you are developing functionality in just one module.
157157

158158
```console
159-
~/projects/devo-python-sdk/tests > pytest unit/test_sender_encoding.py
159+
pytest unit/test_sender_encoding.py
160160
```
161161

162162
### Contact Us

devo/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__description__ = "Devo Python Library."
22
__url__ = "http://www.devo.com"
3-
__version__ = "5.1.10"
3+
__version__ = "5.2.0"
44
__author__ = "Devo"
55
__author_email__ = "support@devo.com"
66
__license__ = "MIT"

devo/api/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""Main class for pull data from Devo API (Client)."""
3+
34
import calendar
45
import hashlib
56
import hmac
@@ -430,6 +431,7 @@ def query(
430431
limit=None,
431432
offset=None,
432433
comment=None,
434+
ip_as_string=False,
433435
):
434436
"""
435437
Query API by a custom query
@@ -452,6 +454,7 @@ def query(
452454
"offset": offset,
453455
"destination": self.config.destination,
454456
"keepAliveToken": self.config.keepAliveToken,
457+
"ip_as_string": ip_as_string,
455458
}
456459

457460
if not self.stream_available(self.config.response) or not self.config.stream:
@@ -682,6 +685,9 @@ def _get_payload(query, query_id, dates, opts):
682685
"token": opts["keepAliveToken"],
683686
}
684687

688+
if opts["ip_as_string"]:
689+
payload["ipAsString"] = opts["ip_as_string"]
690+
685691
return json.dumps(payload)
686692

687693
def _get_headers(self, data):

devo/api/processors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""Defaults proccessors of API data."""
3+
34
import json
45

56

devo/api/scripts/client_cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python3
22
"""CLI for use Devo API from shell command line."""
3+
34
import os
45
import sys
56

@@ -84,6 +85,7 @@ def cli(version):
8485
@click.option("--timeZone", help="Timezone info. For valid formats see API README")
8586
@click.option("--verify", type=bool, help="Verify certificates")
8687
@click.option("--debug/--no-debug", help="For testing purposes", default=False)
88+
@click.option("--ip-as-string", is_flag=True, help="Return IPs as strings", default=False)
8789
def query(**kwargs):
8890
"""Perform query by query string"""
8991
api, config = configure(kwargs)
@@ -121,9 +123,9 @@ def query(**kwargs):
121123
print_error(ERROR_MSGS["binary_format_requires_output"], show_help=True)
122124
exit()
123125

124-
reponse = api.query(query=config["query"], dates=dates)
126+
response = api.query(query=config["query"], dates=dates, ip_as_string=config["ip_as_string"])
125127

126-
process_response(reponse, config)
128+
process_response(response, config)
127129

128130

129131
def process_response(response, config):

devo/common/dates/dateoperations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
"""A collection of allowed operations on date parsing"""
3+
34
from datetime import datetime as dt
45
from datetime import timedelta
56

devo/common/generic/configuration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
2-
""" Util for load generic config file in devo standars"""
2+
"""Util for load generic config file in devo standars"""
3+
34
import json
45
import os
56
import sys

devo/common/logging/log.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
2-
""" Generic function to logging events in Devo SDK """
2+
"""Generic function to logging events in Devo SDK"""
3+
34
import logging
45
import os
56
import sys

0 commit comments

Comments
 (0)