From c769960fa1a5d32396e8602022a2eecd539cc148 Mon Sep 17 00:00:00 2001 From: "joseramon.afonso" Date: Tue, 29 Jan 2019 16:30:23 +0100 Subject: [PATCH 1/8] Changed all new endpoints references for sender and api --- CHANGELOG.md | 4 ++++ README.md | 14 ++++++++------ devo/api/client.py | 6 +++--- docs/api/api.md | 23 +++++++++++++++-------- docs/api/destination_email.md | 2 +- docs/api/destination_redis.md | 2 +- docs/api/destination_s3.md | 2 +- docs/api/task.md | 14 +++++++------- docs/sender.md | 12 ++++++++---- 9 files changed, 48 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93352f3a..d6dc4269 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ 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). +## [UNRELEASED] - xxxx-xx-xx +#### Changed + * All new endpoints references for sender and api + ## [2.1.1] - 2019-01-29 #### Fixed * Problems with recursion depth when zipped send has problems with Socket. diff --git a/README.md b/README.md index 30965c2c..403fabf3 100755 --- a/README.md +++ b/README.md @@ -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 @@ -52,8 +56,6 @@ 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).
Pull and merge requests are welcome ☺ @@ -61,15 +63,15 @@ 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) . diff --git a/devo/api/client.py b/devo/api/client.py index ccd4ca78..03b41f26 100644 --- a/devo/api/client.py +++ b/devo/api/client.py @@ -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' diff --git a/docs/api/api.md b/docs/api/api.md index a3b84619..eb6e7051 100644 --- a/docs/api/api.md +++ b/docs/api/api.md @@ -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 @@ -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="user@devo.com", 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 @@ -67,7 +74,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="user@devo.com", app_name="testing app") @@ -85,7 +92,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="user@devo.com", app_name="testing app") @@ -114,7 +121,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="user@devo.com", app_name="testing app") @@ -238,7 +245,7 @@ json example: "api": { "key": "MyAPIkeytoaccessdevo", "secret": "MyAPIsecrettoaccessdevo", - "url": "https://api-us.logtrust.com/search/query" + "url": "https://api-us.devo.com/search/query" } } @@ -249,7 +256,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 diff --git a/docs/api/destination_email.md b/docs/api/destination_email.md index eb06e9cf..e4a9fb7c 100644 --- a/docs/api/destination_email.md +++ b/docs/api/destination_email.md @@ -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="user@devo.com", app_name="testing app") diff --git a/docs/api/destination_redis.md b/docs/api/destination_redis.md index fe4a0efe..bf249b6e 100644 --- a/docs/api/destination_redis.md +++ b/docs/api/destination_redis.md @@ -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="user@devo.com", app_name="testing app") diff --git a/docs/api/destination_s3.md b/docs/api/destination_s3.md index 87b7831a..176f91e6 100644 --- a/docs/api/destination_s3.md +++ b/docs/api/destination_s3.md @@ -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="user@devo.com", app_name="testing app") diff --git a/docs/api/task.md b/docs/api/task.md index 2ccfc095..a8f272a0 100644 --- a/docs/api/task.md +++ b/docs/api/task.md @@ -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) @@ -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() ``` @@ -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") ``` @@ -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") ``` @@ -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) ``` @@ -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) ``` @@ -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) ``` diff --git a/docs/sender.md b/docs/sender.md index b255ee2d..556b8c80 100644 --- a/docs/sender.md +++ b/docs/sender.md @@ -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 From 29e8bd368c4834bef1c0c72acdab9f00590de32f Mon Sep 17 00:00:00 2001 From: "joseramon.afonso" Date: Mon, 4 Feb 2019 14:46:59 +0100 Subject: [PATCH 2/8] Fixed problem with one processor and added documentation --- devo/api/processors.py | 6 ++++-- docs/api/api.md | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/devo/api/processors.py b/devo/api/processors.py index e6f324e6..60e76f96 100644 --- a/devo/api/processors.py +++ b/devo/api/processors.py @@ -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(): diff --git a/docs/api/api.md b/docs/api/api.md index eb6e7051..7bf29277 100644 --- a/docs/api/api.md +++ b/docs/api/api.md @@ -64,9 +64,16 @@ 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 @@ -283,8 +290,8 @@ 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 @@ -292,8 +299,7 @@ Type allow the following values: · json/simple/compact · msgpack · csv (comma separated values) - · tsv (Tab separated Values) - + · tsv (Tab separated Values) #### Response type JSON From a3ebb2ea2d504908e42c1c8ee6a7a21fcb916902 Mon Sep 17 00:00:00 2001 From: "joseramon.afonso" Date: Mon, 4 Feb 2019 14:48:07 +0100 Subject: [PATCH 3/8] Updated changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6dc4269..29ffcd9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,14 @@ 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). ## [UNRELEASED] - xxxx-xx-xx +#### 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 From 05a8b0e0c92a55dbf57ba359b2822ce62b9d256c Mon Sep 17 00:00:00 2001 From: "joseramon.afonso" Date: Thu, 7 Feb 2019 12:54:27 +0100 Subject: [PATCH 4/8] Only modified len of two comments lines --- devo/common/generic/configuration.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/devo/common/generic/configuration.py b/devo/common/generic/configuration.py index 52d3ab8d..5489a7ca 100644 --- a/devo/common/generic/configuration.py +++ b/devo/common/generic/configuration.py @@ -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: @@ -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: From 4c8a3623f1341941a89b8be55ad74a0d97123ad3 Mon Sep 17 00:00:00 2001 From: "joseramon.afonso" Date: Tue, 12 Feb 2019 16:11:22 +0100 Subject: [PATCH 5/8] Updated version --- CHANGELOG.md | 2 +- README.md | 2 +- devo/__version__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29ffcd9c..9199e614 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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). -## [UNRELEASED] - xxxx-xx-xx +## [2.1.2] - 2019-02-12 #### Added * More documentation info and examples diff --git a/README.md b/README.md index 403fabf3..8eb30d7c 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/devo/__version__.py b/devo/__version__.py index 8b120ea0..80c48bfc 100644 --- a/devo/__version__.py +++ b/devo/__version__.py @@ -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__ = 'support@devo.com' __license__ = 'MIT' From 8acd936d4e9fbe0885a9881e41db2e2185c5a0aa Mon Sep 17 00:00:00 2001 From: "joseramon.afonso" Date: Tue, 12 Feb 2019 16:14:20 +0100 Subject: [PATCH 6/8] Fix in doc --- docs/sender.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/sender.md b/docs/sender.md index 556b8c80..b19dff5e 100644 --- a/docs/sender.md +++ b/docs/sender.md @@ -117,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' @@ -127,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') @@ -136,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, From 1507024492b9a9528247b59637f1f926cad7d329 Mon Sep 17 00:00:00 2001 From: "joseramon.afonso" Date: Tue, 12 Feb 2019 16:20:32 +0100 Subject: [PATCH 7/8] Fixed in common test --- tests/common/configuration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/common/configuration.py b/tests/common/configuration.py index 15c76fe7..83841a4b 100644 --- a/tests/common/configuration.py +++ b/tests/common/configuration.py @@ -13,8 +13,8 @@ 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 supportted" + in str(context.exception)) def test_load_directly(self): config = Configuration(self.config_path + ".yaml") From 5ff1658bad0453c00ce19304375af1b6d7909268 Mon Sep 17 00:00:00 2001 From: "joseramon.afonso" Date: Tue, 12 Feb 2019 16:28:47 +0100 Subject: [PATCH 8/8] fixed typo --- tests/common/configuration.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/common/configuration.py b/tests/common/configuration.py index 83841a4b..33b2fb2f 100644 --- a/tests/common/configuration.py +++ b/tests/common/configuration.py @@ -13,7 +13,9 @@ 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" + 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):