midpoint-cli 1.3.1__tar.gz → 1.4.0__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.
Files changed (49) hide show
  1. {midpoint_cli-1.3.1/midpoint_cli.egg-info → midpoint_cli-1.4.0}/PKG-INFO +58 -39
  2. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/README.md +35 -27
  3. midpoint_cli-1.4.0/pyproject.toml +143 -0
  4. midpoint_cli-1.4.0/src/midpoint_cli/__init__.py +83 -0
  5. midpoint_cli-1.4.0/src/midpoint_cli/client/__init__.py +240 -0
  6. midpoint_cli-1.4.0/src/midpoint_cli/client/objects.py +364 -0
  7. midpoint_cli-1.4.0/src/midpoint_cli/client/observer.py +26 -0
  8. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/client/patch.py +1 -1
  9. midpoint_cli-1.4.0/src/midpoint_cli/client/progress.py +33 -0
  10. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/client/session.py +8 -11
  11. midpoint_cli-1.4.0/src/midpoint_cli/prompt/__init__.py +165 -0
  12. midpoint_cli-1.4.0/src/midpoint_cli/prompt/base.py +13 -0
  13. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/prompt/complete.py +5 -7
  14. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/prompt/configuration.py +4 -4
  15. midpoint_cli-1.4.0/src/midpoint_cli/prompt/console.py +297 -0
  16. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/prompt/delete.py +2 -4
  17. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/prompt/get.py +12 -8
  18. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/prompt/org.py +35 -8
  19. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/prompt/put.py +6 -8
  20. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/prompt/resource.py +56 -11
  21. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/prompt/script.py +7 -11
  22. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/prompt/task.py +71 -20
  23. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/src/midpoint_cli/prompt/user.py +42 -9
  24. midpoint_cli-1.3.1/MANIFEST.in +0 -1
  25. midpoint_cli-1.3.1/PKG-INFO +0 -236
  26. midpoint_cli-1.3.1/midpoint_cli.egg-info/SOURCES.txt +0 -39
  27. midpoint_cli-1.3.1/midpoint_cli.egg-info/dependency_links.txt +0 -1
  28. midpoint_cli-1.3.1/midpoint_cli.egg-info/requires.txt +0 -6
  29. midpoint_cli-1.3.1/midpoint_cli.egg-info/top_level.txt +0 -1
  30. midpoint_cli-1.3.1/requirements.txt +0 -7
  31. midpoint_cli-1.3.1/setup.cfg +0 -7
  32. midpoint_cli-1.3.1/setup.py +0 -47
  33. midpoint_cli-1.3.1/src/midpoint-cli +0 -67
  34. midpoint_cli-1.3.1/src/midpoint_cli/__init__.py +0 -1
  35. midpoint_cli-1.3.1/src/midpoint_cli/client/__init__.py +0 -228
  36. midpoint_cli-1.3.1/src/midpoint_cli/client/objects.py +0 -220
  37. midpoint_cli-1.3.1/src/midpoint_cli/client/observer.py +0 -10
  38. midpoint_cli-1.3.1/src/midpoint_cli/client/progress.py +0 -26
  39. midpoint_cli-1.3.1/src/midpoint_cli/prompt/__init__.py +0 -63
  40. midpoint_cli-1.3.1/src/midpoint_cli/prompt/base.py +0 -5
  41. midpoint_cli-1.3.1/src/midpoint_cli/prompt/console.py +0 -21
  42. midpoint_cli-1.3.1/test/test_client_api.py +0 -43
  43. midpoint_cli-1.3.1/test/test_client_model.py +0 -39
  44. midpoint_cli-1.3.1/test/test_client_put.py +0 -44
  45. midpoint_cli-1.3.1/test/test_environment.py +0 -54
  46. midpoint_cli-1.3.1/test/test_parser.py +0 -62
  47. midpoint_cli-1.3.1/test/test_patch.py +0 -30
  48. midpoint_cli-1.3.1/test/test_script.py +0 -49
  49. {midpoint_cli-1.3.1 → midpoint_cli-1.4.0}/LICENSE +0 -0
@@ -1,25 +1,35 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: midpoint-cli
3
- Version: 1.3.1
3
+ Version: 1.4.0
4
4
  Summary: A command line client to Midpoint Identity Management system.
5
- Home-page: https://gitlab.com/alcibiade/midpoint-cli
5
+ License: MIT
6
+ License-File: LICENSE
6
7
  Author: Yannick Kirschhoffer
7
8
  Author-email: alcibiade@alcibiade.org
8
- License: MIT
9
+ Maintainer: Yannick Kirschhoffer
10
+ Maintainer-email: alcibiade@alcibiade.org
11
+ Requires-Python: >=3.9.0,<4.0.0
9
12
  Classifier: Development Status :: 5 - Production/Stable
10
13
  Classifier: Intended Audience :: Developers
11
14
  Classifier: Intended Audience :: System Administrators
12
- Classifier: Topic :: System :: Systems Administration
13
15
  Classifier: License :: OSI Approved :: MIT License
14
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: tabulate (>=0.9,<0.10)
29
+ Requires-Dist: unidecode (>=1.3,<2.0)
30
+ Requires-Dist: urllib3 (>=2.0,<3.0)
31
+ Project-URL: Repository, https://gitlab.com/alcibiade/midpoint-cli
15
32
  Description-Content-Type: text/markdown
16
- License-File: LICENSE
17
- Requires-Dist: clint>=0.5
18
- Requires-Dist: tabulate>=0.9
19
- Requires-Dist: unidecode>=1.3
20
- Requires-Dist: requests>=2.31
21
- Requires-Dist: urllib3>=2.0
22
- Requires-Dist: setuptools>=68.0
23
33
 
24
34
  ![link=https://badge.fury.io/py/midpoint-cli](https://badge.fury.io/py/midpoint-cli.svg)
25
35
 
@@ -43,9 +53,9 @@ The client currently supports:
43
53
 
44
54
  Features currently under development:
45
55
 
46
- * Auto completion to search of IDs or task names
56
+ * Auto-completion to search of IDs or task names
47
57
  * Improved task results display: retrieve and display a human readable status output
48
- * Any other tasks that would be sumbitted in the issue tracker of this project on Gitlab
58
+ * Any other tasks that would be submitted in the issue tracker of this project on Gitlab
49
59
 
50
60
  The strong points of this project are:
51
61
 
@@ -144,6 +154,10 @@ Successfully installed args-0.1.0 certifi-2019.9.11 chardet-3.0.4 clint-0.5.1 id
144
154
 
145
155
  ### Development build
146
156
 
157
+ Dependency management, build and test is managed using Python Poetry.
158
+
159
+ To install Poetry, please refer to [the official Python Poetry website](https://python-poetry.org/).
160
+
147
161
  To install the current development version from GIT:
148
162
 
149
163
  ```bash
@@ -156,30 +170,34 @@ remote: Total 374 (delta 229), reused 299 (delta 175)
156
170
  Receiving objects: 100% (374/374), 62.84 KiB | 0 bytes/s, done.
157
171
  Resolving deltas: 100% (229/229), done.
158
172
 
159
- yk@lunar:~/dev$ pip3 install midpoint-cli/
160
- Processing ./midpoint-cli
161
- Collecting clint (from midpoint-cli===0.8-snapshot)
162
- Collecting requests (from midpoint-cli===0.8-snapshot)
163
- Using cached https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl
164
- Collecting tabulate (from midpoint-cli===0.8-snapshot)
165
- Collecting args (from clint->midpoint-cli===0.8-snapshot)
166
- Collecting chardet<3.1.0,>=3.0.2 (from requests->midpoint-cli===0.8-snapshot)
167
- Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
168
- Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->midpoint-cli===0.8-snapshot)
169
- Using cached https://files.pythonhosted.org/packages/e0/da/55f51ea951e1b7c63a579c09dd7db825bb730ec1fe9c0180fc77bfb31448/urllib3-1.25.6-py2.py3-none-any.whl
170
- Collecting certifi>=2017.4.17 (from requests->midpoint-cli===0.8-snapshot)
171
- Using cached https://files.pythonhosted.org/packages/18/b0/8146a4f8dd402f60744fa380bc73ca47303cccf8b9190fd16a827281eac2/certifi-2019.9.11-py2.py3-none-any.whl
172
- Collecting idna<2.9,>=2.5 (from requests->midpoint-cli===0.8-snapshot)
173
- Using cached https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl
174
- Building wheels for collected packages: midpoint-cli
175
- Running setup.py bdist_wheel for midpoint-cli ... done
176
- Stored in directory: /home/yk/.cache/pip/wheels/2a/5a/d6/54312f2db19e2a44cea90e4e1c186e7c1beb7192b4974db759
177
- Successfully built midpoint-cli
178
- Installing collected packages: args, clint, chardet, urllib3, certifi, idna, requests, tabulate, midpoint-cli
179
- Successfully installed args-0.1.0 certifi-2019.9.11 chardet-3.0.4 clint-0.5.1 idna-2.8 midpoint-cli-0.7.0 requests-2.22.0 tabulate-0.8.5 urllib3-1.25.6
173
+ yk@lunar:~/dev$ poetry install
174
+ Creating virtualenv midpoint-cli-54EjqR0S-py3.12 in /home/yk/.cache/pypoetry/virtualenvs
175
+ Updating dependencies
176
+ Resolving dependencies... (5.1s)
177
+
178
+ Package operations: 13 installs, 0 updates, 0 removals
179
+
180
+ - Installing args (0.1.0)
181
+ - Installing certifi (2024.8.30)
182
+ - Installing charset-normalizer (3.3.2)
183
+ - Installing idna (3.10)
184
+ - Installing iniconfig (2.0.0)
185
+ - Installing packaging (24.1)
186
+ - Installing pluggy (1.5.0)
187
+ - Installing urllib3 (2.2.3)
188
+ - Installing clint (0.5.1)
189
+ - Installing pytest (8.3.3)
190
+ - Installing requests (2.32.3)
191
+ - Installing tabulate (0.9.0)
192
+ - Installing unidecode (1.3.8)
193
+
194
+ Writing lock file
195
+
196
+ Installing the current project: midpoint-cli (1.4.0.dev2)
197
+
198
+ yk@lunar:~/dev$ poetry run midpoint-cli --version
199
+ Midpoint CLI Version 1.4.0.dev2
180
200
 
181
- yk@lunar:~/dev$ midpoint-cli -v
182
- Midpoint CLI Version 0.8-snapshot
183
201
  ```
184
202
 
185
203
  ### Anaconda
@@ -232,5 +250,6 @@ midpoint-1
232
250
  * Update revision in src/midpoint_cli/__init__.py
233
251
  * Commit and tag with corresponding version number
234
252
  * Generate markdown documentation: downdoc README.adoc
235
- * Build distribution: python setup.py sdist
236
- * Upload distribution to PyPI: twine upload dist/*
253
+ * Build distribution: poetry build
254
+ * Upload distribution to PyPI: poetry publish
255
+
@@ -20,9 +20,9 @@ The client currently supports:
20
20
 
21
21
  Features currently under development:
22
22
 
23
- * Auto completion to search of IDs or task names
23
+ * Auto-completion to search of IDs or task names
24
24
  * Improved task results display: retrieve and display a human readable status output
25
- * Any other tasks that would be sumbitted in the issue tracker of this project on Gitlab
25
+ * Any other tasks that would be submitted in the issue tracker of this project on Gitlab
26
26
 
27
27
  The strong points of this project are:
28
28
 
@@ -121,6 +121,10 @@ Successfully installed args-0.1.0 certifi-2019.9.11 chardet-3.0.4 clint-0.5.1 id
121
121
 
122
122
  ### Development build
123
123
 
124
+ Dependency management, build and test is managed using Python Poetry.
125
+
126
+ To install Poetry, please refer to [the official Python Poetry website](https://python-poetry.org/).
127
+
124
128
  To install the current development version from GIT:
125
129
 
126
130
  ```bash
@@ -133,30 +137,34 @@ remote: Total 374 (delta 229), reused 299 (delta 175)
133
137
  Receiving objects: 100% (374/374), 62.84 KiB | 0 bytes/s, done.
134
138
  Resolving deltas: 100% (229/229), done.
135
139
 
136
- yk@lunar:~/dev$ pip3 install midpoint-cli/
137
- Processing ./midpoint-cli
138
- Collecting clint (from midpoint-cli===0.8-snapshot)
139
- Collecting requests (from midpoint-cli===0.8-snapshot)
140
- Using cached https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl
141
- Collecting tabulate (from midpoint-cli===0.8-snapshot)
142
- Collecting args (from clint->midpoint-cli===0.8-snapshot)
143
- Collecting chardet<3.1.0,>=3.0.2 (from requests->midpoint-cli===0.8-snapshot)
144
- Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
145
- Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->midpoint-cli===0.8-snapshot)
146
- Using cached https://files.pythonhosted.org/packages/e0/da/55f51ea951e1b7c63a579c09dd7db825bb730ec1fe9c0180fc77bfb31448/urllib3-1.25.6-py2.py3-none-any.whl
147
- Collecting certifi>=2017.4.17 (from requests->midpoint-cli===0.8-snapshot)
148
- Using cached https://files.pythonhosted.org/packages/18/b0/8146a4f8dd402f60744fa380bc73ca47303cccf8b9190fd16a827281eac2/certifi-2019.9.11-py2.py3-none-any.whl
149
- Collecting idna<2.9,>=2.5 (from requests->midpoint-cli===0.8-snapshot)
150
- Using cached https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl
151
- Building wheels for collected packages: midpoint-cli
152
- Running setup.py bdist_wheel for midpoint-cli ... done
153
- Stored in directory: /home/yk/.cache/pip/wheels/2a/5a/d6/54312f2db19e2a44cea90e4e1c186e7c1beb7192b4974db759
154
- Successfully built midpoint-cli
155
- Installing collected packages: args, clint, chardet, urllib3, certifi, idna, requests, tabulate, midpoint-cli
156
- Successfully installed args-0.1.0 certifi-2019.9.11 chardet-3.0.4 clint-0.5.1 idna-2.8 midpoint-cli-0.7.0 requests-2.22.0 tabulate-0.8.5 urllib3-1.25.6
140
+ yk@lunar:~/dev$ poetry install
141
+ Creating virtualenv midpoint-cli-54EjqR0S-py3.12 in /home/yk/.cache/pypoetry/virtualenvs
142
+ Updating dependencies
143
+ Resolving dependencies... (5.1s)
144
+
145
+ Package operations: 13 installs, 0 updates, 0 removals
146
+
147
+ - Installing args (0.1.0)
148
+ - Installing certifi (2024.8.30)
149
+ - Installing charset-normalizer (3.3.2)
150
+ - Installing idna (3.10)
151
+ - Installing iniconfig (2.0.0)
152
+ - Installing packaging (24.1)
153
+ - Installing pluggy (1.5.0)
154
+ - Installing urllib3 (2.2.3)
155
+ - Installing clint (0.5.1)
156
+ - Installing pytest (8.3.3)
157
+ - Installing requests (2.32.3)
158
+ - Installing tabulate (0.9.0)
159
+ - Installing unidecode (1.3.8)
160
+
161
+ Writing lock file
162
+
163
+ Installing the current project: midpoint-cli (1.4.0.dev2)
164
+
165
+ yk@lunar:~/dev$ poetry run midpoint-cli --version
166
+ Midpoint CLI Version 1.4.0.dev2
157
167
 
158
- yk@lunar:~/dev$ midpoint-cli -v
159
- Midpoint CLI Version 0.8-snapshot
160
168
  ```
161
169
 
162
170
  ### Anaconda
@@ -209,5 +217,5 @@ midpoint-1
209
217
  * Update revision in src/midpoint_cli/__init__.py
210
218
  * Commit and tag with corresponding version number
211
219
  * Generate markdown documentation: downdoc README.adoc
212
- * Build distribution: python setup.py sdist
213
- * Upload distribution to PyPI: twine upload dist/*
220
+ * Build distribution: poetry build
221
+ * Upload distribution to PyPI: poetry publish
@@ -0,0 +1,143 @@
1
+ [build-system]
2
+ requires = ["poetry-core"]
3
+ build-backend = "poetry.core.masonry.api"
4
+
5
+ [tool.poetry]
6
+ name = "midpoint-cli"
7
+ version = "1.4.0"
8
+ description = "A command line client to Midpoint Identity Management system."
9
+ readme = "README.md"
10
+
11
+ license = "MIT"
12
+ authors = ["Yannick Kirschhoffer <alcibiade@alcibiade.org>"]
13
+ maintainers = ["Yannick Kirschhoffer <alcibiade@alcibiade.org>"]
14
+ repository = "https://gitlab.com/alcibiade/midpoint-cli"
15
+
16
+ packages = [
17
+ { include = "midpoint_cli", from = "src" }
18
+ ]
19
+
20
+ classifiers = [
21
+ "Development Status :: 5 - Production/Stable",
22
+ "Intended Audience :: Developers",
23
+ "Intended Audience :: System Administrators",
24
+ "Topic :: System :: Systems Administration",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.9",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Programming Language :: Python :: 3.14"
33
+ ]
34
+
35
+ [tool.poetry.scripts]
36
+ midpoint-cli = 'midpoint_cli:main'
37
+
38
+ [tool.poetry.dependencies]
39
+ python = "^3.9.0"
40
+ tabulate = "^0.9"
41
+ unidecode = "^1.3"
42
+ requests = "^2.31"
43
+ urllib3 = "^2.0"
44
+ rich = "^13.0"
45
+ prompt-toolkit = "^3.0"
46
+ pygments = "^2.0"
47
+
48
+ [tool.poetry.group.test.dependencies]
49
+ pytest = "*"
50
+
51
+ [tool.poetry.group.dev.dependencies]
52
+ pytest-cov = "*"
53
+ ruff = "*"
54
+ mypy = "*"
55
+
56
+ [tool.ruff]
57
+ target-version = "py39"
58
+ line-length = 120
59
+ exclude = [
60
+ ".git",
61
+ ".pytest_cache",
62
+ ".ruff_cache",
63
+ "__pycache__",
64
+ "build",
65
+ "dist",
66
+ "venv",
67
+ ".venv",
68
+ ]
69
+
70
+ [tool.ruff.lint]
71
+ select = [
72
+ "E", # pycodestyle errors
73
+ "W", # pycodestyle warnings
74
+ "F", # pyflakes
75
+ "I", # isort
76
+ "B", # flake8-bugbear
77
+ "C4", # flake8-comprehensions
78
+ "UP", # pyupgrade
79
+ ]
80
+ ignore = [
81
+ "E501", # line too long (handled by formatter)
82
+ ]
83
+
84
+ [tool.ruff.format]
85
+ quote-style = "single"
86
+ indent-style = "space"
87
+ skip-magic-trailing-comma = false
88
+ line-ending = "auto"
89
+
90
+ [tool.mypy]
91
+ python_version = "3.9"
92
+ warn_return_any = true
93
+ warn_unused_configs = true
94
+ disallow_untyped_defs = false
95
+ disallow_incomplete_defs = false
96
+ check_untyped_defs = true
97
+ disallow_untyped_decorators = false
98
+ warn_redundant_casts = true
99
+ warn_unused_ignores = true
100
+ warn_no_return = true
101
+ warn_unreachable = true
102
+ strict_equality = true
103
+ show_error_codes = true
104
+
105
+ [[tool.mypy.overrides]]
106
+ module = [
107
+ "tabulate.*",
108
+ "unidecode.*",
109
+ "requests.*",
110
+ "urllib3.*",
111
+ ]
112
+ ignore_missing_imports = true
113
+
114
+ [tool.coverage.run]
115
+ source = ["src"]
116
+ branch = true
117
+ omit = [
118
+ "*/tests/*",
119
+ "*/test/*",
120
+ "*/__pycache__/*",
121
+ "*/venv/*",
122
+ "*/.venv/*",
123
+ ]
124
+
125
+ [tool.coverage.report]
126
+ exclude_lines = [
127
+ "pragma: no cover",
128
+ "def __repr__",
129
+ "if self.debug:",
130
+ "if settings.DEBUG",
131
+ "raise AssertionError",
132
+ "raise NotImplementedError",
133
+ "if 0:",
134
+ "if __name__ == .__main__.:",
135
+ "class .*\\bProtocol\\):",
136
+ "@(abc\\.)?abstractmethod",
137
+ ]
138
+ show_missing = true
139
+ skip_covered = false
140
+ precision = 2
141
+
142
+ [tool.coverage.html]
143
+ directory = "coverage_html_report"
@@ -0,0 +1,83 @@
1
+ import importlib
2
+ import importlib.metadata
3
+ import logging
4
+ import os
5
+ import sys
6
+ from argparse import ArgumentParser, RawTextHelpFormatter
7
+ from configparser import ConfigParser
8
+
9
+ from midpoint_cli.client import MidpointClient
10
+ from midpoint_cli.prompt import MidpointClientPrompt
11
+ from midpoint_cli.prompt.configuration import compute_client_configuration
12
+ from midpoint_cli.prompt.console import ConsoleDisplay
13
+
14
+
15
+ def main():
16
+ logging.basicConfig(level=logging.INFO)
17
+ logging.getLogger('urllib3.connectionpool').setLevel(logging.ERROR)
18
+
19
+ version = importlib.metadata.version('midpoint_cli')
20
+
21
+ MIDPOINT_ENVIRONMENT_VARS = ['MIDPOINT_URL', 'MIDPOINT_USERNAME', 'MIDPOINT_PASSWORD']
22
+
23
+ argument_parser = ArgumentParser(
24
+ description='An interactive Midpoint command line client.',
25
+ formatter_class=RawTextHelpFormatter,
26
+ epilog="""
27
+ Available commands:
28
+ get Get an XML definition from the server from an existing OID reference.
29
+ put Create/Update a server object based on an XML structure.
30
+ delete Delete a server object based on its type and OID.
31
+
32
+ task Manage server tasks.
33
+ resource Manage resources on the server.
34
+
35
+ org Manage organizations.
36
+ user Manage users.
37
+
38
+ Server URL and credentials can also be stored in ~/.midpoint-cli.cfg, or read from environment variables MIDPOINT_URL,
39
+ MIDPOINT_USERNAME and MIDPOINT_PASSWORD.
40
+
41
+ Midpoint-cli version """
42
+ + version
43
+ + """, created and maintained by Yannick Kirschhoffer alcibiade@alcibiade.org
44
+ """,
45
+ )
46
+ argument_parser.add_argument(
47
+ '-v', '--version', help='Set the username to authenticate this session.', action='store_true'
48
+ )
49
+ argument_parser.add_argument(
50
+ '-u', '--username', help='Set the username to authenticate this session.', default=None
51
+ )
52
+ argument_parser.add_argument(
53
+ '-p', '--password', help='Set the password to authenticate this session.', default=None
54
+ )
55
+ argument_parser.add_argument('-U', '--url', help='Midpoint base URL', default=None)
56
+ argument_parser.add_argument('command', help='Optional command to be executed immediately.', nargs='?')
57
+ argument_parser.add_argument('arg', help='Optional command arguments.', nargs='*')
58
+
59
+ argument_namespace = argument_parser.parse_args(sys.argv[1:])
60
+
61
+ if argument_namespace.version:
62
+ print(f'Midpoint CLI Version {version}')
63
+ sys.exit(0)
64
+
65
+ config_parser = ConfigParser()
66
+ config_parser.read(['midpoint-cli.cfg', os.path.expanduser('~/.midpoint-cli.cfg')])
67
+
68
+ client_configuration = compute_client_configuration(
69
+ argument_namespace, config_parser, [os.getenv(v) for v in MIDPOINT_ENVIRONMENT_VARS]
70
+ )
71
+
72
+ client = MidpointClient(client_configuration, observer=ConsoleDisplay())
73
+ prompt = MidpointClientPrompt(client)
74
+
75
+ if argument_namespace.command is not None:
76
+ prompt.onecmd(argument_namespace.command + ' ' + ' '.join(argument_namespace.arg))
77
+ sys.exit(prompt.error_code)
78
+ else:
79
+ prompt.cmdloop()
80
+
81
+
82
+ if __name__ == '__main__':
83
+ main()