Skip to content

Commit 8a72aaa

Browse files
authored
Merge pull request #89 from Worvast/master
## [3.3.1] - 2020-05-11
2 parents dcbd156 + f3e8813 commit 8a72aaa

File tree

10 files changed

+63
-33
lines changed

10 files changed

+63
-33
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [3.3.1] - 2020-05-11
8+
### Added
9+
* env vars JWT and TOKEN for API shell client
10+
* verify certs in API creation and cli calls
11+
12+
### Fixed
13+
* Documentation about SSLConfigSender
14+
15+
### Deprecated
16+
* Unnecesary setters
17+
718
## [No version upgraded] - 2020-04-29
819
### Added
920
* Added examples

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[![master Build Status](https://travis-ci.com/DevoInc/python-sdk.svg?branch=master)](https://travis-ci.com/DevoInc/python-sdk) [![LICENSE](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/DevoInc/python-sdk/blob/master/LICENSE)
33

4-
[![wheel](https://img.shields.io/badge/wheel-yes-brightgreen.svg)](https://pypi.org/project/devo-sdk/) [![version](https://img.shields.io/badge/version-3.3.0-blue.svg)](https://pypi.org/project/devo-sdk/) [![python](https://img.shields.io/badge/python-3.5%20%7C%203.6%20%7C%203.7%20%7C%203.8-blue.svg)](https://pypi.org/project/devo-sdk/)
4+
[![wheel](https://img.shields.io/badge/wheel-yes-brightgreen.svg)](https://pypi.org/project/devo-sdk/) [![version](https://img.shields.io/badge/version-3.3.1-blue.svg)](https://pypi.org/project/devo-sdk/) [![python](https://img.shields.io/badge/python-3.5%20%7C%203.6%20%7C%203.7%20%7C%203.8-blue.svg)](https://pypi.org/project/devo-sdk/)
55

66

77
# Devo Python SDK

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__ = "3.3.0"
3+
__version__ = "3.3.1"
44
__author__ = 'Devo'
55
__author_email__ = 'support@devo.com'
66
__license__ = 'MIT'

devo/api/client.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class Client:
133133
The Devo seach rest api main class
134134
"""
135135
def __init__(self, address=None, auth=None, config=None,
136-
retries=None, timeout=None):
136+
retries=None, timeout=None, verify=None):
137137
"""
138138
Initialize the API with this params, all optionals
139139
:param address: endpoint
@@ -155,13 +155,11 @@ def __init__(self, address=None, auth=None, config=None,
155155
"token": config.get("token",
156156
None)})
157157

158+
verify = verify if verify else config.get("verify", True)
158159
retries = retries if retries else config.get("retries", 3)
159160
timeout = timeout if timeout else config.get("timeout", 30)
160161
self.config = self._from_dict(config)
161162

162-
retries = int(retries) if retries else 3
163-
timeout = int(timeout) if timeout else 30
164-
165163
self.auth = auth
166164
if not address:
167165
raise raise_exception(
@@ -170,9 +168,9 @@ def __init__(self, address=None, auth=None, config=None,
170168

171169
self.address = self.__get_address_parts(address)
172170

173-
self.retries = retries
174-
self.timeout = timeout
175-
self.verify = True
171+
self.retries = int(retries) if retries else 3
172+
self.timeout = int(timeout) if timeout else 30
173+
self.verify = verify if verify else True
176174

177175
@staticmethod
178176
def _from_dict(config):

devo/api/scripts/client_cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def cli(version):
4040
@click.option('--key', help='Key for the api.')
4141
@click.option('--secret', help='Secret for the api.')
4242
@click.option('--token', help='Secret for the api.')
43+
@click.option('--jwt', help='JWT auth for the api.')
4344
@click.option('--query', '-q', help='Query.', default="")
4445
@click.option('--stream/--no-stream',
4546
help='Flag for make streaming query or full query with '
@@ -55,6 +56,7 @@ def cli(version):
5556
help='To date. For valid formats see API README')
5657
@click.option('--timeZone',
5758
help='Timezone info. For valid formats see API README')
59+
@click.option('--verify', type=bool, help='Verify certificates')
5860
@click.option('--debug/--no-debug', help='For testing purposes', default=False)
5961
def query(**kwargs):
6062
"""Perform query by query string"""
@@ -129,6 +131,8 @@ def configure(args):
129131
if args.get('env'):
130132
config.set("key", os.environ.get('DEVO_API_KEY', None))
131133
config.set("secret", os.environ.get('DEVO_API_SECRET', None))
134+
config.set("token", os.environ.get('DEVO_API_TOKEN', None))
135+
config.set("jwt", os.environ.get('DEVO_API_JWT', None))
132136
config.set("address", os.environ.get('DEVO_API_ADDRESS', None))
133137
config.set("user", os.environ.get('DEVO_API_USER', None))
134138
config.set("comment", os.environ.get('DEVO_API_COMMENT', None))

devo/sender/data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ def info(self, msg):
251251
"""
252252
self.send(tag=self.logging.get("tag"), msg=msg)
253253

254+
# TODO: Deprecated
254255
def set_sec_level(self, sec_level=None):
255256
"""
256257
Set sec_level of SSL Context:
@@ -260,6 +261,7 @@ def set_sec_level(self, sec_level=None):
260261
"""
261262
self._sender_config.sec_level = sec_level
262263

264+
# TODO: Deprecated
263265
def set_verify_mode(self, verify_mode=None):
264266
"""
265267
Set verify_mode of SSL Context:
@@ -273,6 +275,7 @@ def set_verify_mode(self, verify_mode=None):
273275
"""
274276
self._sender_config.verify_mode = verify_mode
275277

278+
# TODO: Deprecated
276279
def set_check_hostname(self, check_hostname=True):
277280
"""
278281
Set check_hostname of SSL Context:

devo/sender/lookup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ def send_csv(self, path=None, has_header=True, delimiter=',',
206206
p_fields = Lookup.process_fields(fields=fields,
207207
key_index=key_index)
208208
self.send_data(row=p_fields,
209-
delete=field_action == "delete")
209+
delete=field_action == "delete"
210+
or field_action == "DELETE")
210211

211212
# Send full log for historic
212213
if historic_tag is not None:

docs/api/api.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -343,25 +343,31 @@ Usage: `devo-api query [OPTIONS]`
343343

344344
```
345345
Options:
346-
-c, --config PATH JSON/YAML File with configuration, you can put all options here
347-
-e, --env Use env vars for configuration
348-
-a, --address TEXT Endpoint for the api.
349-
--key TEXT Key for the api.
350-
--secret TEXT Secret for the api.
351-
--token TEXT Token auth for query.
352-
--jwt TEXT jwt auth for query.
353-
-q, --query TEXT Query.
354-
--stream / --no-stream Flag for make streaming query or full query with start and end. Default is true
355-
--output TEXT File path to store query response if not want stdout
356-
-r, --response TEXT The output format. Default is json/simple/compact
357-
--from TEXT From date, and time for the query (YYYY-MM-DD hh:mm:ss). For valid formats see lt-common README
358-
--to TEXT To date, and time for the query (YYYY-MM-DD hh:mm:ss). For valid formats see lt-common README
359-
--help Show this message and exit.
360-
--user User for the api.
361-
--app_name App Name for the api.
362-
--comment Comment for pragma in query
363-
--debug/--no-debug For testing purposes
364-
--help Show this message and exit.
346+
-c, --config PATH Optional JSON/Yaml File with configuration info.
347+
-e, --env TEXT Use env vars for configuration
348+
-d, --default TEXT Use default file for configuration
349+
-a, --address TEXT Endpoint for the api.
350+
--user TEXT User for the api.
351+
--app_name TEXT Application name for the api.
352+
--comment TEXT Comment for the queries.
353+
--key TEXT Key for the api.
354+
--secret TEXT Secret for the api.
355+
--token TEXT Secret for the api.
356+
--jwt TEXT JWT auth for the api.
357+
-q, --query TEXT Query.
358+
--stream / --no-stream Flag for make streaming query or full query with
359+
start and end. Default is true
360+
361+
--output TEXT File path to store query response if not want stdout
362+
-r, --response TEXT The output format. Default is json/simple/compact
363+
--from TEXT From date. For valid formats see API README. Default
364+
if now - 1 hour
365+
366+
--to TEXT To date. For valid formats see API README
367+
--timeZone TEXT Timezone info. For valid formats see API README
368+
--verify BOOLEAN Verify certificates
369+
--debug / --no-debug For testing purposes
370+
--help Show this message and exit.
365371
```
366372

367373
A configuration file does not have to have all the necessary keys, you can have
@@ -424,7 +430,13 @@ Priority order:
424430
3. Environment vars: if you send key, secrey or token in config file or params cli, this option not be called
425431
4. ~/.devo.json or ~/.devo.yaml: if you send key, secrey or token in other way, this option not be called
426432
427-
Environment vars are: `DEVO_API_ADDRESS`, `DEVO_API_KEY`, `DEVO_API_SECRET`, `DEVO_API_USER`.
433+
Environment vars are:
434+
- `DEVO_API_ADDRESS`
435+
- `DEVO_API_KEY`
436+
- `DEVO_API_SECRET`
437+
- `DEVO_API_USER`
438+
- `DEVO_API_TOKEN`
439+
- `DEVO_API_JWT`
428440

429441
## Choosing Fomat
430442
The default response format (`response`) is `json`, to change the default value, it can be established directly:

docs/sender/data.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Class SenderConfigSSL accept various types of certificates, you has:
2626
+ chain **(_str_)**: chain src file
2727
+ pkcs **(_dict_)**: (path: pfx src file, password: of cert)
2828
+ sec_level **(_int_)**: Security level to openssl launch
29-
29+
+ check_hostname **(_bool_)**: Verify cert hostname. Default: True
30+
+ verify_mode **(_int_)**: Verify mode for SSL Socket. Default: SSL default.You need use int "0" (CERT_NONE), "1" (CERT_OPTIONAL) or "2" (CERT_REQUIRED)
3031

3132
You can use the collector in some ways:
3233

tests/api/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_normal_query(self):
8585

8686
self.assertIsNone(result.exception)
8787
self.assertEqual(result.exit_code, 0)
88-
self.assertIn('{"m":{"timestamp":{"type":"str","index":0}}}',
88+
self.assertIn('{"m":{"timestamp":{"type":"str","index":0',
8989
result.output)
9090

9191
def test_with_config_file(self):
@@ -100,7 +100,7 @@ def test_with_config_file(self):
100100

101101
self.assertIsNone(result.exception)
102102
self.assertEqual(result.exit_code, 0)
103-
self.assertIn('{"m":{"timestamp":{"type":"str","index":0}}}',
103+
self.assertIn('{"m":{"timestamp":{"type":"str","index":0',
104104
result.output)
105105

106106

0 commit comments

Comments
 (0)