Skip to content

Commit

Permalink
Merge pull request #240 from Axonius/SA-3421/feature/enforcement_tasks
Browse files Browse the repository at this point in the history
Sa 3421/feature/enforcement tasks
  • Loading branch information
Jim Olsen committed May 1, 2023
2 parents 19a6f42 + 1eadac2 commit e1cb134
Show file tree
Hide file tree
Showing 250 changed files with 16,573 additions and 7,855 deletions.
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.8.10
3.11.2
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include MANIFEST.in
include requirements*.txt
include axonius_api_client/cert_human/all_logs_list.json
include axonius_api_client/projects/cert_human/all_logs_list.json
graft axonius_api_client/tests/datafiles/
global-exclude __pycache__
global-exclude *.py[co]
Expand Down
43 changes: 40 additions & 3 deletions axonius_api_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
"""
import logging
import sys
import pathlib

from . import setup_env, version

PACKAGE_ROOT: str = __package__
PACKAGE_FILE: str = __file__
PACKAGE_PATH: pathlib.Path = pathlib.Path(PACKAGE_FILE).parent.absolute()
PROJECTS_PATH: pathlib.Path = PACKAGE_PATH / "projects"

VERSION: str = version.__version__
__version__ = VERSION

Expand All @@ -32,8 +37,30 @@
POST_DOTENV: dict = setup_env.get_env_ax()
"""AX.* env variables after loading dotenv."""

# short term hack for projects until they are moved to their own repos
try:
from . import api, auth, cert_human, cli, constants, data, exceptions, http, logs, tools
sys.path.insert(0, str(PROJECTS_PATH))
from .projects import cf_token, cert_human, url_parser

except Exception: # pragma: no cover
raise


try:
# noinspection PyCompatibility
from . import (
api,
auth,
cli,
constants,
data,
exceptions,
http,
logs,
tools,
projects,
)

from .api import (
ActivityLogs,
Adapters,
Expand All @@ -58,8 +85,9 @@
Wizard,
WizardCsv,
WizardText,
json_api,
)
from .auth import ApiKey
from .auth import AuthApiKey, AuthCredentials, AuthModel, AuthNull
from .connect import Connect
from .features import Features
from .http import Http
Expand All @@ -70,12 +98,16 @@
LOG = logs.LOG

__all__ = (
"PACKAGE_ROOT",
# API client
"Connect",
# HTTP client
"Http",
# API authentication
"ApiKey",
"AuthApiKey",
"AuthModel",
"AuthCredentials",
"AuthNull",
# API
"Adapters",
"Cnx",
Expand Down Expand Up @@ -115,5 +147,10 @@
"logs",
"tools",
"version",
"json_api",
# projects
"projects",
"cert_human",
"cf_token",
"url_parser",
)
6 changes: 5 additions & 1 deletion axonius_api_client/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from .adapters import Adapters, Cnx
from .api_endpoint import ApiEndpoint
from .api_endpoints import ApiEndpoints
from .assets import Devices, Runner, Users, Vulnerabilities
from .assets import Devices, Runner, Users, Vulnerabilities, AssetMixin
from .enforcements import Enforcements
from .folders import Folders
from .mixins import ChildMixins, ModelMixins
from .openapi import OpenAPISpec
from .system import (
ActivityLogs,
Expand Down Expand Up @@ -57,4 +58,7 @@
"DataScopes",
"Vulnerabilities",
"Folders",
"ModelMixins",
"ChildMixins",
"AssetMixin",
)
8 changes: 4 additions & 4 deletions axonius_api_client/api/adapters/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
from ..api_endpoints import ApiEndpoints
from ..json_api.adapters import (
Adapter,
AdapterFetchHistory,
AdapterFetchHistoryFilters,
AdapterFetchHistoryRequest,
AdapterSettings,
AdaptersList,
CnxLabels,
AdapterFetchHistory,
AdapterFetchHistoryFilters,
)
from ..json_api.paging_state import PagingState
from ..json_api.system_settings import SystemSettings
Expand Down Expand Up @@ -461,7 +461,7 @@ def file_upload(
Args:
name: name of adapter to upload file to
node: name of node to to upload file to
node: name of node to upload file to
field_name: name of field (should match configuration schema key name)
file_name: name of file to upload
file_content: content of file to upload
Expand Down Expand Up @@ -622,7 +622,7 @@ def _get_labels(self) -> CnxLabels:
Returns:
CnxLabels: dataclass model containing response
"""
api_endpoint = ApiEndpoints.adapters.labels_get
api_endpoint = ApiEndpoints.adapters.cnx_get_labels
response = api_endpoint.perform_request(http=self.http)
return response

Expand Down
16 changes: 12 additions & 4 deletions axonius_api_client/api/adapters/cnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
strip_right,
)
from ..api_endpoints import ApiEndpoints
from ..json_api.adapters import CnxDelete, CnxModifyResponse, Cnxs
from ..json_api.adapters import CnxCreate, CnxDelete, CnxLabels, Cnxs, CnxUpdate
from ..json_api.instances import Tunnel
from ..mixins import ChildMixins

Expand Down Expand Up @@ -845,7 +845,7 @@ def cb_file_upload(
Raises:
:exc:`ConfigInvalidValue`: When value is a path that does not exist, or
a dictionary that does not have 'uuid' and 'filename' keys',
a dictionary that does not have 'uuid' and 'filename' keys,
or if value is not a file
"""

Expand Down Expand Up @@ -901,7 +901,7 @@ def _add(
connection_label: Optional[str] = None,
tunnel_id: Optional[str] = None,
response_status_hook: Optional[Callable] = None,
) -> CnxModifyResponse:
) -> CnxCreate:
"""Pass."""
api_endpoint = ApiEndpoints.adapters.cnx_create
request_obj = api_endpoint.load_request(
Expand Down Expand Up @@ -971,6 +971,14 @@ def _get(self, adapter_name: str) -> Cnxs:
ret.adapter_name = strip_right(obj=adapter_name, fix="_adapter")
return ret

def _get_labels(self) -> CnxLabels:
"""Get all connection labels.
Returns:
CnxLabels: dataclass model containing response
"""
return ApiEndpoints.adapters.cnx_get_labels.perform_request(http=self.auth.http)

def _delete(
self,
uuid: str,
Expand Down Expand Up @@ -1027,7 +1035,7 @@ def _update(
active: bool = True,
connection_label: Optional[str] = None,
response_status_hook: Optional[Callable] = None,
) -> CnxModifyResponse:
) -> CnxUpdate:
"""Pass.
Args:
Expand Down

0 comments on commit e1cb134

Please sign in to comment.