entropy-data-cli 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,93 @@
1
+ """Data products commands."""
2
+
3
+ from pathlib import Path
4
+ from typing import Annotated, Optional
5
+
6
+ import typer
7
+
8
+ from entropy_data_cli.output import OutputFormat, print_link, print_resource, print_resource_list, print_success
9
+ from entropy_data_cli.util import read_body
10
+
11
+ dataproducts_app = typer.Typer(no_args_is_help=True)
12
+ RESOURCE_PATH = "dataproducts"
13
+ RESOURCE_TYPE = "dataproducts"
14
+
15
+
16
+ @dataproducts_app.command("list")
17
+ def list_dataproducts(
18
+ page: Annotated[int, typer.Option("--page", "-p", help="Page number (0-indexed).")] = 0,
19
+ query: Annotated[Optional[str], typer.Option("--query", "-q", help="Search term.")] = None,
20
+ status: Annotated[Optional[str], typer.Option("--status", help="Filter by status.")] = None,
21
+ tag: Annotated[Optional[str], typer.Option("--tag", help="Filter by tag.")] = None,
22
+ sort: Annotated[Optional[str], typer.Option("--sort", help="Sort field.")] = None,
23
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
24
+ ) -> None:
25
+ """List all data products."""
26
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
27
+
28
+ fmt = output or get_output_format()
29
+ try:
30
+ client = get_client()
31
+ params = {"p": page}
32
+ if query:
33
+ params["q"] = query
34
+ if status:
35
+ params["status"] = status
36
+ if tag:
37
+ params["tag"] = tag
38
+ if sort:
39
+ params["sort"] = sort
40
+ data, has_next = client.list_resources(RESOURCE_PATH, params=params)
41
+ print_resource_list(data, RESOURCE_TYPE, fmt, has_next_page=has_next, page=page)
42
+ except Exception as e:
43
+ handle_error(e)
44
+
45
+
46
+ @dataproducts_app.command("get")
47
+ def get_dataproduct(
48
+ id: Annotated[str, typer.Argument(help="Data product ID.")],
49
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
50
+ ) -> None:
51
+ """Get a data product by ID."""
52
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
53
+
54
+ fmt = output or get_output_format()
55
+ try:
56
+ client = get_client()
57
+ data = client.get_resource(RESOURCE_PATH, id)
58
+ print_resource(data, RESOURCE_TYPE, fmt)
59
+ except Exception as e:
60
+ handle_error(e)
61
+
62
+
63
+ @dataproducts_app.command("put")
64
+ def put_dataproduct(
65
+ id: Annotated[str, typer.Argument(help="Data product ID.")],
66
+ file: Annotated[Path, typer.Option("--file", "-f", help="JSON or YAML file (use - for stdin).")] = ...,
67
+ ) -> None:
68
+ """Create or update a data product."""
69
+ from entropy_data_cli.cli import get_client, handle_error
70
+
71
+ try:
72
+ body = read_body(file)
73
+ client = get_client()
74
+ location = client.put_resource(RESOURCE_PATH, id, body)
75
+ print_success(f"Data product '{id}' saved.")
76
+ print_link(location)
77
+ except Exception as e:
78
+ handle_error(e)
79
+
80
+
81
+ @dataproducts_app.command("delete")
82
+ def delete_dataproduct(
83
+ id: Annotated[str, typer.Argument(help="Data product ID.")],
84
+ ) -> None:
85
+ """Delete a data product."""
86
+ from entropy_data_cli.cli import get_client, handle_error
87
+
88
+ try:
89
+ client = get_client()
90
+ client.delete_resource(RESOURCE_PATH, id)
91
+ print_success(f"Data product '{id}' deleted.")
92
+ except Exception as e:
93
+ handle_error(e)
@@ -0,0 +1,80 @@
1
+ """Definitions commands."""
2
+
3
+ from pathlib import Path
4
+ from typing import Annotated, Optional
5
+
6
+ import typer
7
+
8
+ from entropy_data_cli.output import OutputFormat, print_link, print_resource, print_resource_list, print_success
9
+ from entropy_data_cli.util import read_body
10
+
11
+ definitions_app = typer.Typer(no_args_is_help=True)
12
+ RESOURCE_PATH = "definitions"
13
+ RESOURCE_TYPE = "definitions"
14
+
15
+
16
+ @definitions_app.command("list")
17
+ def list_definitions(
18
+ page: Annotated[int, typer.Option("--page", "-p", help="Page number (0-indexed).")] = 0,
19
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
20
+ ) -> None:
21
+ """List all definitions."""
22
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
23
+
24
+ fmt = output or get_output_format()
25
+ try:
26
+ client = get_client()
27
+ data, has_next = client.list_resources(RESOURCE_PATH, params={"p": page})
28
+ print_resource_list(data, RESOURCE_TYPE, fmt, has_next_page=has_next, page=page)
29
+ except Exception as e:
30
+ handle_error(e)
31
+
32
+
33
+ @definitions_app.command("get")
34
+ def get_definition(
35
+ id: Annotated[str, typer.Argument(help="Definition ID.")],
36
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
37
+ ) -> None:
38
+ """Get a definition by ID."""
39
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
40
+
41
+ fmt = output or get_output_format()
42
+ try:
43
+ client = get_client()
44
+ data = client.get_resource(RESOURCE_PATH, id)
45
+ print_resource(data, RESOURCE_TYPE, fmt)
46
+ except Exception as e:
47
+ handle_error(e)
48
+
49
+
50
+ @definitions_app.command("put")
51
+ def put_definition(
52
+ id: Annotated[str, typer.Argument(help="Definition ID.")],
53
+ file: Annotated[Path, typer.Option("--file", "-f", help="JSON or YAML file (use - for stdin).")] = ...,
54
+ ) -> None:
55
+ """Create or update a definition."""
56
+ from entropy_data_cli.cli import get_client, handle_error
57
+
58
+ try:
59
+ body = read_body(file)
60
+ client = get_client()
61
+ location = client.put_resource(RESOURCE_PATH, id, body)
62
+ print_success(f"Definition '{id}' saved.")
63
+ print_link(location)
64
+ except Exception as e:
65
+ handle_error(e)
66
+
67
+
68
+ @definitions_app.command("delete")
69
+ def delete_definition(
70
+ id: Annotated[str, typer.Argument(help="Definition ID.")],
71
+ ) -> None:
72
+ """Delete a definition."""
73
+ from entropy_data_cli.cli import get_client, handle_error
74
+
75
+ try:
76
+ client = get_client()
77
+ client.delete_resource(RESOURCE_PATH, id)
78
+ print_success(f"Definition '{id}' deleted.")
79
+ except Exception as e:
80
+ handle_error(e)
@@ -0,0 +1,32 @@
1
+ """Events commands."""
2
+
3
+ import json
4
+ from typing import Annotated, Optional
5
+
6
+ import typer
7
+
8
+ from entropy_data_cli.output import OutputFormat, console, print_resource_list
9
+
10
+ events_app = typer.Typer(no_args_is_help=True)
11
+
12
+
13
+ @events_app.command("poll")
14
+ def poll_events(
15
+ last_event_id: Annotated[
16
+ Optional[str], typer.Option("--last-event-id", help="Last event ID for incremental polling.")
17
+ ] = None,
18
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
19
+ ) -> None:
20
+ """Poll for events."""
21
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
22
+
23
+ fmt = output or get_output_format()
24
+ try:
25
+ client = get_client()
26
+ data = client.get_events(last_event_id=last_event_id)
27
+ if fmt == OutputFormat.json:
28
+ console.print_json(json.dumps(data))
29
+ else:
30
+ print_resource_list(data, "events", fmt)
31
+ except Exception as e:
32
+ handle_error(e)
@@ -0,0 +1,83 @@
1
+ """Example data commands."""
2
+
3
+ from pathlib import Path
4
+ from typing import Annotated, Optional
5
+
6
+ import typer
7
+
8
+ from entropy_data_cli.output import OutputFormat, print_link, print_resource, print_resource_list, print_success
9
+ from entropy_data_cli.util import read_body
10
+
11
+ example_data_app = typer.Typer(no_args_is_help=True)
12
+ RESOURCE_PATH = "example-data"
13
+ RESOURCE_TYPE = "example-data"
14
+
15
+
16
+ @example_data_app.command("list")
17
+ def list_example_data(
18
+ data_product_id: Annotated[Optional[str], typer.Option("--data-product-id", help="Filter by data product.")] = None,
19
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
20
+ ) -> None:
21
+ """List all example data entries."""
22
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
23
+
24
+ fmt = output or get_output_format()
25
+ try:
26
+ client = get_client()
27
+ params = {}
28
+ if data_product_id:
29
+ params["dataProductId"] = data_product_id
30
+ data, has_next = client.list_resources(RESOURCE_PATH, params=params or None)
31
+ print_resource_list(data, RESOURCE_TYPE, fmt, has_next_page=has_next)
32
+ except Exception as e:
33
+ handle_error(e)
34
+
35
+
36
+ @example_data_app.command("get")
37
+ def get_example_data(
38
+ id: Annotated[str, typer.Argument(help="Example data ID.")],
39
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
40
+ ) -> None:
41
+ """Get example data by ID."""
42
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
43
+
44
+ fmt = output or get_output_format()
45
+ try:
46
+ client = get_client()
47
+ data = client.get_resource(RESOURCE_PATH, id)
48
+ print_resource(data, RESOURCE_TYPE, fmt)
49
+ except Exception as e:
50
+ handle_error(e)
51
+
52
+
53
+ @example_data_app.command("put")
54
+ def put_example_data(
55
+ id: Annotated[str, typer.Argument(help="Example data ID.")],
56
+ file: Annotated[Path, typer.Option("--file", "-f", help="JSON or YAML file (use - for stdin).")] = ...,
57
+ ) -> None:
58
+ """Create or update example data."""
59
+ from entropy_data_cli.cli import get_client, handle_error
60
+
61
+ try:
62
+ body = read_body(file)
63
+ client = get_client()
64
+ location = client.put_resource(RESOURCE_PATH, id, body)
65
+ print_success(f"Example data '{id}' saved.")
66
+ print_link(location)
67
+ except Exception as e:
68
+ handle_error(e)
69
+
70
+
71
+ @example_data_app.command("delete")
72
+ def delete_example_data(
73
+ id: Annotated[str, typer.Argument(help="Example data ID.")],
74
+ ) -> None:
75
+ """Delete example data."""
76
+ from entropy_data_cli.cli import get_client, handle_error
77
+
78
+ try:
79
+ client = get_client()
80
+ client.delete_resource(RESOURCE_PATH, id)
81
+ print_success(f"Example data '{id}' deleted.")
82
+ except Exception as e:
83
+ handle_error(e)
@@ -0,0 +1,55 @@
1
+ """Search commands."""
2
+
3
+ import json
4
+ from typing import Annotated, Optional
5
+
6
+ import typer
7
+
8
+ from entropy_data_cli.output import OutputFormat, console
9
+
10
+ search_app = typer.Typer(no_args_is_help=True)
11
+
12
+
13
+ @search_app.command("query")
14
+ def search_query(
15
+ query: Annotated[str, typer.Argument(help="Search query.")],
16
+ resource_type: Annotated[
17
+ Optional[str], typer.Option("--resource-type", "-t", help="Filter by resource type.")
18
+ ] = None,
19
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
20
+ ) -> None:
21
+ """Search across all resources."""
22
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
23
+
24
+ fmt = output or get_output_format()
25
+ try:
26
+ client = get_client()
27
+ params = {}
28
+ if resource_type:
29
+ params["resourceType"] = resource_type
30
+ data = client.search(query, **params)
31
+
32
+ if fmt == OutputFormat.json:
33
+ console.print_json(json.dumps(data))
34
+ return
35
+
36
+ # Table output for search results
37
+ results = data if isinstance(data, list) else data.get("results", data.get("items", [data]))
38
+ if isinstance(results, list):
39
+ from rich.table import Table
40
+
41
+ table = Table(show_header=True, title="Search Results")
42
+ table.add_column("Type")
43
+ table.add_column("ID")
44
+ table.add_column("Title")
45
+ for item in results:
46
+ table.add_row(
47
+ str(item.get("resourceType", item.get("type", ""))),
48
+ str(item.get("id", "")),
49
+ str(item.get("title", item.get("name", ""))),
50
+ )
51
+ console.print(table)
52
+ else:
53
+ console.print_json(json.dumps(data))
54
+ except Exception as e:
55
+ handle_error(e)
@@ -0,0 +1,80 @@
1
+ """Source systems commands."""
2
+
3
+ from pathlib import Path
4
+ from typing import Annotated, Optional
5
+
6
+ import typer
7
+
8
+ from entropy_data_cli.output import OutputFormat, print_link, print_resource, print_resource_list, print_success
9
+ from entropy_data_cli.util import read_body
10
+
11
+ sourcesystems_app = typer.Typer(no_args_is_help=True)
12
+ RESOURCE_PATH = "sourcesystems"
13
+ RESOURCE_TYPE = "sourcesystems"
14
+
15
+
16
+ @sourcesystems_app.command("list")
17
+ def list_sourcesystems(
18
+ page: Annotated[int, typer.Option("--page", "-p", help="Page number (0-indexed).")] = 0,
19
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
20
+ ) -> None:
21
+ """List all source systems."""
22
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
23
+
24
+ fmt = output or get_output_format()
25
+ try:
26
+ client = get_client()
27
+ data, has_next = client.list_resources(RESOURCE_PATH, params={"p": page})
28
+ print_resource_list(data, RESOURCE_TYPE, fmt, has_next_page=has_next, page=page)
29
+ except Exception as e:
30
+ handle_error(e)
31
+
32
+
33
+ @sourcesystems_app.command("get")
34
+ def get_sourcesystem(
35
+ id: Annotated[str, typer.Argument(help="Source system ID.")],
36
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
37
+ ) -> None:
38
+ """Get a source system by ID."""
39
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
40
+
41
+ fmt = output or get_output_format()
42
+ try:
43
+ client = get_client()
44
+ data = client.get_resource(RESOURCE_PATH, id)
45
+ print_resource(data, RESOURCE_TYPE, fmt)
46
+ except Exception as e:
47
+ handle_error(e)
48
+
49
+
50
+ @sourcesystems_app.command("put")
51
+ def put_sourcesystem(
52
+ id: Annotated[str, typer.Argument(help="Source system ID.")],
53
+ file: Annotated[Path, typer.Option("--file", "-f", help="JSON or YAML file (use - for stdin).")] = ...,
54
+ ) -> None:
55
+ """Create or update a source system."""
56
+ from entropy_data_cli.cli import get_client, handle_error
57
+
58
+ try:
59
+ body = read_body(file)
60
+ client = get_client()
61
+ location = client.put_resource(RESOURCE_PATH, id, body)
62
+ print_success(f"Source system '{id}' saved.")
63
+ print_link(location)
64
+ except Exception as e:
65
+ handle_error(e)
66
+
67
+
68
+ @sourcesystems_app.command("delete")
69
+ def delete_sourcesystem(
70
+ id: Annotated[str, typer.Argument(help="Source system ID.")],
71
+ ) -> None:
72
+ """Delete a source system."""
73
+ from entropy_data_cli.cli import get_client, handle_error
74
+
75
+ try:
76
+ client = get_client()
77
+ client.delete_resource(RESOURCE_PATH, id)
78
+ print_success(f"Source system '{id}' deleted.")
79
+ except Exception as e:
80
+ handle_error(e)
@@ -0,0 +1,80 @@
1
+ """Teams commands."""
2
+
3
+ from pathlib import Path
4
+ from typing import Annotated, Optional
5
+
6
+ import typer
7
+
8
+ from entropy_data_cli.output import OutputFormat, print_link, print_resource, print_resource_list, print_success
9
+ from entropy_data_cli.util import read_body
10
+
11
+ teams_app = typer.Typer(no_args_is_help=True)
12
+ RESOURCE_PATH = "teams"
13
+ RESOURCE_TYPE = "teams"
14
+
15
+
16
+ @teams_app.command("list")
17
+ def list_teams(
18
+ page: Annotated[int, typer.Option("--page", "-p", help="Page number (0-indexed).")] = 0,
19
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
20
+ ) -> None:
21
+ """List all teams."""
22
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
23
+
24
+ fmt = output or get_output_format()
25
+ try:
26
+ client = get_client()
27
+ data, has_next = client.list_resources(RESOURCE_PATH, params={"p": page})
28
+ print_resource_list(data, RESOURCE_TYPE, fmt, has_next_page=has_next, page=page)
29
+ except Exception as e:
30
+ handle_error(e)
31
+
32
+
33
+ @teams_app.command("get")
34
+ def get_team(
35
+ id: Annotated[str, typer.Argument(help="Team ID.")],
36
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
37
+ ) -> None:
38
+ """Get a team by ID."""
39
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
40
+
41
+ fmt = output or get_output_format()
42
+ try:
43
+ client = get_client()
44
+ data = client.get_resource(RESOURCE_PATH, id)
45
+ print_resource(data, RESOURCE_TYPE, fmt)
46
+ except Exception as e:
47
+ handle_error(e)
48
+
49
+
50
+ @teams_app.command("put")
51
+ def put_team(
52
+ id: Annotated[str, typer.Argument(help="Team ID.")],
53
+ file: Annotated[Path, typer.Option("--file", "-f", help="JSON or YAML file (use - for stdin).")] = ...,
54
+ ) -> None:
55
+ """Create or update a team."""
56
+ from entropy_data_cli.cli import get_client, handle_error
57
+
58
+ try:
59
+ body = read_body(file)
60
+ client = get_client()
61
+ location = client.put_resource(RESOURCE_PATH, id, body)
62
+ print_success(f"Team '{id}' saved.")
63
+ print_link(location)
64
+ except Exception as e:
65
+ handle_error(e)
66
+
67
+
68
+ @teams_app.command("delete")
69
+ def delete_team(
70
+ id: Annotated[str, typer.Argument(help="Team ID.")],
71
+ ) -> None:
72
+ """Delete a team."""
73
+ from entropy_data_cli.cli import get_client, handle_error
74
+
75
+ try:
76
+ client = get_client()
77
+ client.delete_resource(RESOURCE_PATH, id)
78
+ print_success(f"Team '{id}' deleted.")
79
+ except Exception as e:
80
+ handle_error(e)
@@ -0,0 +1,85 @@
1
+ """Test results commands."""
2
+
3
+ from pathlib import Path
4
+ from typing import Annotated, Optional
5
+
6
+ import typer
7
+
8
+ from entropy_data_cli.output import OutputFormat, print_link, print_resource, print_resource_list, print_success
9
+ from entropy_data_cli.util import read_body
10
+
11
+ test_results_app = typer.Typer(no_args_is_help=True)
12
+ RESOURCE_PATH = "test-results"
13
+ RESOURCE_TYPE = "test-results"
14
+
15
+
16
+ @test_results_app.command("list")
17
+ def list_test_results(
18
+ page: Annotated[int, typer.Option("--page", "-p", help="Page number (0-indexed).")] = 0,
19
+ data_contract_id: Annotated[
20
+ Optional[str], typer.Option("--data-contract-id", help="Filter by data contract.")
21
+ ] = None,
22
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
23
+ ) -> None:
24
+ """List all test results."""
25
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
26
+
27
+ fmt = output or get_output_format()
28
+ try:
29
+ client = get_client()
30
+ params = {"p": page}
31
+ if data_contract_id:
32
+ params["dataContractId"] = data_contract_id
33
+ data, has_next = client.list_resources(RESOURCE_PATH, params=params)
34
+ print_resource_list(data, RESOURCE_TYPE, fmt, has_next_page=has_next, page=page)
35
+ except Exception as e:
36
+ handle_error(e)
37
+
38
+
39
+ @test_results_app.command("get")
40
+ def get_test_result(
41
+ id: Annotated[str, typer.Argument(help="Test result ID.")],
42
+ output: Annotated[Optional[OutputFormat], typer.Option("--output", "-o", help="Output format.")] = None,
43
+ ) -> None:
44
+ """Get a test result by ID."""
45
+ from entropy_data_cli.cli import get_client, get_output_format, handle_error
46
+
47
+ fmt = output or get_output_format()
48
+ try:
49
+ client = get_client()
50
+ data = client.get_resource(RESOURCE_PATH, id)
51
+ print_resource(data, RESOURCE_TYPE, fmt)
52
+ except Exception as e:
53
+ handle_error(e)
54
+
55
+
56
+ @test_results_app.command("publish")
57
+ def publish_test_results(
58
+ file: Annotated[Path, typer.Option("--file", "-f", help="JSON or YAML file (use - for stdin).")] = ...,
59
+ ) -> None:
60
+ """Publish test results."""
61
+ from entropy_data_cli.cli import get_client, handle_error
62
+
63
+ try:
64
+ body = read_body(file)
65
+ client = get_client()
66
+ location = client.post_resource(RESOURCE_PATH, body)
67
+ print_success("Test results published.")
68
+ print_link(location)
69
+ except Exception as e:
70
+ handle_error(e)
71
+
72
+
73
+ @test_results_app.command("delete")
74
+ def delete_test_result(
75
+ id: Annotated[str, typer.Argument(help="Test result ID.")],
76
+ ) -> None:
77
+ """Delete a test result."""
78
+ from entropy_data_cli.cli import get_client, handle_error
79
+
80
+ try:
81
+ client = get_client()
82
+ client.delete_resource(RESOURCE_PATH, id)
83
+ print_success(f"Test result '{id}' deleted.")
84
+ except Exception as e:
85
+ handle_error(e)