-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Forcepoint/dev
added password encryption,
- Loading branch information
Showing
9 changed files
with
225 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
#!/usr/bin/env python3 | ||
import requests | ||
from datacollectorapi import client | ||
from datacollectorapiMOD import client | ||
import logging | ||
import collections | ||
|
||
from requests import ReadTimeout | ||
|
||
from Config import Configurations | ||
|
||
|
||
def azure_api_call(customer_id, shared_key, log_type, send_list): | ||
api = client.DataCollectorAPIClient(customer_id, shared_key) | ||
try: | ||
result = api.post_data(log_type, send_list, timeout=30.0) | ||
if result: | ||
logging.info(f'azure api response: {result}') | ||
except (requests.exceptions.ConnectionError, ReadTimeout) as e: | ||
logging.error(f'{e}: error occurred') | ||
|
||
|
||
def azure_data_collector(json_records): | ||
customer_id = Configurations.get_configurations()['AzureCustomerId'] | ||
shared_key = Configurations.get_configurations()['AzureSharedKey'] | ||
log_type = Configurations.get_configurations()['LogName'] | ||
|
||
api = client.DataCollectorAPIClient(customer_id, shared_key) | ||
|
||
numbers_deque = collections.deque(json_records) | ||
|
||
while bool(numbers_deque): | ||
|
||
if len(numbers_deque) > 50: | ||
send_list = [numbers_deque.popleft() for _i in range(49)] | ||
try: | ||
api.post_data(log_type, send_list) | ||
except requests.exceptions.ConnectionError: | ||
logging.error('Connection to Azure can not be established') | ||
azure_api_call(customer_id, shared_key, log_type, send_list) | ||
|
||
else: | ||
send_list = ([numbers_deque.popleft() for _i in range(len(numbers_deque))]) | ||
try: | ||
api.post_data(log_type, send_list) | ||
except requests.exceptions.ConnectionError: | ||
logging.error('Connection to Azure can not be established') | ||
|
||
|
||
|
||
azure_api_call(customer_id, shared_key, log_type, send_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.