Skip to content

Commit

Permalink
bugfixes for QA gold release
Browse files Browse the repository at this point in the history
- axonshell asset-type saved-query add
- axonshell asset-type saved-query copy
  • Loading branch information
Jim Olsen committed Mar 9, 2023
1 parent 03254ff commit b1bec46
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def cmd(ctx, url, key, secret, export_format, table_format, wizard_content, **kw

with ctx.obj.exc_wrap(wraperror=ctx.obj.wraperror):
kwargs = load_wiz(apiobj=apiobj, wizard_content=wizard_content, exprs=True, kwargs=kwargs)
data = apiobj.saved_query.add(as_dataclass=True, echo=True, **kwargs)
data = apiobj.saved_query.add(as_dataclass=True, **kwargs)

ctx.obj.echo_ok(f"Successfully created saved query: {data.name}")
click.secho(EXPORT_FORMATS[export_format](data=data, table_format=table_format))
Expand Down
8 changes: 3 additions & 5 deletions axonius_api_client/cli/grp_assets/grp_saved_query/cmd_copy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Command line interface for Axonius API Client."""
from ...context import CONTEXT_SETTINGS, click
from ...grp_folders.grp_options import OPT_CREATE_FOLDER_REQ, OPT_ECHO, OPT_FOLDER
from ...grp_folders.grp_options import OPTS_OBJECT_CREATE
from ...options import AUTH, add_options
from .grp_common import EXPORT_FORMATS, OPTS_EXPORT

Expand Down Expand Up @@ -59,9 +59,7 @@
show_default=True,
required=False,
),
OPT_ECHO,
OPT_FOLDER,
OPT_CREATE_FOLDER_REQ,
*OPTS_OBJECT_CREATE,
]


Expand All @@ -76,7 +74,7 @@ def cmd(ctx, url, key, secret, export_format, table_format, sq, **kwargs):
apiobj = getattr(client, p_grp)

with ctx.obj.exc_wrap(wraperror=ctx.obj.wraperror):
data = apiobj.saved_query.copy(sq=sq, as_dataclass=True, echo=True, **kwargs)
data = apiobj.saved_query.copy(sq=sq, as_dataclass=True, **kwargs)
ctx.obj.echo_ok(f"Successfully copied Saved Query {sq!r} to {data.name!r}")

click.secho(EXPORT_FORMATS[export_format](data=data, table_format=table_format))
Expand Down
33 changes: 2 additions & 31 deletions axonius_api_client/cli/grp_folders/grp_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,6 @@
from ..options import TABLE_FMT
from .grp_common import SEARCH_EXPORT_DEFAULT, SEARCH_EXPORTS

# OPT_FOLDER = click.option(
# "--folder",
# "-F",
# "folder",
# help="Path of folder to store object in",
# required=False,
# show_envvar=True,
# show_default=True,
# )
# OPT_REQ_FOLDER = click.option(
# "--folder",
# "-F",
# "folder",
# help="Path of folder to store object in",
# required=False,
# show_envvar=True,
# show_default=True,
# )
# OPT_FOLDER_CREATE = click.option(
# "--create/--no-create",
# "-c/-nc",
# "create",
# default=FolderDefaults.create_action,
# help="Create --folder if not found.",
# show_envvar=True,
# show_default=True,
# )
# OPTS_FOLDER = [OPT_FOLDER, OPT_FOLDER_CREATE]
# OPTS_REQ_FOLDER = [OPT_REQ_FOLDER, OPT_FOLDER_CREATE]

OPT_FOLDER = click.option(
"--folder",
"-f",
Expand Down Expand Up @@ -451,13 +421,14 @@
OPT_FOLDER_DELETE,
]

# update-folder
# object.update-folder
OPTS_UPDATE_FOLDER = [
OPT_ECHO,
OPT_CREATE_FOLDER_REQ,
OPT_FOLDER_UPDATE,
]

# object.copy/add/create/etc
OPTS_OBJECT_CREATE = [
OPT_ECHO,
OPT_CREATE_FOLDER_REQ,
Expand Down
16 changes: 8 additions & 8 deletions axonius_api_client/tests/tests_api/tests_folders/test_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import datetime

import pytest

from axonius_api_client.api.json_api import folders
from axonius_api_client.data import BaseEnum
from axonius_api_client.exceptions import ( # SearchZeroObjectsError,
Expand Down Expand Up @@ -1068,13 +1067,14 @@ class TestFolderQueries(FolderBase, FolderBaseQueries):


class TestFoldersQueries(FoldersBase, FolderBaseQueries):
def test_property_path_archive(self, apiobj, jsonapi_module):
root = apiobj.get()

archive_name: str = str(root.get_enum_names().archive)
assert isinstance(root.path_archive, jsonapi_module.FolderModel)
assert root.path_archive.name == archive_name
assert root.path_archive.depth == 1
# NEXT: not in release yet
# def test_property_path_archive(self, apiobj, jsonapi_module):
# root = apiobj.get()

# archive_name: str = str(root.get_enum_names().archive)
# assert isinstance(root.path_archive, jsonapi_module.FolderModel)
# assert root.path_archive.name == archive_name
# assert root.path_archive.depth == 1

def test_property_path_predefined(self, apiobj, jsonapi_module):
root = apiobj.get()
Expand Down

0 comments on commit b1bec46

Please sign in to comment.