bt-cli 0.4.13__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.
Files changed (121) hide show
  1. bt_cli/__init__.py +3 -0
  2. bt_cli/cli.py +830 -0
  3. bt_cli/commands/__init__.py +1 -0
  4. bt_cli/commands/configure.py +415 -0
  5. bt_cli/commands/learn.py +229 -0
  6. bt_cli/commands/quick.py +784 -0
  7. bt_cli/core/__init__.py +1 -0
  8. bt_cli/core/auth.py +213 -0
  9. bt_cli/core/client.py +313 -0
  10. bt_cli/core/config.py +393 -0
  11. bt_cli/core/config_file.py +420 -0
  12. bt_cli/core/csv_utils.py +91 -0
  13. bt_cli/core/errors.py +247 -0
  14. bt_cli/core/output.py +205 -0
  15. bt_cli/core/prompts.py +87 -0
  16. bt_cli/core/rest_debug.py +221 -0
  17. bt_cli/data/CLAUDE.md +94 -0
  18. bt_cli/data/__init__.py +0 -0
  19. bt_cli/data/skills/bt/SKILL.md +108 -0
  20. bt_cli/data/skills/entitle/SKILL.md +170 -0
  21. bt_cli/data/skills/epmw/SKILL.md +144 -0
  22. bt_cli/data/skills/pra/SKILL.md +150 -0
  23. bt_cli/data/skills/pws/SKILL.md +198 -0
  24. bt_cli/entitle/__init__.py +1 -0
  25. bt_cli/entitle/client/__init__.py +5 -0
  26. bt_cli/entitle/client/base.py +443 -0
  27. bt_cli/entitle/commands/__init__.py +24 -0
  28. bt_cli/entitle/commands/accounts.py +53 -0
  29. bt_cli/entitle/commands/applications.py +39 -0
  30. bt_cli/entitle/commands/auth.py +68 -0
  31. bt_cli/entitle/commands/bundles.py +218 -0
  32. bt_cli/entitle/commands/integrations.py +60 -0
  33. bt_cli/entitle/commands/permissions.py +70 -0
  34. bt_cli/entitle/commands/policies.py +97 -0
  35. bt_cli/entitle/commands/resources.py +131 -0
  36. bt_cli/entitle/commands/roles.py +74 -0
  37. bt_cli/entitle/commands/users.py +123 -0
  38. bt_cli/entitle/commands/workflows.py +187 -0
  39. bt_cli/entitle/models/__init__.py +31 -0
  40. bt_cli/entitle/models/bundle.py +28 -0
  41. bt_cli/entitle/models/common.py +37 -0
  42. bt_cli/entitle/models/integration.py +30 -0
  43. bt_cli/entitle/models/permission.py +27 -0
  44. bt_cli/entitle/models/policy.py +25 -0
  45. bt_cli/entitle/models/resource.py +29 -0
  46. bt_cli/entitle/models/role.py +28 -0
  47. bt_cli/entitle/models/user.py +24 -0
  48. bt_cli/entitle/models/workflow.py +55 -0
  49. bt_cli/epmw/__init__.py +1 -0
  50. bt_cli/epmw/client/__init__.py +5 -0
  51. bt_cli/epmw/client/base.py +848 -0
  52. bt_cli/epmw/commands/__init__.py +33 -0
  53. bt_cli/epmw/commands/audits.py +250 -0
  54. bt_cli/epmw/commands/auth.py +55 -0
  55. bt_cli/epmw/commands/computers.py +140 -0
  56. bt_cli/epmw/commands/events.py +233 -0
  57. bt_cli/epmw/commands/groups.py +215 -0
  58. bt_cli/epmw/commands/policies.py +673 -0
  59. bt_cli/epmw/commands/quick.py +348 -0
  60. bt_cli/epmw/commands/requests.py +224 -0
  61. bt_cli/epmw/commands/roles.py +78 -0
  62. bt_cli/epmw/commands/tasks.py +38 -0
  63. bt_cli/epmw/commands/users.py +219 -0
  64. bt_cli/epmw/models/__init__.py +1 -0
  65. bt_cli/pra/__init__.py +1 -0
  66. bt_cli/pra/client/__init__.py +5 -0
  67. bt_cli/pra/client/base.py +618 -0
  68. bt_cli/pra/commands/__init__.py +30 -0
  69. bt_cli/pra/commands/auth.py +55 -0
  70. bt_cli/pra/commands/import_export.py +442 -0
  71. bt_cli/pra/commands/jump_clients.py +139 -0
  72. bt_cli/pra/commands/jump_groups.py +146 -0
  73. bt_cli/pra/commands/jump_items.py +638 -0
  74. bt_cli/pra/commands/jumpoints.py +95 -0
  75. bt_cli/pra/commands/policies.py +197 -0
  76. bt_cli/pra/commands/quick.py +470 -0
  77. bt_cli/pra/commands/teams.py +81 -0
  78. bt_cli/pra/commands/users.py +87 -0
  79. bt_cli/pra/commands/vault.py +564 -0
  80. bt_cli/pra/models/__init__.py +27 -0
  81. bt_cli/pra/models/common.py +12 -0
  82. bt_cli/pra/models/jump_client.py +25 -0
  83. bt_cli/pra/models/jump_group.py +15 -0
  84. bt_cli/pra/models/jump_item.py +72 -0
  85. bt_cli/pra/models/jumpoint.py +19 -0
  86. bt_cli/pra/models/team.py +14 -0
  87. bt_cli/pra/models/user.py +17 -0
  88. bt_cli/pra/models/vault.py +45 -0
  89. bt_cli/pws/__init__.py +1 -0
  90. bt_cli/pws/client/__init__.py +5 -0
  91. bt_cli/pws/client/base.py +356 -0
  92. bt_cli/pws/client/beyondinsight.py +869 -0
  93. bt_cli/pws/client/passwordsafe.py +1786 -0
  94. bt_cli/pws/commands/__init__.py +33 -0
  95. bt_cli/pws/commands/accounts.py +372 -0
  96. bt_cli/pws/commands/assets.py +311 -0
  97. bt_cli/pws/commands/auth.py +166 -0
  98. bt_cli/pws/commands/clouds.py +221 -0
  99. bt_cli/pws/commands/config.py +344 -0
  100. bt_cli/pws/commands/credentials.py +347 -0
  101. bt_cli/pws/commands/databases.py +306 -0
  102. bt_cli/pws/commands/directories.py +199 -0
  103. bt_cli/pws/commands/functional.py +298 -0
  104. bt_cli/pws/commands/import_export.py +452 -0
  105. bt_cli/pws/commands/platforms.py +118 -0
  106. bt_cli/pws/commands/quick.py +1646 -0
  107. bt_cli/pws/commands/search.py +256 -0
  108. bt_cli/pws/commands/secrets.py +1343 -0
  109. bt_cli/pws/commands/systems.py +389 -0
  110. bt_cli/pws/commands/users.py +415 -0
  111. bt_cli/pws/commands/workgroups.py +166 -0
  112. bt_cli/pws/config.py +18 -0
  113. bt_cli/pws/models/__init__.py +19 -0
  114. bt_cli/pws/models/account.py +186 -0
  115. bt_cli/pws/models/asset.py +102 -0
  116. bt_cli/pws/models/common.py +132 -0
  117. bt_cli/pws/models/system.py +121 -0
  118. bt_cli-0.4.13.dist-info/METADATA +417 -0
  119. bt_cli-0.4.13.dist-info/RECORD +121 -0
  120. bt_cli-0.4.13.dist-info/WHEEL +4 -0
  121. bt_cli-0.4.13.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,219 @@
1
+ """EPMW users commands."""
2
+
3
+ from typing import Optional
4
+
5
+ import httpx
6
+ import typer
7
+
8
+ from bt_cli.core.output import OutputFormat, print_api_error, print_error, print_json, print_table
9
+
10
+ app = typer.Typer(no_args_is_help=True, help="EPM user accounts")
11
+
12
+
13
+ @app.command("list")
14
+ def list_users(
15
+ output: OutputFormat = typer.Option(
16
+ OutputFormat.TABLE, "--output", "-o", help="Output format"
17
+ ),
18
+ ):
19
+ """List all users."""
20
+ from bt_cli.epmw.client import get_client
21
+
22
+ try:
23
+ client = get_client()
24
+ users = client.list_users()
25
+
26
+ if output == OutputFormat.JSON:
27
+ print_json(users)
28
+ else:
29
+ columns = [
30
+ ("ID", "id"),
31
+ ("Account", "accountName"),
32
+ ("Email", "emailAddress"),
33
+ ("Type", "userType"),
34
+ ("Disabled", "disabled"),
35
+ ]
36
+ print_table(users, columns, title="Users")
37
+ except httpx.HTTPStatusError as e:
38
+ print_api_error(e, "list users")
39
+ raise typer.Exit(1)
40
+ except httpx.RequestError as e:
41
+ print_api_error(e, "list users")
42
+ raise typer.Exit(1)
43
+ except Exception as e:
44
+ print_api_error(e, "list users")
45
+ raise typer.Exit(1)
46
+
47
+
48
+ @app.command("get")
49
+ def get_user(
50
+ user_id: str = typer.Argument(..., help="User ID"),
51
+ output: OutputFormat = typer.Option(
52
+ OutputFormat.JSON, "--output", "-o", help="Output format"
53
+ ),
54
+ ):
55
+ """Get user details."""
56
+ from bt_cli.epmw.client import get_client
57
+
58
+ try:
59
+ client = get_client()
60
+ user = client.get_user(user_id)
61
+
62
+ if output == OutputFormat.JSON:
63
+ print_json(user)
64
+ else:
65
+ typer.echo(f"ID: {user.get('id')}")
66
+ typer.echo(f"Account: {user.get('accountName')}")
67
+ typer.echo(f"Email: {user.get('emailAddress')}")
68
+ typer.echo(f"Type: {user.get('userType')}")
69
+ typer.echo(f"Disabled: {user.get('disabled')}")
70
+ typer.echo(f"Last Signed In: {user.get('lastSignedIn')}")
71
+ if user.get('roles'):
72
+ typer.echo("Roles:")
73
+ for role in user['roles']:
74
+ typer.echo(f" - {role.get('name')}")
75
+ except httpx.HTTPStatusError as e:
76
+ print_api_error(e, "get user")
77
+ raise typer.Exit(1)
78
+ except httpx.RequestError as e:
79
+ print_api_error(e, "get user")
80
+ raise typer.Exit(1)
81
+ except Exception as e:
82
+ print_api_error(e, "get user")
83
+ raise typer.Exit(1)
84
+
85
+
86
+ @app.command("create")
87
+ def create_user(
88
+ account_name: str = typer.Option(..., "--account", "-a", help="Account name (email)"),
89
+ email: Optional[str] = typer.Option(None, "--email", "-e", help="Email address (defaults to account name)"),
90
+ output: OutputFormat = typer.Option(
91
+ OutputFormat.JSON, "--output", "-o", help="Output format"
92
+ ),
93
+ ):
94
+ """Create a new user."""
95
+ from bt_cli.epmw.client import get_client
96
+
97
+ try:
98
+ client = get_client()
99
+ data = {
100
+ "accountName": account_name,
101
+ "emailAddress": email or account_name,
102
+ }
103
+ user = client.create_user(data)
104
+
105
+ typer.echo(f"Created user: {user['accountName']} (ID: {user['id']})")
106
+ if output == OutputFormat.JSON:
107
+ print_json(user)
108
+ except httpx.HTTPStatusError as e:
109
+ print_api_error(e, "create user")
110
+ raise typer.Exit(1)
111
+ except httpx.RequestError as e:
112
+ print_api_error(e, "create user")
113
+ raise typer.Exit(1)
114
+ except Exception as e:
115
+ print_api_error(e, "create user")
116
+ raise typer.Exit(1)
117
+
118
+
119
+ @app.command("update")
120
+ def update_user(
121
+ user_id: str = typer.Argument(..., help="User ID"),
122
+ email: Optional[str] = typer.Option(None, "--email", "-e", help="New email address"),
123
+ output: OutputFormat = typer.Option(
124
+ OutputFormat.JSON, "--output", "-o", help="Output format"
125
+ ),
126
+ ):
127
+ """Update a user."""
128
+ from bt_cli.epmw.client import get_client
129
+
130
+ try:
131
+ client = get_client()
132
+ data = {}
133
+ if email:
134
+ data["emailAddress"] = email
135
+ if not data:
136
+ print_error("No updates specified")
137
+ raise typer.Exit(1)
138
+
139
+ user = client.update_user(user_id, data)
140
+ typer.echo(f"Updated user: {user_id}")
141
+ if output == OutputFormat.JSON and user:
142
+ print_json(user)
143
+ except httpx.HTTPStatusError as e:
144
+ print_api_error(e, "update user")
145
+ raise typer.Exit(1)
146
+ except httpx.RequestError as e:
147
+ print_api_error(e, "update user")
148
+ raise typer.Exit(1)
149
+ except Exception as e:
150
+ print_api_error(e, "update user")
151
+ raise typer.Exit(1)
152
+
153
+
154
+ @app.command("enable")
155
+ def enable_user(
156
+ user_id: str = typer.Argument(..., help="User ID"),
157
+ ):
158
+ """Enable a user."""
159
+ from bt_cli.epmw.client import get_client
160
+
161
+ try:
162
+ client = get_client()
163
+ client.enable_user(user_id)
164
+ typer.echo(f"Enabled user: {user_id}")
165
+ except httpx.HTTPStatusError as e:
166
+ print_api_error(e, "enable user")
167
+ raise typer.Exit(1)
168
+ except httpx.RequestError as e:
169
+ print_api_error(e, "enable user")
170
+ raise typer.Exit(1)
171
+ except Exception as e:
172
+ print_api_error(e, "enable user")
173
+ raise typer.Exit(1)
174
+
175
+
176
+ @app.command("disable")
177
+ def disable_user(
178
+ user_id: str = typer.Argument(..., help="User ID"),
179
+ ):
180
+ """Disable a user."""
181
+ from bt_cli.epmw.client import get_client
182
+
183
+ try:
184
+ client = get_client()
185
+ client.disable_user(user_id)
186
+ typer.echo(f"Disabled user: {user_id}")
187
+ except httpx.HTTPStatusError as e:
188
+ print_api_error(e, "disable user")
189
+ raise typer.Exit(1)
190
+ except httpx.RequestError as e:
191
+ print_api_error(e, "disable user")
192
+ raise typer.Exit(1)
193
+ except Exception as e:
194
+ print_api_error(e, "disable user")
195
+ raise typer.Exit(1)
196
+
197
+
198
+ @app.command("assign-roles")
199
+ def assign_roles(
200
+ user_id: str = typer.Argument(..., help="User ID"),
201
+ role_ids: str = typer.Option(..., "--roles", "-r", help="Comma-separated role IDs"),
202
+ ):
203
+ """Assign roles to a user."""
204
+ from bt_cli.epmw.client import get_client
205
+
206
+ try:
207
+ client = get_client()
208
+ ids = [r.strip() for r in role_ids.split(",")]
209
+ client.assign_roles_to_user(user_id, ids)
210
+ typer.echo(f"Assigned {len(ids)} role(s) to user {user_id}")
211
+ except httpx.HTTPStatusError as e:
212
+ print_api_error(e, "assign roles")
213
+ raise typer.Exit(1)
214
+ except httpx.RequestError as e:
215
+ print_api_error(e, "assign roles")
216
+ raise typer.Exit(1)
217
+ except Exception as e:
218
+ print_api_error(e, "assign roles")
219
+ raise typer.Exit(1)
@@ -0,0 +1 @@
1
+ """EPMW models module."""
bt_cli/pra/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """BeyondTrust Privileged Remote Access (PRA) module."""
@@ -0,0 +1,5 @@
1
+ """PRA client module."""
2
+
3
+ from .base import PRAClient, get_client
4
+
5
+ __all__ = ["PRAClient", "get_client"]