Skip to content
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
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).

## [2.1.2] - 2019-02-12
#### Added
* More documentation info and examples

#### Changed
* All new endpoints references for sender and api

#### Fixed
* Problems with proc_json_compact_simple_to_jobj when None

## [2.1.1] - 2019-01-29
#### Fixed
* Problems with recursion depth when zipped send has problems with Socket.
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[![relese-next Build Status](https://travis-ci.com/DevoInc/python-sdk.svg?branch=release-next)](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)

[![wheel](https://img.shields.io/badge/wheel-yes-brightgreen.svg)](https://pypi.org/project/devo-sdk/) [![version](https://img.shields.io/badge/version-2.1.1-blue.svg)](https://pypi.org/project/devo-sdk/) [![python](https://img.shields.io/badge/python-2.7%20%7C%203.3%20%7C%203.4%20%7C%203.5%20%7C%203.6%20%7C%203.7-blue.svg)](https://pypi.org/project/devo-sdk/)
[![wheel](https://img.shields.io/badge/wheel-yes-brightgreen.svg)](https://pypi.org/project/devo-sdk/) [![version](https://img.shields.io/badge/version-2.1.2-blue.svg)](https://pypi.org/project/devo-sdk/) [![python](https://img.shields.io/badge/python-2.7%20%7C%203.3%20%7C%203.4%20%7C%203.5%20%7C%203.6%20%7C%203.7-blue.svg)](https://pypi.org/project/devo-sdk/)


# Devo Python SDK
Expand All @@ -15,6 +15,10 @@ This is the SDK to access Devo directly from Python. It can be used to:

The Devo SDK for Python requires Python 2.7+ or Python 3.4+

## Compatibility
- Tested compatibility between python 2.x and 3.x series
- Unit tests for both python 2.x and 3.x

## Quick Start
### Installing the SDK

Expand Down Expand Up @@ -52,24 +56,22 @@ You has specific documentation in _[docs](docs)_ folder for each part of SDK:
* [Destination: S3](docs/api/destination_s3.md)




## Contributing
See [PyLibs contributing guide](CONTRIBUTING.md).<br/>
Pull and merge requests are welcome ☺

## Endpoints
##### Sender
To send data with Devo SDK, first choose the required endpoint depending on the region your are accessing from:
* **USA:** us.elb.relay.logtrust.net:443
* **EU:** eu.elb.relay.logtrust.net:443
* **USA:** collector-us.devo.io:443
* **EU:** collector-eu.devo.io:443

You have more information in the official documentation of Devo, [Sending data to Devo](https://docs.devo.com/confluence/ndt/sending-data-to-devo).

##### API
To perform a request with API, first choose the required endpoint depending on the region your are accessing from:
* **USA:** https://api-us.logtrust.com/search/query
* **EU:** https://api-eu.logtrust.com/search/query
* **USA:** https://api-us.devo.com/search/query
* **EU:** https://api-eu.devo.com/search/query

You have more information in the official documentation of Devo, [REST API v2](https://docs.devo.com/confluence/ndt/api-reference/rest-api-v2) .

Expand Down
2 changes: 1 addition & 1 deletion devo/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__description__ = 'Devo Python Library.'
__url__ = 'http://www.devo.com'
__version__ = "2.1.1"
__version__ = "2.1.2"
__author__ = 'Devo'
__author_email__ = '[email protected]'
__license__ = 'MIT'
Expand Down
6 changes: 3 additions & 3 deletions devo/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
PY3 = sys.version_info[0] > 2
CLIENT_DEFAULT_APP_NAME = 'python-sdk-app'
CLIENT_DEFAULT_USER = 'python-sdk-user'
URL_AWS_EU = 'https://api-eu.logtrust.com'
URL_VDC = 'https://spainapi.logtrust.com'
URL_AWS_USA = 'https://api-us.logtrust.com'
URL_AWS_EU = 'https://api-eu.devo.com'
URL_VDC = 'https://api-es.devo.com'
URL_AWS_USA = 'https://api-us.devo.com'
URL_QUERY_COMPLEMENT = 'search/query'
URL_JOB = '/search/job/'
URL_JOBS = '/search/jobs'
Expand Down
6 changes: 4 additions & 2 deletions devo/api/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ def json_compact_simple_names(data):

def proc_json_compact_simple_to_jobj(names=None):
return proc_json_compact_simple_to_array() if not names else \
lambda data: dict(zip(names, proc_json_compact_simple_to_array()(data)))
lambda data: dict(zip(names,
proc_json_compact_simple_to_array()(data))) \
if data else {}


def proc_json_compact_simple_to_array():
return lambda data: proc_json()(data)['d']
return lambda data: proc_json()(data)['d'] if data else []


def processors():
Expand Down
6 changes: 4 additions & 2 deletions devo/common/generic/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def load_yaml(self, path, section=None):
try:
import yaml
except ImportError as import_error:
print(str(import_error), "- Use 'pip install pyyaml' or install this "
print(str(import_error), "- Use 'pip install pyyaml' or "
"install this "
"package with [click] option")
sys.exit(1)
with open(path, 'r') as stream:
Expand All @@ -73,7 +74,8 @@ def load_config(self, path, section=None):
if path.endswith('.yaml') or path.endswith('.yml'):
return self.load_yaml(path, section)

raise ConfigurationException("Configuration file type unknown or not supportted: %s" %path)
raise ConfigurationException("Configuration file type unknown "
"or not supported: %s" % path)

def save(self, path=None, save_bak=False):
if path is None:
Expand Down
37 changes: 25 additions & 12 deletions docs/api/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
## Overview
This library performs queries to the Client API (Search rest api) of Devo.

## Endpoints
##### API
To perform a request with API, first choose the required endpoint depending on the region your are accessing from:
* **USA:** https://api-us.devo.com/search/query
* **EU:** https://api-eu.devo.com/search/query

You have more information in the official documentation of Devo, [REST API v2](https://docs.devo.com/confluence/ndt/api-reference/rest-api-v2) .

## USAGE
#### Constructor
Expand All @@ -24,16 +31,16 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query",
url="https://api-eu.devo.com/search/query",
user="[email protected]",
app_name="testing app")


api = Client(token="myauthtoken",
url="https://api-eu.logtrust.com/search/query")
url="https://api-eu.devo.com/search/query")

api = Client(jwt="myauthtoken",
url="https://api-eu.logtrust.com/search/query")
url="https://api-eu.devo.com/search/query")
```

#### query() params
Expand All @@ -57,17 +64,24 @@ api = Client(jwt="myauthtoken",
###### - Non stream call
- Result of the query in str/bytes when query work
- JSON Object when query has errors
- You can use all the response formats in non-stream mode.
###### - stream call
- Generator with result of the query, str/bytes, when query work
- JSON Object when query has errors
- Stream available formats:
- json/simple
- json/simple/compact
- msgpack
- csv (comma separated values)
- tsv (Tab separated Values)

Normal/Non stream response:
```python
from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query",
url="https://api-eu.devo.com/search/query",
user="[email protected]",
app_name="testing app")

Expand All @@ -85,7 +99,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query",
url="https://api-eu.devo.com/search/query",
user="[email protected]",
app_name="testing app")

Expand Down Expand Up @@ -114,7 +128,7 @@ from devo.api import Client, JSON_SIMPLE

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query",
url="https://api-eu.devo.com/search/query",
user="[email protected]",
app_name="testing app")

Expand Down Expand Up @@ -238,7 +252,7 @@ json example:
"api": {
"key": "MyAPIkeytoaccessdevo",
"secret": "MyAPIsecrettoaccessdevo",
"url": "https://api-us.logtrust.com/search/query"
"url": "https://api-us.devo.com/search/query"
}
}

Expand All @@ -249,7 +263,7 @@ yaml example:
api:
key: "MyAPIkeytoaccessdevo"
secret: "MyAPIsecrettoaccessdevo"
url: "https://api-us.logtrust.com/search/query"
url: "https://api-us.devo.com/search/query"
```

You can use environment variables or a global configuration file for the KEY, SECRET, URL, USER, APP_NAME and COMMENT values
Expand All @@ -276,17 +290,16 @@ response = api.query(config['query'],
date_to=config['to'],
response=config['response'])
```

Type allow the following values:
Format allow the following values:

· json
· json/compact
· json/simple
· json/simple/compact
· msgpack
· csv (comma separated values)
· tsv (Tab separated Values)

· tsv (Tab separated Values)

#### Response type JSON

Expand Down
2 changes: 1 addition & 1 deletion docs/api/destination_email.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query",
url="https://api-eu.devo.com/search/query",
user="[email protected]",
app_name="testing app")

Expand Down
2 changes: 1 addition & 1 deletion docs/api/destination_redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query",
url="https://api-eu.devo.com/search/query",
user="[email protected]",
app_name="testing app")

Expand Down
2 changes: 1 addition & 1 deletion docs/api/destination_s3.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query",
url="https://api-eu.devo.com/search/query",
user="[email protected]",
app_name="testing app")

Expand Down
14 changes: 7 additions & 7 deletions docs/api/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query")
url="https://api-eu.devo.com/search/query")

job_id = "aaaaa-bbbbb-ccccc-dddd"
response = api.get_job(job_id)
Expand Down Expand Up @@ -67,7 +67,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query")
url="https://api-eu.devo.com/search/query")
response = api.get_jobs()
```

Expand Down Expand Up @@ -118,7 +118,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query")
url="https://api-eu.devo.com/search/query")
response = api.get_jobs(type="donothing")
```

Expand All @@ -141,7 +141,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query")
url="https://api-eu.devo.com/search/query")
response = api.get_jobs(type="donothing", name="devo-sdk-test")
```

Expand All @@ -162,7 +162,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query")
url="https://api-eu.devo.com/search/query")
job_id = "aaaaa-bbbbb-ccccc-dddd"
response = api.stop_job(job_id)
```
Expand Down Expand Up @@ -206,7 +206,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query")
url="https://api-eu.devo.com/search/query")
job_id = "aaaaa-bbbbb-ccccc-dddd"
response = api.start_job(job_id)
```
Expand Down Expand Up @@ -248,7 +248,7 @@ from devo.api import Client

api = Client(key="myapikey",
secret="myapisecret",
url="https://api-eu.logtrust.com/search/query")
url="https://api-eu.devo.com/search/query")
job_id = "aaaaa-bbbbb-ccccc-dddd"
response = api.remove_job(job_id)
```
Expand Down
20 changes: 12 additions & 8 deletions docs/sender.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ This library allows you to send logs or lookups to the Devo platform.
- Allows to send real time data
- Logger integration and logging handler capacity for Sender

## Compatibility
- Tested compatibility between python 2.x and 3.x series
- Unit tests for both python 2.x and 3.x
## Endpoints
##### Sender
To send data with Devo SDK, first choose the required endpoint depending on the region your are accessing from:
* **USA:** collector-us.devo.io:443
* **EU:** collector-eu.devo.io:443

You have more information in the official documentation of Devo, [Sending data to Devo](https://docs.devo.com/confluence/ndt/sending-data-to-devo).

## Usage in script

## Usage in script
### Sender

Before sending the lookup information it is necessary to initialize the collector configuration
Expand Down Expand Up @@ -113,7 +117,7 @@ In order to use **Sender** as an Handler, for logging instances, the **tag** pro

The regular use of the handler can be observed in this 3 examples:

######Setting up configuration variables.
##### Setting up configuration variables.
```python
from devo.sender import SenderConfigSSL
tag = 'test.dump.free'
Expand All @@ -123,7 +127,7 @@ engine_config = SenderConfigSSL(address=server, port=port,
con = Sender(engine_config)

```
######First example: Setting up tag after Sender is created
##### First example: Setting up tag after Sender is created

```python
logger = logging.getLogger('DEVO_logger')
Expand All @@ -132,14 +136,14 @@ con = Sender(engine_config)
con.set_logger_tag(tag)
logger.addHandler(con)
```
######Second example: Setting up a Sender with tag
##### Second example: Setting up a Sender with tag
```python
logger = logging.getLogger('DEVO_logger')
#Sender created ready to be used
con = Sender(engine_config, tag)
logger.addHandler(con)
```
######Third example: Setting up a static Sender
##### Third example: Setting up a static Sender

```python
engine_config = {"address": server, "port": port,
Expand Down
6 changes: 4 additions & 2 deletions tests/common/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ def test_load_config(self):
with self.assertRaises(Exception) as context:
config.load_config(self.config_path + ".ini")

self.assertTrue("Configuration file type unknown or not supportted: %s%stestfile_config.ini" % \
(os.path.dirname(os.path.abspath(__file__)), os.sep) in str(context.exception))
self.assertTrue("Configuration file type unknown or not supported: "
"%s%stestfile_config.ini" % \
(os.path.dirname(os.path.abspath(__file__)), os.sep)
in str(context.exception))

def test_load_directly(self):
config = Configuration(self.config_path + ".yaml")
Expand Down