|
4 | 4 | from typing_extensions import Annotated |
5 | 5 | from typing import List |
6 | 6 | from pyaxm.client import Client |
| 7 | +from pyaxm.utils import download_activity_csv |
7 | 8 |
|
8 | 9 | app = typer.Typer() |
9 | 10 |
|
@@ -71,24 +72,32 @@ def mdm_server_assigned(device_id: Annotated[str, typer.Argument()]): |
71 | 72 | df.to_csv(sys.stdout, index=False) |
72 | 73 |
|
73 | 74 | @app.command() |
74 | | -def assign_device(device_id: Annotated[List[str], typer.Argument()], server_id: Annotated[str, typer.Argument()]): |
| 75 | +def assign_device(device_ids: Annotated[List[str], typer.Argument()], server_id: Annotated[str, typer.Argument()]): |
75 | 76 | """Assign one or more devices to an MDM server.""" |
76 | 77 | client = Client() |
77 | | - activity = client.assign_unassign_device_to_mdm_server(device_id, server_id, 'ASSIGN_DEVICES') |
| 78 | + activity = client.assign_unassign_device_to_mdm_server(device_ids, server_id, 'ASSIGN_DEVICES') |
78 | 79 | activity_data = {'id': activity.id} |
79 | 80 | activity_data.update(activity.attributes.model_dump()) |
80 | 81 | df = pd.DataFrame([activity_data]) |
81 | 82 | df.to_csv(sys.stdout, index=False) |
82 | 83 |
|
| 84 | + file_path = download_activity_csv(activity) |
| 85 | + if file_path: |
| 86 | + typer.echo(f"Report downloaded successfully to: {file_path}") |
| 87 | + |
83 | 88 | @app.command() |
84 | | -def unassign_device(device_id: Annotated[List[str], typer.Argument()], server_id: Annotated[str, typer.Argument()]): |
| 89 | +def unassign_device(device_ids: Annotated[List[str], typer.Argument()], server_id: Annotated[str, typer.Argument()]): |
85 | 90 | """Unassign one or more devices from an MDM server.""" |
86 | 91 | client = Client() |
87 | | - activity = client.assign_unassign_device_to_mdm_server(device_id, server_id, 'UNASSIGN_DEVICES') |
| 92 | + activity = client.assign_unassign_device_to_mdm_server(device_ids, server_id, 'UNASSIGN_DEVICES') |
88 | 93 | activity_data = {'id': activity.id} |
89 | 94 | activity_data.update(activity.attributes.model_dump()) |
90 | 95 | df = pd.DataFrame([activity_data]) |
91 | 96 | df.to_csv(sys.stdout, index=False) |
| 97 | + |
| 98 | + file_path = download_activity_csv(activity) |
| 99 | + if file_path: |
| 100 | + typer.echo(f"Report downloaded successfully to: {file_path}") |
92 | 101 |
|
93 | 102 | if __name__ == "__main__": |
94 | 103 | app() |
0 commit comments