Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions austrakka/components/group/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# pylint: disable=expression-not-assigned
import click

from austrakka.components.group.field import field
from austrakka.components.group.funcs import add_group
from austrakka.components.group.funcs import list_group
from austrakka.components.group.funcs import update_group
Expand All @@ -19,7 +18,6 @@ def group(ctx):
ctx.context = ctx.parent.context


group.add_command(field) if show_admin_cmds() else None
group.add_command(role) if show_admin_cmds() else None


Expand Down
47 changes: 0 additions & 47 deletions austrakka/components/group/field/__init__.py

This file was deleted.

57 changes: 0 additions & 57 deletions austrakka/components/group/field/funcs.py

This file was deleted.

4 changes: 4 additions & 0 deletions austrakka/components/org/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=expression-not-assigned
import click

from austrakka.utils.output import table_format_option
Expand All @@ -10,6 +11,8 @@
from austrakka.utils.privilege import ORG_RESOURCE
from austrakka.components.iam.privilege import privilege_subcommands
from austrakka.components.log import log_subcommands
from austrakka.components.org.field import field
from austrakka.utils.cmd_filter import show_admin_cmds
from .funcs import list_orgs
from .funcs import add_org
from .funcs import update_org
Expand All @@ -23,6 +26,7 @@ def org(ctx):

org.add_command(privilege_subcommands(ORG_RESOURCE))
org.add_command(log_subcommands(ORG_RESOURCE))
org.add_command(field) if show_admin_cmds() else None

@org.command('list', help="List organisations")
@table_format_option()
Expand Down
47 changes: 47 additions & 0 deletions austrakka/components/org/field/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import click

from austrakka.utils.output import table_format_option
from austrakka.utils.cmd_filter import hide_admin_cmds
from austrakka.utils.options import *
from .funcs import \
add_field, \
remove_field, \
list_field


@click.group()
@click.pass_context
def field(ctx):
"""Commands related to org fields"""
ctx.context = ctx.parent.context


@field.command('add', hidden=hide_admin_cmds())
@opt_identifier(help="Org identifier")
@opt_field_name()
def group_add_field(identifier, field_names):
'''
Add fields to the data view for the given org
'''
add_field(identifier, field_names)


@field.command('remove', hidden=hide_admin_cmds())
@opt_identifier(help="Org identifier")
@opt_field_name()
def group_remove_field(identifier, field_names):
'''
Remove fields from the data view for the given org
'''
remove_field(identifier, field_names)


@field.command('list', hidden=hide_admin_cmds())
@opt_identifier(help="Org identifier")
@table_format_option()
@opt_view_type()
def group_list_field(identifier: str, out_format: str, view_type: str):
'''
List of fields in data view for the given org
'''
list_field(identifier, out_format, view_type)
44 changes: 44 additions & 0 deletions austrakka/components/org/field/funcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from typing import List

from austrakka.utils.api import api_patch
from austrakka.utils.misc import logger_wraps
from austrakka.utils.output import get_viewtype_columns
from austrakka.utils.paths import ORG_V2_PATH
from austrakka.utils.helpers.output import call_get_and_print


@logger_wraps()
def add_field(identifier: str, field_names: List[str]):
return api_patch(
path=f'{ORG_V2_PATH}/{identifier}/Fields/Add',
data={
"fields": field_names
}
)


@logger_wraps()
def remove_field(identifier: str, field_names: List[str]):
return api_patch(
path=f'{ORG_V2_PATH}/{identifier}/Fields/Remove',
data={
"fields": field_names
}
)


@logger_wraps()
def list_field(identifier: str, out_format: str, view_type: str):
compact_fields = [
"columnName",
"metaDataColumnTypeName",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we got metaDataColumnTypeName as a property throughout the rest of the CLI? If we do then we should just fix them all at once (and maybe backend too) but if not, I think it's worth renaming the first two properties to field and fieldType which matches the names of the commands themselves

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost of all our DTOs have metaDataColumn* rather than field*. I'll make a separate card for it. I think we'll probably want to rename the tables as well

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we do, there is a cleanup card for that

"description",
"primitiveType",
"isActive",
]
columns = get_viewtype_columns(view_type, compact_fields, [])
call_get_and_print(
f'{ORG_V2_PATH}/{identifier}/Fields',
out_format,
restricted_cols=columns,
)
4 changes: 2 additions & 2 deletions austrakka/utils/helpers/output.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict
from typing import Dict, Union, List
from loguru import logger

from austrakka.utils.api import api_get
Expand All @@ -10,7 +10,7 @@ def call_get_and_print(
path: str,
out_format: str,
params: Dict = None,
restricted_cols: list[str] = None,
restricted_cols: Union[List[str], None] = None,
datetime_cols: list[str] = None
):
params = {} if params is None else params
Expand Down
Loading