Skip to content

Commit

Permalink
Merge pull request #224 from Axonius/develop
Browse files Browse the repository at this point in the history
4.60.0
  • Loading branch information
nate-axonius committed Mar 8, 2023
2 parents e97fa8d + 03254ff commit 28058cf
Show file tree
Hide file tree
Showing 179 changed files with 8,999 additions and 1,948 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ lint:
pipenv run isort $(PACKAGE) setup.py shell.py
pipenv run black -l 100 $(PACKAGE) setup.py shell.py
pipenv run flake8 --max-line-length 100 --exclude $(PACKAGE)/tests --exclude $(PACKAGE)/examples $(PACKAGE) setup.py shell.py
# XXX DISABLED FOR NOW
# TBD DISABLED FOR NOW
# pipenv run pydocstyle \
# --match-dir='(?!tests).*'\
# --match-dir='(?!examples).*' \
Expand Down
4 changes: 2 additions & 2 deletions axonius_api_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@
Instances,
Meta,
RemoteSupport,
Runner,
SettingsGlobal,
SettingsGui,
SettingsLifecycle,
Signup,
SystemRoles,
SystemUsers,
Users,
Vulnerabilities,
Wizard,
WizardCsv,
WizardText,
Vulnerabilities,
Runner,
)
from .auth import ApiKey
from .connect import Connect
Expand Down
2 changes: 2 additions & 0 deletions axonius_api_client/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .api_endpoints import ApiEndpoints
from .assets import Devices, Runner, Users, Vulnerabilities
from .enforcements import Enforcements
from .folders import Folders
from .openapi import OpenAPISpec
from .system import (
ActivityLogs,
Expand Down Expand Up @@ -55,4 +56,5 @@
"OpenAPISpec",
"DataScopes",
"Vulnerabilities",
"Folders",
)
19 changes: 13 additions & 6 deletions axonius_api_client/api/adapters/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
HIST_GEN = t.Generator[HIST_MOD, None, None]
HIST_LIST = t.List[HIST_MOD]

CACHE_HISTORY_FILTERS: TTLCache = TTLCache(maxsize=4096, ttl=30)
CACHE_HISTORY_FILTERS: TTLCache = TTLCache(maxsize=4096, ttl=60)
CACHE_GET_BASIC: TTLCache = TTLCache(maxsize=1024, ttl=60)


class Adapters(ModelMixins):
Expand Down Expand Up @@ -77,9 +78,8 @@ def get(self, get_clients: bool = False) -> t.List[dict]:
t.List[dict]: list of adapter metadata
"""
basic_data = self._get_basic()
return [
adapter_node.to_dict_old(basic_data=basic_data.adapters)
adapter_node.to_dict_old()
for adapter in self._get(get_clients=get_clients)
for adapter_node in adapter.adapter_nodes
]
Expand All @@ -93,7 +93,7 @@ def get_by_name_basic(self, value: str) -> dict:
Returns:
dict: adapter basic metadata
"""
data = self._get_basic()
data = self.get_basic()
return data.find_by_name(value=value)

def get_by_name(
Expand Down Expand Up @@ -154,6 +154,15 @@ def get_by_name(
err = f"No adapter named {name!r} found on instance {node_name!r}"
raise NotFoundError(tablize_adapters(adapters=adapters, err=err))

@cached(cache=CACHE_GET_BASIC)
def get_basic_cached(self) -> AdaptersList:
"""Get basic adapter data cached."""
return self.get_basic()

def get_basic(self) -> AdaptersList:
"""Get basic adapter data."""
return self._get_basic()

@cached(cache=CACHE_HISTORY_FILTERS)
def get_fetch_history_filters(self) -> AdapterFetchHistoryFilters:
"""Get filter values for use in adapters history."""
Expand Down Expand Up @@ -389,8 +398,6 @@ def config_update(
... name="aws", config_type="specific", fetch_s3=True
... )
Update the discovery advanced settings
>>> # XXX currently broken!
Args:
name (str): name of adapter to update advanced settings of
Expand Down
4 changes: 2 additions & 2 deletions axonius_api_client/api/adapters/cnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def add(
tunnel=tunnel_id,
)

if not result.working or not cnx_new["working"]:
if not result.working and not cnx_new["working"]:
err = f"Connection was added but had a failure connecting:\n{result}"
exc = CnxAddError(err)
exc.result = result
Expand Down Expand Up @@ -673,7 +673,7 @@ def update_cnx(
tunnel=tunnel_id_new,
)

if not result.working or not cnx_new["working"]:
if not result.working and not cnx_new["working"]:
err = f"Connection configuration was updated but had a failure connecting:\n{result}"
exc = CnxUpdateError(err)
exc.result = result
Expand Down
Loading

0 comments on commit 28058cf

Please sign in to comment.