Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
47e7bb7
support -q flag for ls command
Oct 21, 2025
f17cff4
return error in case all fieled are invalid
Oct 21, 2025
123fb49
fix ws acl ls test
Oct 22, 2025
8b5bae2
support -q in ls test helper
Oct 22, 2025
36df125
Fix type check
Oct 22, 2025
3e45e7c
ls support - filter with Jm Jjmespath
Nov 16, 2025
dba7f6b
fix docs
Nov 18, 2025
13c1be3
update docs & examples
Nov 20, 2025
2b0c04f
add changie row
Nov 20, 2025
676f240
support -q in config ls
Nov 23, 2025
f7376c5
update doces
Nov 23, 2025
faac3e8
revert -q support for config ls and remove nargs
Nov 24, 2025
dfd02d3
fix type check
Nov 24, 2025
4908174
fix
Nov 24, 2025
e42ffd7
revert nargs change
Nov 25, 2025
6318ce9
Merge branch 'main' into dev/aviatcohen/support-quering-ls-command
aviatco Nov 25, 2025
ce86ad3
Merge branch 'main' into dev/aviatcohen/support-quering-ls-command
aviatco Nov 26, 2025
0787e2a
use shlex to split the command into parts
Nov 27, 2025
201c488
Fix create connection with onpre gateway values param to use quotes
Nov 27, 2025
176dd69
align tests with shlex
Nov 27, 2025
c015675
Merge branch 'main' into dev/aviatcohen/support-quering-ls-command
aviatco Nov 27, 2025
39888f7
revert sample_items files, fix run-run tests
Nov 27, 2025
82f5f39
fix tests
Nov 27, 2025
3b67305
record test test_cd_workspace_with_special_characters_success
Nov 27, 2025
929aca2
record test_cd_workspace_with_special_characters_success
Nov 27, 2025
fe3ade1
revert recording of test_cd_workspace_with_special_characters_success
Nov 27, 2025
a0c1650
revert
Nov 27, 2025
84d4a57
skip test_cd_workspace_with_special_characters_success[\']
Nov 27, 2025
1e0c973
fix acl docs typo
Nov 27, 2025
d694053
delete test_cd_workspace_with_special_characters_success[\'] recording
Nov 27, 2025
d19a5e9
Revert the specified assertion change for \.
Nov 27, 2025
58bb555
update changie
Nov 27, 2025
acb6e5f
skip \' test in cd
Nov 30, 2025
b8fe96c
resolve PR comments
Nov 30, 2025
be31ec7
Merge branch 'main' into dev/aviatcohen/support-quering-ls-command
aviatco Nov 30, 2025
9f1bbe9
merge with main
Nov 30, 2025
bd23d87
remove nargs from set - sync with main
Nov 30, 2025
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
5 changes: 4 additions & 1 deletion docs/commands/acls/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ List access control entries for a workspace, item, or OneLake resource.
**Usage:**

```
fab acl ls <path> [-l]
fab acl ls <path> [-l] [-q <fields>]
```

**Parameters:**

- `<path>`: Path to the resource.
- `-l, --long`: Show detailed output. Optional.
- `-q, --query`: Space-separated list of fields to display (e.g., 'identity role'). Shows only specified fields. Optional.

**Examples:**

```
fab acl ls workspace1.workspace
fab acl ls lh1.lakehouse -l
fab acl ls /Files/data -l
fab acl ls workspace1.workspace -q identity # Show only identity column
fab acl ls workspace1.workspace -q "identity name" # Show identity and name columns
```

---
Expand Down
8 changes: 8 additions & 0 deletions docs/examples/acl_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ fab acl ls ws1.Workspace

# List detailed workspace permissions
fab acl ls ws1.Workspace -l

# List specific columns using query parameter
fab acl ls ws1.Workspace -q identity # Show only identity column
fab acl ls ws1.Workspace -q "identity name" # Show identity and name columns
Comment thread
aviatco marked this conversation as resolved.
Outdated
```

#### List Item Permissions
Expand All @@ -47,6 +51,10 @@ fab acl ls ws1.Workspace/lh1.Lakehouse

# List detailed item permissions
fab acl ls ws1.Workspace/lh1.Lakehouse -l

# List specific columns for item permissions
fab acl ls ws1.Workspace/lh1.Lakehouse -q type # Show only type column
fab acl ls ws1.Workspace/lh1.Lakehouse -q "type role" # Show type and role columns
Comment thread
aviatco marked this conversation as resolved.
Outdated
```

#### List OneLake RBAC Permissions
Expand Down
40 changes: 20 additions & 20 deletions src/fabric_cli/commands/acls/fab_acls_ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def _ls_acls_workspace(workspace: Workspace, args: Namespace) -> None:
}
)
sorted_acls = sorted(sorted_acls, key=lambda acl: acl["acl"])
columns = ["acl", "identity", "type"]

columns = (
["acl", "identity", "type", "objectId", "name"]
if show_all
Expand Down Expand Up @@ -132,11 +134,11 @@ def _ls_acls_gateway(gateway: VirtualWorkspaceItem, args: Namespace) -> None:
)

sorted_acls = sorted(sorted_acls, key=lambda acl: acl["role"])
columns = (
["id", "role", "principalId", "principalType"]
if show_all
else ["role", "principalId", "principalType"]
)

columns = ["role", "principalId", "principalType"]
if show_all:
columns.insert(0, "id")

utils_ls.format_and_print_output(
data=sorted_acls,
columns=columns,
Expand Down Expand Up @@ -169,11 +171,10 @@ def _ls_acls_connection(connection: VirtualWorkspaceItem, args: Namespace) -> No
)

sorted_acls = sorted(sorted_acls, key=lambda acl: acl["role"])
columns = (
["id", "role", "principalId", "principalType"]
if show_all
else ["role", "principalId", "principalType"]
)

columns = ["role", "principalId", "principalType"]
if show_all:
columns.insert(0, "id")

utils_ls.format_and_print_output(
data=sorted_acls,
Expand Down Expand Up @@ -221,11 +222,11 @@ def _ls_acls_item(item: Item, args: Namespace) -> None:
)

sorted_acls = sorted(sorted_acls, key=lambda acl: acl["acl"])
columns = (
["acl", "identity", "type", "id", "name"]
if show_all
else ["acl", "identity", "type"]
)

columns = ["acl", "identity", "type"]
if show_all:
columns.extend(["id", "name"])
Comment thread
aviatco marked this conversation as resolved.
Outdated

utils_ls.format_and_print_output(
data=sorted_acls,
columns=columns,
Expand Down Expand Up @@ -292,11 +293,10 @@ def _ls_acls_onelake(context: OneLakeItem, args: Namespace) -> None:
)

sorted_acls = sorted(sorted_acls, key=lambda acl: acl["acl"])
columns = (
["acl", "identity", "type", "details"]
if show_all
else ["acl", "identity", "type"]
)
columns = ["acl", "identity", "type"]
if show_all:
Comment thread
aviatco marked this conversation as resolved.
columns.extend(["id", "name"])

utils_ls.format_and_print_output(
data=sorted_acls,
columns=columns,
Expand Down
1 change: 1 addition & 0 deletions src/fabric_cli/commands/fs/fab_fs_ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@


def exec_command(args, context: FabricElement):
args.long = bool(args.long) if args.long else (args.query is not None and bool(len(args.query) > 1))
Comment thread
aviatco marked this conversation as resolved.
Outdated
if isinstance(context, Tenant):
ls_workspace.exec(context, args)
elif isinstance(context, VirtualWorkspace):
Expand Down
11 changes: 6 additions & 5 deletions src/fabric_cli/commands/fs/ls/fab_fs_ls_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from fabric_cli.core.hiearchy.fab_folder import Folder
from fabric_cli.core.hiearchy.fab_hiearchy import Item, Workspace
from fabric_cli.utils import fab_cmd_fs_utils as utils_fs
from fabric_cli.utils import fab_ui as utils_ui
from fabric_cli.utils import fab_cmd_ls_utils as utils_ls


def exec(workspace: Workspace, args):
Expand All @@ -21,9 +21,10 @@ def exec(workspace: Workspace, args):
show_all or fab_state_config.get_config(fab_constant.FAB_SHOW_HIDDEN) == "true"
)

utils_ui.print_output_format(
utils_ls.format_and_print_output(
sorted_elements_dict,
args,
data=sorted_elements_dict,
hidden_data=VirtualItemContainerType if show_hidden else None,
show_headers=show_details,
show_details,
Comment thread
ayeshurun marked this conversation as resolved.
Outdated
sorted_elements_dict[0].keys() if sorted_elements_dict else [],
Comment thread
aviatco marked this conversation as resolved.
Outdated
VirtualItemContainerType if show_hidden else None,
)
1 change: 1 addition & 0 deletions src/fabric_cli/core/fab_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
ERROR_INVALID_PATH = "InvalidPath"
ERROR_INVALID_PROPERTY = "InvalidProperty"
ERROR_INVALID_DETLA_TABLE = "InvalidDeltaTable"
ERROR_INVALID_QUERY_FIELDS = "InvalidQueryFields"
ERROR_INVALID_WORKSPACE_TYPE = "InvalidWorkspaceType"
ERROR_INTERNAL_SERVER_ERROR = "InternalServerError"
ERROR_UNSUPPORTED_ITEM_TYPE = "UnsupportedItemType"
Expand Down
4 changes: 4 additions & 0 deletions src/fabric_cli/errors/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class CommonErrors:
def invalid_jmespath_query() -> str:
return f"Invalid jmespath query (https://jmespath.org)"

@staticmethod
def invalid_parameter(invalid_fields: list, valid_columns: list) -> str:
Comment thread
aviatco marked this conversation as resolved.
Outdated
return f"Invalid query field(s): {', '.join(invalid_fields)}. Available fields: {', '.join(valid_columns)}"

@staticmethod
def invalid_hostname(hostname: str) -> str:
return f"Invalid hostname for '{hostname}'"
Expand Down
8 changes: 8 additions & 0 deletions src/fabric_cli/parsers/fab_acls_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def register_parser(subparsers: _SubParsersAction) -> None:
action="store_true",
help="Show detailed output. Optional",
)
ls_parser.add_argument(
"-q",
"--query",
Comment thread
aviatco marked this conversation as resolved.
metavar="",
nargs="+",
Comment thread
aviatco marked this conversation as resolved.
Outdated
required=False,
help="Query to filter results. Optional",
)
Comment thread
aviatco marked this conversation as resolved.

ls_parser.usage = f"{utils_error_parser.get_usage_prog(ls_parser)}"
ls_parser.set_defaults(func=acls.ls_command)
Expand Down
12 changes: 11 additions & 1 deletion src/fabric_cli/parsers/fab_fs_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def register_ls_parser(subparsers: _SubParsersAction) -> None:
"# list all workspaces with details",
"$ ls -l\n",
"# list lakehouse tables",
"$ ls ws1.Workspace/lh1.Lakehouse/Tables",
"$ ls ws1.Workspace/lh1.Lakehouse/Tables\n",
"# list items with name matching a pattern",
Comment thread
aviatco marked this conversation as resolved.
"$ ls -q \"contains(name, 'report')\"",
]

ls_parser = subparsers.add_parser(
Expand Down Expand Up @@ -43,6 +45,14 @@ def register_ls_parser(subparsers: _SubParsersAction) -> None:
action="store_true",
help="Show all. Optional",
)
ls_parser.add_argument(
Comment thread
aviatco marked this conversation as resolved.
"-q",
"--query",
metavar="",
nargs="+",
Comment thread
aviatco marked this conversation as resolved.
Outdated
required=False,
help="Query to filter results. Optional",
)

ls_parser.usage = f"{utils_error_parser.get_usage_prog(ls_parser)}"
ls_parser.set_defaults(func=fs.ls_command)
Expand Down
23 changes: 21 additions & 2 deletions src/fabric_cli/utils/fab_cmd_ls_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
from fabric_cli.client import fab_api_capacity as capacity_api
from fabric_cli.client import fab_api_workspace as workspace_api
from fabric_cli.core.hiearchy.fab_hiearchy import VirtualWorkspaceItem
from fabric_cli.errors import ErrorMessages
from fabric_cli.utils import fab_ui as utils_ui

from fabric_cli.core.fab_exceptions import FabricCLIError
from fabric_cli.core import fab_constant

def sort_elements(
elements: list[dict[str, str]], key: str = "name"
Expand Down Expand Up @@ -76,7 +78,24 @@ def format_and_print_output(
columns: list[str] = [],
hidden_data=None,
) -> None:

# Handle query parameter
if hasattr(args, 'query') and args.query:
query_parts = args.query.split() if isinstance(args.query, str) else args.query

# Validate that all query fields exist in available columns
invalid_fields = [field for field in query_parts if field not in columns]
if invalid_fields:
raise FabricCLIError(
ErrorMessages.Common.invalid_parameter(invalid_fields, columns),
fab_constant.ERROR_INVALID_QUERY_FIELDS,
)

if len(query_parts) > 1:
# Multiple query parameters - simulate -l flag
show_details = True
columns = query_parts

# Project only requested columns
filtered_data = [
{key: item[key] for key in columns if key in item} for item in data
]
Expand Down
Loading