Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DPDV-5997] feat: allow query all or selected accounts #127

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions TA_dataset/bin/dataset_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
get_proxy,
get_url,
relative_to_epoch,
get_tenant_related_payload,
)
from solnlib import log
from solnlib.modular_input import checkpointer
Expand Down Expand Up @@ -110,17 +111,8 @@ def stream_events(self, inputs, ew):
ds_headers = {
"Authorization": "Bearer " + acct_dict[ds_acct]["ds_api_key"]
}
if acct_dict.get(ds_acct).get("tenant") is not None:
tenant_value = acct_dict.get(ds_acct).get("tenant")
if tenant_value:
ds_payload.update({"tenant": True})
else:
ds_payload.update(
{
"tenant": False,
"accountIds": acct_dict[ds_acct]["account_ids"],
}
)
tenant_related_payload = get_tenant_related_payload(acct_dict.get(ds_acct))
ds_payload.update(tenant_related_payload)
logger.debug(
"ds payload in power query stream events = {}".format(ds_payload)
)
Expand Down
8 changes: 8 additions & 0 deletions TA_dataset/bin/dataset_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ def get_token_from_config(self, conf, name, logger):

return authn_token

def get_tenant_related_payload(ds_acct):
if ds_acct.get("tenant") is not None:
tenant_value = ds_acct.get("tenant")
if tenant_value:
return {"tenant": True}
return {"tenant": False, "accountIds": ds_acct["account_ids"],}



def get_token(self, account, token_type, logger, config_key=None):
try:
Expand Down
15 changes: 3 additions & 12 deletions TA_dataset/bin/dataset_powerquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import import_declare_test # noqa: F401
import requests
from dataset_api import build_payload, parse_powerquery
from dataset_common import get_acct_info, get_log_level, get_proxy, get_url
from dataset_common import get_acct_info, get_log_level, get_proxy, get_url, get_tenant_related_payload
from solnlib import log
from solnlib.modular_input import checkpointer
from splunklib import modularinput as smi
Expand Down Expand Up @@ -117,17 +117,8 @@ def stream_events(self, inputs, ew):
ds_headers = {
"Authorization": "Bearer " + acct_dict[ds_acct]["ds_api_key"]
}
if acct_dict.get(ds_acct).get("tenant") is not None:
tenant_value = acct_dict.get(ds_acct).get("tenant")
if tenant_value:
ds_payload.update({"tenant": True})
else:
ds_payload.update(
{
"tenant": False,
"accountIds": acct_dict[ds_acct]["account_ids"],
}
)
tenant_related_payload = get_tenant_related_payload(acct_dict.get(ds_acct))
ds_payload.update(tenant_related_payload)
logger.info(
"ds payload in power query stream events = {}".format(ds_payload)
)
Expand Down
14 changes: 3 additions & 11 deletions TA_dataset/bin/dataset_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
get_proxy,
get_url,
relative_to_epoch,
get_tenant_related_payload,
)
from dataset_query_api_client.client import get_user_agent
from solnlib.modular_input import checkpointer
Expand Down Expand Up @@ -144,17 +145,8 @@ def stream_events(self, inputs, ew):
proxy = get_proxy(session_key, logger)
acct_dict = get_acct_info(self, logger, ds_account)
for ds_acct in acct_dict.keys():
if acct_dict.get(ds_acct).get("tenant") is not None:
tenant_value = acct_dict.get(ds_acct).get("tenant")
if tenant_value:
ds_payload.update({"tenant": True})
else:
ds_payload.update(
{
"tenant": False,
"accountIds": acct_dict[ds_acct]["account_ids"],
}
)
tenant_related_payload = get_tenant_related_payload(acct_dict.get(ds_acct))
ds_payload.update(tenant_related_payload)
curr_payload = copy.deepcopy(ds_payload)
logger.info("query api account curr payload {}".format(curr_payload))
curr_maxcount = copy.copy(ds_maxcount)
Expand Down
14 changes: 3 additions & 11 deletions TA_dataset/bin/dataset_search_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
get_url,
logger,
relative_to_epoch,
get_tenant_related_payload,
)

# Dataset V2 API client (generated)
Expand Down Expand Up @@ -442,17 +443,8 @@ def generate(self):
"DataSetFunction=makeRequest, destination={}, startTime={}"
.format(ds_url, time.time())
)
if acct_dict.get(ds_acct).get("tenant") is not None:
tenant_value = acct_dict.get(ds_acct).get("tenant")
if tenant_value:
ds_payload.update({"tenant": True})
else:
ds_payload.update(
{
"tenant": False,
"accountIds": acct_dict[ds_acct]["account_ids"],
}
)
tenant_related_payload = get_tenant_related_payload(acct_dict.get(ds_acct))
ds_payload.update(tenant_related_payload)
logger.info(
"The paylaod for the timeseries api {}".format(ds_payload)
)
Expand Down
2 changes: 1 addition & 1 deletion globalConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"field": "dataset_log_read_access_key",
"label": "DataSet Log Read Access Key",
"type": "text",
"help": "Required to enable inputs and SPL comand. Include trailing hyphens if applicable.",
"help": "Required to enable inputs and SPL comand. Include trailing hyphens if applicable. Please ignore this if AuthN token value is provided.",
zdaratom-s1 marked this conversation as resolved.
Show resolved Hide resolved
zdaratom-s1 marked this conversation as resolved.
Show resolved Hide resolved
"required": false,
"defaultValue": "",
"encrypted": true,
Expand Down
Loading