midpoint-cli 1.4.0__tar.gz → 1.5.0.dev1__tar.gz
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.
- midpoint_cli-1.5.0.dev1/PKG-INFO +797 -0
- midpoint_cli-1.5.0.dev1/README.md +764 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/pyproject.toml +1 -3
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/client/__init__.py +28 -1
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/client/objects.py +81 -42
- midpoint_cli-1.5.0.dev1/src/midpoint_cli/client/progress.py +62 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/__init__.py +63 -3
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/console.py +153 -5
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/task.py +27 -10
- midpoint_cli-1.4.0/PKG-INFO +0 -255
- midpoint_cli-1.4.0/README.md +0 -221
- midpoint_cli-1.4.0/src/midpoint_cli/client/progress.py +0 -33
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/LICENSE +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/__init__.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/client/observer.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/client/patch.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/client/session.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/base.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/complete.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/configuration.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/delete.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/get.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/org.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/put.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/resource.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/script.py +0 -0
- {midpoint_cli-1.4.0 → midpoint_cli-1.5.0.dev1}/src/midpoint_cli/prompt/user.py +0 -0
|
@@ -0,0 +1,797 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: midpoint-cli
|
|
3
|
+
Version: 1.5.0.dev1
|
|
4
|
+
Summary: A command line client to Midpoint Identity Management system.
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: Yannick Kirschhoffer
|
|
8
|
+
Author-email: alcibiade@alcibiade.org
|
|
9
|
+
Maintainer: Yannick Kirschhoffer
|
|
10
|
+
Maintainer-email: alcibiade@alcibiade.org
|
|
11
|
+
Requires-Python: >=3.9.0,<4.0.0
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: System :: Systems Administration
|
|
24
|
+
Requires-Dist: prompt-toolkit (>=3.0,<4.0)
|
|
25
|
+
Requires-Dist: pygments (>=2.0,<3.0)
|
|
26
|
+
Requires-Dist: requests (>=2.31,<3.0)
|
|
27
|
+
Requires-Dist: rich (>=13.0,<14.0)
|
|
28
|
+
Requires-Dist: unidecode (>=1.3,<2.0)
|
|
29
|
+
Requires-Dist: urllib3 (>=2.0,<3.0)
|
|
30
|
+
Project-URL: Repository, https://gitlab.com/alcibiade/midpoint-cli
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# Midpoint CLI
|
|
34
|
+
|
|
35
|
+
[](https://badge.fury.io/py/midpoint-cli)
|
|
36
|
+
[](https://pypi.org/project/midpoint-cli/)
|
|
37
|
+
[](https://opensource.org/licenses/MIT)
|
|
38
|
+
[](https://gitlab.com/alcibiade/midpoint-cli/-/pipelines)
|
|
39
|
+
[](https://gitlab.com/alcibiade/midpoint-cli/-/commits/master)
|
|
40
|
+
[](https://github.com/astral-sh/ruff)
|
|
41
|
+
|
|
42
|
+
This project is a command line client interface used to drive an Evolveum Midpoint identity management server.
|
|
43
|
+
|
|
44
|
+
## Table of Contents
|
|
45
|
+
|
|
46
|
+
- [Quick Start](#quick-start)
|
|
47
|
+
- [Features](#features)
|
|
48
|
+
- [Installation](#installation)
|
|
49
|
+
- [Through PyPI](#through-pypi)
|
|
50
|
+
- [Development build](#development-build)
|
|
51
|
+
- [Usage](#usage)
|
|
52
|
+
- [General syntax](#general-syntax)
|
|
53
|
+
- [Configuration files](#external-configuration-files-since-v12)
|
|
54
|
+
- [Environment variables](#environment-variables-since-v12)
|
|
55
|
+
- [Usage Examples](#usage-examples)
|
|
56
|
+
- [Interactive Mode](#interactive-mode)
|
|
57
|
+
- [User Management](#user-management)
|
|
58
|
+
- [Organization Management](#organization-management)
|
|
59
|
+
- [Task Management](#task-management)
|
|
60
|
+
- [Resource Management](#resource-management)
|
|
61
|
+
- [Scripting and Automation](#scripting-and-automation)
|
|
62
|
+
- [Working with XML Definitions](#working-with-xml-definitions)
|
|
63
|
+
- [Using Configuration Files](#using-configuration-files)
|
|
64
|
+
- [Setting up a sandbox environment](#setting-up-a-sandbox-environment)
|
|
65
|
+
- [Requirements](#requirements)
|
|
66
|
+
|
|
67
|
+
## Features
|
|
68
|
+
|
|
69
|
+
The objectives of this tool are to enable:
|
|
70
|
+
|
|
71
|
+
* **Administrator access** to run tasks and review data
|
|
72
|
+
* **Scripting** for remote controlled automation
|
|
73
|
+
* **Test scenarios** implementation
|
|
74
|
+
|
|
75
|
+
### Core Capabilities
|
|
76
|
+
|
|
77
|
+
The client currently supports:
|
|
78
|
+
|
|
79
|
+
* **User Management:** List, search, create, update, and delete users
|
|
80
|
+
* **Organizational Units:** Display and manage organizational structures
|
|
81
|
+
* **Task Operations:** List tasks with status and duration, run tasks synchronously with progress monitoring
|
|
82
|
+
* **Resource Management:** List resources, test connectivity, retrieve configurations
|
|
83
|
+
* **Object Operations:** Retrieve, create, update, and delete any Midpoint object type via XML
|
|
84
|
+
* **XML Patch Support:** Apply modifications to existing objects using XML patches
|
|
85
|
+
|
|
86
|
+
### Task Duration Display
|
|
87
|
+
|
|
88
|
+
* **Running tasks** show real-time elapsed time since start
|
|
89
|
+
* **Completed tasks** display total execution time
|
|
90
|
+
* Human-readable format (e.g., "2h 35m 20s", "5m 30s", "45s")
|
|
91
|
+
* Automatic calculation from Midpoint timestamp fields
|
|
92
|
+
|
|
93
|
+
### Interactive Mode Features
|
|
94
|
+
|
|
95
|
+
The strong points of this project are:
|
|
96
|
+
|
|
97
|
+
* **Dual Execution Modes:** Run commands directly from shell or use an interactive prompt session
|
|
98
|
+
* **Colorized Output:** Color-coded output when running in a terminal for improved readability
|
|
99
|
+
* **Command History:** Bash-compatible command line history with persistent storage across sessions
|
|
100
|
+
* **Tab Completion:** Auto-completion for task names and OIDs
|
|
101
|
+
* **Interactive Help:** Full built-in help system with command-specific documentation
|
|
102
|
+
* **Standard CLI Syntax:** Classical `midpoint-cli [command] [options]` syntax
|
|
103
|
+
|
|
104
|
+
### Configuration Flexibility
|
|
105
|
+
|
|
106
|
+
* **Multiple Auth Methods:** Command-line arguments, environment variables, or configuration files
|
|
107
|
+
* **Configuration Priority:** Command-line > Environment variables > Config files > Defaults
|
|
108
|
+
* **Secure Credential Storage:** Use config files or environment variables to avoid exposing passwords
|
|
109
|
+
|
|
110
|
+
## Quick Start
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Install via pip
|
|
114
|
+
pip3 install midpoint-cli
|
|
115
|
+
|
|
116
|
+
# Check version
|
|
117
|
+
midpoint-cli --version
|
|
118
|
+
|
|
119
|
+
# Start interactive session with credentials via command line
|
|
120
|
+
midpoint-cli -u administrator -p password -U https://localhost:8080/midpoint/
|
|
121
|
+
|
|
122
|
+
# Or run a direct command
|
|
123
|
+
midpoint-cli -u administrator -p password -U https://localhost:8080/midpoint/ users
|
|
124
|
+
|
|
125
|
+
# Use environment variables for authentication (recommended)
|
|
126
|
+
export MIDPOINT_URL="https://localhost:8080/midpoint/"
|
|
127
|
+
export MIDPOINT_USERNAME="administrator"
|
|
128
|
+
export MIDPOINT_PASSWORD="password"
|
|
129
|
+
|
|
130
|
+
# Now you can run commands without specifying credentials
|
|
131
|
+
midpoint-cli
|
|
132
|
+
midpoint-cli users
|
|
133
|
+
midpoint-cli tasks
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Usage
|
|
137
|
+
|
|
138
|
+
### General syntax
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
usage: midpoint-cli [-h] [-v] [-u USERNAME] [-p PASSWORD] [-U URL]
|
|
142
|
+
[command] [arg [arg ...]]
|
|
143
|
+
|
|
144
|
+
An interactive Midpoint command line client.
|
|
145
|
+
|
|
146
|
+
positional arguments:
|
|
147
|
+
command Optional command to be executed immediately.
|
|
148
|
+
arg Optional command arguments.
|
|
149
|
+
|
|
150
|
+
optional arguments:
|
|
151
|
+
-h, --help show this help message and exit
|
|
152
|
+
-v, --version Show version information
|
|
153
|
+
-u USERNAME, --username USERNAME
|
|
154
|
+
Set the username to authenticate this session.
|
|
155
|
+
-p PASSWORD, --password PASSWORD
|
|
156
|
+
Set the password to authenticate this session.
|
|
157
|
+
-U URL, --url URL Midpoint base URL (e.g., https://localhost:8080/midpoint/)
|
|
158
|
+
|
|
159
|
+
Available commands:
|
|
160
|
+
get Get an XML definition from the server from an existing OID reference.
|
|
161
|
+
Usage: get <object-type> <oid>
|
|
162
|
+
Example: get user 12345678-abcd-1234-abcd-123456789012
|
|
163
|
+
|
|
164
|
+
put Create/Update a server object based on an XML structure.
|
|
165
|
+
Usage: put <xml-file>
|
|
166
|
+
Example: put user-definition.xml
|
|
167
|
+
|
|
168
|
+
delete Delete a server object based on its type and OID.
|
|
169
|
+
Usage: delete <object-type> <oid>
|
|
170
|
+
Example: delete user 12345678-abcd-1234-abcd-123456789012
|
|
171
|
+
|
|
172
|
+
task Manage server tasks.
|
|
173
|
+
Subcommands:
|
|
174
|
+
- tasks: List all tasks with status and duration
|
|
175
|
+
- task run <name-or-oid>: Execute a task and wait for completion
|
|
176
|
+
Example: task run "Recompute All Users"
|
|
177
|
+
|
|
178
|
+
resource Manage resources on the server.
|
|
179
|
+
Subcommands:
|
|
180
|
+
- resources: List all configured resources
|
|
181
|
+
- resource test <name-or-oid>: Test resource connectivity
|
|
182
|
+
Example: resource test "Active Directory"
|
|
183
|
+
|
|
184
|
+
org Manage organizations.
|
|
185
|
+
Usage: org [search-term]
|
|
186
|
+
Example: org Engineering
|
|
187
|
+
|
|
188
|
+
user Manage users.
|
|
189
|
+
Subcommands:
|
|
190
|
+
- users: List all users
|
|
191
|
+
- user search <term>: Search for users by name
|
|
192
|
+
Example: user search john
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### External configuration files (since v1.2)
|
|
196
|
+
|
|
197
|
+
Settings can be provided from an external configuration file. It can be either:
|
|
198
|
+
|
|
199
|
+
* .midpoint-cli.cfg in the home directory of the current user
|
|
200
|
+
* midpoint-cli.cfg in the current working directory
|
|
201
|
+
|
|
202
|
+
The syntax is as follows:
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
[Midpoint]
|
|
206
|
+
url = https://localhost:8080/midpoint/
|
|
207
|
+
username = administrator
|
|
208
|
+
password = ...
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Environment variables (since v1.2)
|
|
212
|
+
|
|
213
|
+
The script will scan environment variables to read input parameters. This is
|
|
214
|
+
particularly useful for injection of password or in-container execution.
|
|
215
|
+
|
|
216
|
+
The variables are:
|
|
217
|
+
|
|
218
|
+
* MIDPOINT_URL
|
|
219
|
+
* MIDPOINT_USERNAME
|
|
220
|
+
* MIDPOINT_PASSWORD
|
|
221
|
+
|
|
222
|
+
## Usage Examples
|
|
223
|
+
|
|
224
|
+
### Interactive Mode
|
|
225
|
+
|
|
226
|
+
The interactive mode is one of the strongest features of midpoint-cli. It provides a persistent session with command history, tab completion, colorized output, and a built-in help system. This is ideal for exploring your Midpoint server, troubleshooting, and performing multiple operations without re-authenticating.
|
|
227
|
+
|
|
228
|
+
#### Starting an Interactive Session
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# Start interactive session with authentication
|
|
232
|
+
midpoint-cli -u administrator -p mypassword -U https://midpoint.example.com/midpoint/
|
|
233
|
+
|
|
234
|
+
# Or use environment variables (recommended)
|
|
235
|
+
export MIDPOINT_URL="https://midpoint.example.com/midpoint/"
|
|
236
|
+
export MIDPOINT_USERNAME="administrator"
|
|
237
|
+
export MIDPOINT_PASSWORD="mypassword"
|
|
238
|
+
midpoint-cli
|
|
239
|
+
|
|
240
|
+
# Or use a configuration file
|
|
241
|
+
# Create ~/.midpoint-cli.cfg with your credentials
|
|
242
|
+
midpoint-cli
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### Interactive Features
|
|
246
|
+
|
|
247
|
+
**Command History Navigation:**
|
|
248
|
+
- Use arrow keys (↑/↓) to navigate through command history
|
|
249
|
+
- History is persistent across sessions (bash-compatible)
|
|
250
|
+
- Search history with Ctrl+R
|
|
251
|
+
|
|
252
|
+
**Tab Completion:**
|
|
253
|
+
- Tab completion available for task names and OIDs
|
|
254
|
+
- Complete commands by pressing Tab
|
|
255
|
+
|
|
256
|
+
**Colorized Output:**
|
|
257
|
+
- Automatic color-coded output when running in a terminal
|
|
258
|
+
- Improved readability for status indicators and tables
|
|
259
|
+
|
|
260
|
+
**Built-in Help System:**
|
|
261
|
+
```bash
|
|
262
|
+
midpoint> help
|
|
263
|
+
# Shows all available commands
|
|
264
|
+
|
|
265
|
+
midpoint> help users
|
|
266
|
+
# Shows detailed help for the users command
|
|
267
|
+
|
|
268
|
+
midpoint> help task
|
|
269
|
+
# Shows task-related subcommands and usage
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
#### Common Interactive Workflows
|
|
273
|
+
|
|
274
|
+
**Exploring Users and Organizations:**
|
|
275
|
+
```bash
|
|
276
|
+
midpoint> users
|
|
277
|
+
# Lists all users with their details
|
|
278
|
+
|
|
279
|
+
midpoint> user search john
|
|
280
|
+
# Search for users matching "john"
|
|
281
|
+
|
|
282
|
+
midpoint> org
|
|
283
|
+
# List all organizational units
|
|
284
|
+
|
|
285
|
+
midpoint> get user 12345678-abcd-1234-abcd-123456789012
|
|
286
|
+
# Get detailed XML definition of a specific user
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**Task Management Workflow:**
|
|
290
|
+
```bash
|
|
291
|
+
midpoint> tasks
|
|
292
|
+
# View all tasks with status and duration
|
|
293
|
+
|
|
294
|
+
midpoint> task run "Recompute All Users"
|
|
295
|
+
# Execute a task and monitor progress
|
|
296
|
+
# For running tasks, duration shows elapsed time
|
|
297
|
+
# For completed tasks, duration shows total execution time
|
|
298
|
+
|
|
299
|
+
midpoint> tasks
|
|
300
|
+
# Check updated status after task completion
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Resource Testing and Monitoring:**
|
|
304
|
+
```bash
|
|
305
|
+
midpoint> resources
|
|
306
|
+
# List all configured resources
|
|
307
|
+
|
|
308
|
+
midpoint> resource test "Active Directory"
|
|
309
|
+
# Test connectivity to a specific resource
|
|
310
|
+
|
|
311
|
+
midpoint> tasks
|
|
312
|
+
# View any reconciliation tasks that may have been triggered
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Quick Object Inspection:**
|
|
316
|
+
```bash
|
|
317
|
+
midpoint> get user 00000000-0000-0000-0000-000000000002
|
|
318
|
+
# Get administrator user definition
|
|
319
|
+
|
|
320
|
+
midpoint> get task 12345678-task-1234-abcd-123456789012
|
|
321
|
+
# Get task details and configuration
|
|
322
|
+
|
|
323
|
+
midpoint> get resource 12345678-res1-1234-abcd-123456789012
|
|
324
|
+
# Get resource configuration
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
#### Interactive vs. Direct Execution
|
|
328
|
+
|
|
329
|
+
**Interactive mode advantages:**
|
|
330
|
+
- No need to re-authenticate for each command
|
|
331
|
+
- Command history for repeated operations
|
|
332
|
+
- Tab completion for faster input
|
|
333
|
+
- Persistent session for exploration
|
|
334
|
+
- Better for troubleshooting and manual operations
|
|
335
|
+
|
|
336
|
+
**Direct execution advantages:**
|
|
337
|
+
- Better for scripting and automation
|
|
338
|
+
- Can be used in CI/CD pipelines
|
|
339
|
+
- Single command operations
|
|
340
|
+
- Output can be easily piped to other commands
|
|
341
|
+
|
|
342
|
+
**Example comparison:**
|
|
343
|
+
```bash
|
|
344
|
+
# Direct execution - requires full authentication each time
|
|
345
|
+
midpoint-cli -u admin -p pass -U https://localhost:8080/midpoint/ users
|
|
346
|
+
midpoint-cli -u admin -p pass -U https://localhost:8080/midpoint/ tasks
|
|
347
|
+
midpoint-cli -u admin -p pass -U https://localhost:8080/midpoint/ resources
|
|
348
|
+
|
|
349
|
+
# Interactive mode - authenticate once, run multiple commands
|
|
350
|
+
midpoint-cli -u admin -p pass -U https://localhost:8080/midpoint/
|
|
351
|
+
midpoint> users
|
|
352
|
+
midpoint> tasks
|
|
353
|
+
midpoint> resources
|
|
354
|
+
midpoint> task run "Recompute All Users"
|
|
355
|
+
midpoint> tasks
|
|
356
|
+
midpoint> exit
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### User Management
|
|
360
|
+
|
|
361
|
+
#### List all users
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
# Direct command execution
|
|
365
|
+
midpoint-cli -u admin -p pass -U https://localhost:8080/midpoint/ users
|
|
366
|
+
|
|
367
|
+
# Output example:
|
|
368
|
+
# OID Name Title FullName Status EmpNo Email OU
|
|
369
|
+
# ------------------------------------ ------------- -------------- --------------- -------- ------- ----------------------- ----
|
|
370
|
+
# 00000000-0000-0000-0000-000000000002 administrator Administrator enabled admin@example.com
|
|
371
|
+
# 12345678-abcd-1234-abcd-123456789012 jdoe IT Manager John Doe enabled E12345 jdoe@example.com IT
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
#### Search for a specific user
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
# Search by name or username
|
|
378
|
+
midpoint-cli user search john
|
|
379
|
+
|
|
380
|
+
# Search with wildcards
|
|
381
|
+
midpoint-cli user search "j*"
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
#### Get user details (XML definition)
|
|
385
|
+
|
|
386
|
+
```bash
|
|
387
|
+
# Retrieve full XML definition of a user by OID
|
|
388
|
+
midpoint-cli get user 12345678-abcd-1234-abcd-123456789012
|
|
389
|
+
|
|
390
|
+
# Save user definition to a file
|
|
391
|
+
midpoint-cli get user 12345678-abcd-1234-abcd-123456789012 > user-backup.xml
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
#### Create or update a user
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
# Upload a user definition from an XML file
|
|
398
|
+
midpoint-cli put user-definition.xml
|
|
399
|
+
|
|
400
|
+
# Update user with a patch file
|
|
401
|
+
midpoint-cli put user-patch.xml
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
#### Delete a user
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
# Delete a user by OID
|
|
408
|
+
midpoint-cli delete user 12345678-abcd-1234-abcd-123456789012
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### Organization Management
|
|
412
|
+
|
|
413
|
+
#### List organizational units
|
|
414
|
+
|
|
415
|
+
```bash
|
|
416
|
+
# List all organizational units
|
|
417
|
+
midpoint-cli org
|
|
418
|
+
|
|
419
|
+
# Interactive mode
|
|
420
|
+
midpoint> org
|
|
421
|
+
# OID Name Parent Description
|
|
422
|
+
# ------------------------------------ -------------- -------- ---------------------
|
|
423
|
+
# 12345678-org1-1234-abcd-123456789012 Engineering Root Engineering Department
|
|
424
|
+
# 12345678-org2-1234-abcd-123456789012 IT Operations Root IT Operations Team
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
#### Get organization details
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
# Get full XML definition of an org unit
|
|
431
|
+
midpoint-cli get org 12345678-org1-1234-abcd-123456789012
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Task Management
|
|
435
|
+
|
|
436
|
+
#### List all tasks
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
# List all tasks with status and duration
|
|
440
|
+
midpoint-cli tasks
|
|
441
|
+
|
|
442
|
+
# Output shows running tasks with elapsed time and completed tasks with total execution time
|
|
443
|
+
# Task Name Status Duration Last Run
|
|
444
|
+
# --------------------------- --------- ---------- --------------------
|
|
445
|
+
# Import from HR System RUNNING 1h 25m 30s 2025-10-14 10:30:00
|
|
446
|
+
# Recompute All Users CLOSED 5m 42s 2025-10-14 09:15:00
|
|
447
|
+
# Reconciliation Task WAITING - Not yet started
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
#### Execute a task synchronously
|
|
451
|
+
|
|
452
|
+
```bash
|
|
453
|
+
# Run a task and wait for completion
|
|
454
|
+
midpoint-cli task run "Recompute All Users"
|
|
455
|
+
|
|
456
|
+
# Run task by OID
|
|
457
|
+
midpoint-cli task run 12345678-task-1234-abcd-123456789012
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
#### Get task details
|
|
461
|
+
|
|
462
|
+
```bash
|
|
463
|
+
# Get task status and XML definition
|
|
464
|
+
midpoint-cli get task 12345678-task-1234-abcd-123456789012
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
#### Monitor long-running tasks
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
# In interactive mode, you can repeatedly check task status
|
|
471
|
+
midpoint> task run "Import from HR System"
|
|
472
|
+
# Task started: 12345678-task-1234-abcd-123456789012
|
|
473
|
+
# Status: RUNNING (Duration: 5m 30s)
|
|
474
|
+
|
|
475
|
+
midpoint> tasks
|
|
476
|
+
# Check all running tasks with real-time duration updates
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### Resource Management
|
|
480
|
+
|
|
481
|
+
#### List all resources
|
|
482
|
+
|
|
483
|
+
```bash
|
|
484
|
+
# List configured resources
|
|
485
|
+
midpoint-cli resources
|
|
486
|
+
|
|
487
|
+
# Example output:
|
|
488
|
+
# OID Name Type Status
|
|
489
|
+
# ------------------------------------ ---------------- ------------ --------
|
|
490
|
+
# 12345678-res1-1234-abcd-123456789012 Active Directory LDAP UP
|
|
491
|
+
# 12345678-res2-1234-abcd-123456789012 HR Database Database UP
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
#### Test a resource connection
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
# Test resource connectivity
|
|
498
|
+
midpoint-cli resource test 12345678-res1-1234-abcd-123456789012
|
|
499
|
+
|
|
500
|
+
# Test by resource name
|
|
501
|
+
midpoint-cli resource test "Active Directory"
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
#### Get resource configuration
|
|
505
|
+
|
|
506
|
+
```bash
|
|
507
|
+
# Retrieve full resource definition
|
|
508
|
+
midpoint-cli get resource 12345678-res1-1234-abcd-123456789012 > ad-resource.xml
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### Scripting and Automation
|
|
512
|
+
|
|
513
|
+
#### Batch operations with scripts
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
#!/bin/bash
|
|
517
|
+
# Script to backup all users
|
|
518
|
+
|
|
519
|
+
MIDPOINT_URL="https://midpoint.example.com/midpoint/"
|
|
520
|
+
MIDPOINT_USERNAME="administrator"
|
|
521
|
+
MIDPOINT_PASSWORD="mypassword"
|
|
522
|
+
|
|
523
|
+
export MIDPOINT_URL MIDPOINT_USERNAME MIDPOINT_PASSWORD
|
|
524
|
+
|
|
525
|
+
# Create backup directory
|
|
526
|
+
mkdir -p user-backups
|
|
527
|
+
|
|
528
|
+
# Get list of all users and backup each one
|
|
529
|
+
midpoint-cli users | tail -n +3 | while read -r line; do
|
|
530
|
+
OID=$(echo "$line" | awk '{print $1}')
|
|
531
|
+
NAME=$(echo "$line" | awk '{print $2}')
|
|
532
|
+
|
|
533
|
+
if [ -n "$OID" ] && [ "$OID" != "----" ]; then
|
|
534
|
+
echo "Backing up user: $NAME ($OID)"
|
|
535
|
+
midpoint-cli get user "$OID" > "user-backups/${NAME}.xml"
|
|
536
|
+
fi
|
|
537
|
+
done
|
|
538
|
+
|
|
539
|
+
echo "Backup completed!"
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
#### Automated user provisioning
|
|
543
|
+
|
|
544
|
+
```bash
|
|
545
|
+
#!/bin/bash
|
|
546
|
+
# Create users from a list
|
|
547
|
+
|
|
548
|
+
MIDPOINT_CLI="midpoint-cli -u admin -p pass -U https://localhost:8080/midpoint/"
|
|
549
|
+
|
|
550
|
+
# Read user list and create each user
|
|
551
|
+
while IFS=',' read -r username fullname email; do
|
|
552
|
+
cat > /tmp/new-user.xml <<EOF
|
|
553
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
554
|
+
<user xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
|
|
555
|
+
<name>$username</name>
|
|
556
|
+
<fullName>$fullname</fullName>
|
|
557
|
+
<emailAddress>$email</emailAddress>
|
|
558
|
+
<credentials>
|
|
559
|
+
<password>
|
|
560
|
+
<value>ChangeMe123</value>
|
|
561
|
+
</password>
|
|
562
|
+
</credentials>
|
|
563
|
+
</user>
|
|
564
|
+
EOF
|
|
565
|
+
|
|
566
|
+
echo "Creating user: $username"
|
|
567
|
+
$MIDPOINT_CLI put /tmp/new-user.xml
|
|
568
|
+
done < users.csv
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
#### Task automation with environment variables
|
|
572
|
+
|
|
573
|
+
```bash
|
|
574
|
+
# Use environment variables for credentials (more secure)
|
|
575
|
+
export MIDPOINT_URL="https://midpoint.example.com/midpoint/"
|
|
576
|
+
export MIDPOINT_USERNAME="administrator"
|
|
577
|
+
export MIDPOINT_PASSWORD="$(cat /secure/location/password.txt)"
|
|
578
|
+
|
|
579
|
+
# Run tasks without exposing credentials in command line
|
|
580
|
+
midpoint-cli task run "Daily User Reconciliation"
|
|
581
|
+
midpoint-cli task run "Nightly Cleanup Task"
|
|
582
|
+
|
|
583
|
+
# Check task status
|
|
584
|
+
midpoint-cli tasks | grep -E "RUNNING|RUNNABLE"
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
#### Continuous monitoring script
|
|
588
|
+
|
|
589
|
+
```bash
|
|
590
|
+
#!/bin/bash
|
|
591
|
+
# Monitor running tasks and send alerts
|
|
592
|
+
|
|
593
|
+
while true; do
|
|
594
|
+
RUNNING_TASKS=$(midpoint-cli tasks | grep "RUNNING" | wc -l)
|
|
595
|
+
|
|
596
|
+
if [ "$RUNNING_TASKS" -gt 5 ]; then
|
|
597
|
+
echo "WARNING: More than 5 tasks running simultaneously!"
|
|
598
|
+
# Send alert (e.g., via email or Slack)
|
|
599
|
+
fi
|
|
600
|
+
|
|
601
|
+
# Check for failed tasks
|
|
602
|
+
FAILED_TASKS=$(midpoint-cli tasks | grep "SUSPENDED")
|
|
603
|
+
if [ -n "$FAILED_TASKS" ]; then
|
|
604
|
+
echo "ALERT: Failed tasks detected:"
|
|
605
|
+
echo "$FAILED_TASKS"
|
|
606
|
+
fi
|
|
607
|
+
|
|
608
|
+
sleep 60 # Check every minute
|
|
609
|
+
done
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
### Working with XML Definitions
|
|
613
|
+
|
|
614
|
+
#### Export configuration for version control
|
|
615
|
+
|
|
616
|
+
```bash
|
|
617
|
+
# Export all critical configurations
|
|
618
|
+
mkdir -p midpoint-config
|
|
619
|
+
|
|
620
|
+
# Export resources
|
|
621
|
+
midpoint-cli resources | tail -n +3 | while read -r line; do
|
|
622
|
+
OID=$(echo "$line" | awk '{print $1}')
|
|
623
|
+
NAME=$(echo "$line" | awk '{print $2}')
|
|
624
|
+
if [ -n "$OID" ] && [ "$OID" != "----" ]; then
|
|
625
|
+
midpoint-cli get resource "$OID" > "midpoint-config/resource-${NAME}.xml"
|
|
626
|
+
fi
|
|
627
|
+
done
|
|
628
|
+
|
|
629
|
+
# Export roles
|
|
630
|
+
midpoint-cli get role 00000000-0000-0000-0000-000000000004 > midpoint-config/superuser-role.xml
|
|
631
|
+
|
|
632
|
+
# Commit to version control
|
|
633
|
+
git add midpoint-config/
|
|
634
|
+
git commit -m "Backup Midpoint configuration"
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
#### Apply patches to objects
|
|
638
|
+
|
|
639
|
+
```bash
|
|
640
|
+
# Create a patch file to modify a user
|
|
641
|
+
cat > user-patch.xml <<EOF
|
|
642
|
+
<?xml version="1.0"?>
|
|
643
|
+
<objectModification xmlns="http://midpoint.evolveum.com/xml/ns/public/common/api-types-3">
|
|
644
|
+
<oid>12345678-abcd-1234-abcd-123456789012</oid>
|
|
645
|
+
<modificationType>modify</modificationType>
|
|
646
|
+
<itemDelta>
|
|
647
|
+
<modificationType>replace</modificationType>
|
|
648
|
+
<path>emailAddress</path>
|
|
649
|
+
<value>newemail@example.com</value>
|
|
650
|
+
</itemDelta>
|
|
651
|
+
</objectModification>
|
|
652
|
+
EOF
|
|
653
|
+
|
|
654
|
+
# Apply the patch
|
|
655
|
+
midpoint-cli put user-patch.xml
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
### Using Configuration Files
|
|
659
|
+
|
|
660
|
+
Create a configuration file for different environments:
|
|
661
|
+
|
|
662
|
+
**~/.midpoint-cli.cfg** (Production):
|
|
663
|
+
```ini
|
|
664
|
+
[Midpoint]
|
|
665
|
+
url = https://midpoint.production.example.com/midpoint/
|
|
666
|
+
username = automation-user
|
|
667
|
+
password = secure-production-password
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
**./midpoint-cli.cfg** (Development - overrides home directory config):
|
|
671
|
+
```ini
|
|
672
|
+
[Midpoint]
|
|
673
|
+
url = https://localhost:8080/midpoint/
|
|
674
|
+
username = administrator
|
|
675
|
+
password = 5ecr3t
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
Then simply run commands without authentication parameters:
|
|
679
|
+
|
|
680
|
+
```bash
|
|
681
|
+
# Uses configuration from file
|
|
682
|
+
midpoint-cli users
|
|
683
|
+
midpoint-cli tasks
|
|
684
|
+
midpoint-cli resource test "AD Resource"
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
## Requirements
|
|
688
|
+
|
|
689
|
+
This program is compatible with Python version 3.8 or above.
|
|
690
|
+
|
|
691
|
+
## Installation
|
|
692
|
+
|
|
693
|
+
### Through PyPI
|
|
694
|
+
|
|
695
|
+
The most common way to install midpoint-cli on your own computer is to use the PyPI repository:
|
|
696
|
+
|
|
697
|
+
```bash
|
|
698
|
+
pip3 install midpoint-cli
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
The installation will automatically install all required dependencies including:
|
|
702
|
+
- `requests` for HTTP communication
|
|
703
|
+
- `tabulate` for formatted table output
|
|
704
|
+
- `args` for argument parsing
|
|
705
|
+
|
|
706
|
+
### Development build
|
|
707
|
+
|
|
708
|
+
Dependency management, build and test is managed using Python Poetry.
|
|
709
|
+
|
|
710
|
+
To install Poetry, please refer to [the official Python Poetry website](https://python-poetry.org/).
|
|
711
|
+
|
|
712
|
+
To install the current development version from GIT:
|
|
713
|
+
|
|
714
|
+
```bash
|
|
715
|
+
yk@lunar:~/dev$ git clone https://gitlab.com/alcibiade/midpoint-cli.git
|
|
716
|
+
Cloning into 'midpoint-cli'...
|
|
717
|
+
remote: Enumerating objects: 374, done.
|
|
718
|
+
remote: Counting objects: 100% (374/374), done.
|
|
719
|
+
remote: Compressing objects: 100% (176/176), done.
|
|
720
|
+
remote: Total 374 (delta 229), reused 299 (delta 175)
|
|
721
|
+
Receiving objects: 100% (374/374), 62.84 KiB | 0 bytes/s, done.
|
|
722
|
+
Resolving deltas: 100% (229/229), done.
|
|
723
|
+
|
|
724
|
+
yk@lunar:~/dev$ poetry install
|
|
725
|
+
Creating virtualenv midpoint-cli-54EjqR0S-py3.12 in /home/yk/.cache/pypoetry/virtualenvs
|
|
726
|
+
Updating dependencies
|
|
727
|
+
Resolving dependencies... (5.1s)
|
|
728
|
+
|
|
729
|
+
Package operations: 13 installs, 0 updates, 0 removals
|
|
730
|
+
|
|
731
|
+
- Installing args (0.1.0)
|
|
732
|
+
- Installing certifi (2024.8.30)
|
|
733
|
+
- Installing charset-normalizer (3.3.2)
|
|
734
|
+
- Installing idna (3.10)
|
|
735
|
+
- Installing iniconfig (2.0.0)
|
|
736
|
+
- Installing packaging (24.1)
|
|
737
|
+
- Installing pluggy (1.5.0)
|
|
738
|
+
- Installing urllib3 (2.2.3)
|
|
739
|
+
- Installing pytest (8.3.3)
|
|
740
|
+
- Installing requests (2.32.3)
|
|
741
|
+
- Installing tabulate (0.9.0)
|
|
742
|
+
- Installing unidecode (1.3.8)
|
|
743
|
+
|
|
744
|
+
Writing lock file
|
|
745
|
+
|
|
746
|
+
Installing the current project: midpoint-cli (1.4.0.dev2)
|
|
747
|
+
|
|
748
|
+
yk@lunar:~/dev$ poetry run midpoint-cli --version
|
|
749
|
+
Midpoint CLI Version 1.4.0.dev2
|
|
750
|
+
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
### Anaconda
|
|
754
|
+
|
|
755
|
+
Anaconda packages are not available yet.
|
|
756
|
+
|
|
757
|
+
## Setting up a sandbox environment
|
|
758
|
+
|
|
759
|
+
If you wish to test this project locally and don’t have a midpoint server available, you can use the
|
|
760
|
+
following instructions.
|
|
761
|
+
|
|
762
|
+
### Using the Evolveum managed Docker image
|
|
763
|
+
|
|
764
|
+
Pull the image locally:
|
|
765
|
+
|
|
766
|
+
```bash
|
|
767
|
+
yk@lunar:~$ docker pull evolveum/midpoint
|
|
768
|
+
Using default tag: latest
|
|
769
|
+
latest: Pulling from evolveum/midpoint
|
|
770
|
+
|
|
771
|
+
[...]
|
|
772
|
+
|
|
773
|
+
Digest: sha256:1e29b7e891d17bf7b1cf1853c84609e414c3a71d5c420aa38927200b2bdecc8e
|
|
774
|
+
Status: Downloaded newer image for evolveum/midpoint:latest
|
|
775
|
+
docker.io/evolveum/midpoint:latest
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
Then run the server and bind the port 8080:
|
|
781
|
+
|
|
782
|
+
```bash
|
|
783
|
+
yk@lunar:~$ docker run -d --name midpoint-1 -p8080:8080 evolveum/midpoint
|
|
784
|
+
c048d519395ca48c8e94e361a2239b1c35c5e5305a29600895056e030d6a576f
|
|
785
|
+
|
|
786
|
+
yk@lunar:~$ midpoint-cli
|
|
787
|
+
Welcome to Midpoint client ! Type ? for a list of commands
|
|
788
|
+
midpoint> users
|
|
789
|
+
OID Name Title FullName Status EmpNo Email OU
|
|
790
|
+
------------------------------------ ------------- ------- ---------------------- -------- ------- ------- ----
|
|
791
|
+
00000000-0000-0000-0000-000000000002 administrator midPoint Administrator enabled
|
|
792
|
+
midpoint>
|
|
793
|
+
|
|
794
|
+
yk@lunar:~$ docker stop midpoint-1
|
|
795
|
+
midpoint-1
|
|
796
|
+
```
|
|
797
|
+
|