ctm-web-client 2.0.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.
@@ -0,0 +1,17 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2026 MI19979
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include ctm_web_client *.py
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: ctm-web-client
3
+ Version: 2.0.0
4
+ Summary: Cliente Python para Control-M/EM Web: reportes, logs y monitoreo sin Automation API
5
+ Author: MI19979
6
+ License: GPL-3.0-or-later
7
+ Project-URL: Homepage, https://github.com/MI19979/ctm-web-client
8
+ Project-URL: Issues, https://github.com/MI19979/ctm-web-client/issues
9
+ Keywords: control-m,controlm,bmc,scheduling,monitoring,reports
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: System Administrators
13
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: System :: Monitoring
21
+ Classifier: Topic :: System :: Systems Administration
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: requests>=2.28.0
26
+ Requires-Dist: urllib3>=1.26.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.0; extra == "dev"
29
+ Requires-Dist: responses>=0.23; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # ctm-web-client
33
+
34
+ Cliente Python para **Control-M/EM Web** (on-premise). Permite descargar reportes, logs de ejecucion y monitorear jobs sin necesidad de privilegios de Automation API.
35
+
36
+ Funciona usando los mismos endpoints internos que utiliza la interfaz web de Control-M.
37
+
38
+ ## Instalacion
39
+
40
+ ```bash
41
+ pip install ctm-web-client
42
+ ```
43
+
44
+ O desde el codigo fuente:
45
+
46
+ ```bash
47
+ pip install -e .
48
+ ```
49
+
50
+ ## Uso rapido
51
+
52
+ ```python
53
+ from ctm_web_client import ControlMWebClient
54
+
55
+ with ControlMWebClient("https://controlm-server:8443/ControlM", verify_ssl=False) as client:
56
+ client.login("usuario", "password")
57
+
58
+ # Jobs activos con filtros
59
+ jobs = client.get_jobs(status="Ended Not OK", limit=100)
60
+ for j in jobs:
61
+ print(f"{j['jobId']} | {j['name']} | {j['status']}")
62
+
63
+ # Log de ejecucion de un job
64
+ log = client.get_job_log("CTM_SERVER:runid")
65
+ print(log)
66
+
67
+ # Output del proceso
68
+ output = client.get_job_output("CTM_SERVER:runid")
69
+ print(output)
70
+ ```
71
+
72
+ ## Reportes desde .em.json
73
+
74
+ Ejecuta cualquier reporte exportado de Control-M Web (archivos `.em.json`):
75
+
76
+ ```python
77
+ import json
78
+
79
+ with open("mi_reporte.em.json") as f:
80
+ config = json.load(f)
81
+
82
+ csv_bytes = client.wait_and_download_report(config["reportName"], config)
83
+
84
+ with open("reporte.csv", "wb") as f:
85
+ f.write(csv_bytes)
86
+ ```
87
+
88
+ ## Funcionalidades
89
+
90
+ ### Jobs activos
91
+
92
+ ```python
93
+ # Listar todos (con limite)
94
+ jobs = client.get_jobs(limit=1000)
95
+
96
+ # Filtrar por nombre, folder, estado, servidor
97
+ jobs = client.get_jobs(
98
+ job_name="MCTD*",
99
+ status="Ended Not OK",
100
+ ctm_server="CTM_DATIOPROD",
101
+ )
102
+
103
+ # Estado de un job especifico
104
+ status = client.get_job_status("CTM_DATIOPROD:4e9uy")
105
+ ```
106
+
107
+ ### Logs y Output
108
+
109
+ ```python
110
+ # Log de Control-M (eventos, tiempos, recursos)
111
+ log = client.get_job_log("CTM_DATIOPROD:4e9uy")
112
+
113
+ # Output del proceso (stdout/stderr del script)
114
+ output = client.get_job_output("CTM_DATIOPROD:4e9uy")
115
+ ```
116
+
117
+ ### Reportes
118
+
119
+ ```python
120
+ # Ejecutar reporte por nombre
121
+ result = client.run_report("ACTIVO-MX-*", config)
122
+
123
+ # Todo en uno: ejecutar, esperar y descargar
124
+ csv_bytes = client.wait_and_download_report("Jobs Definitions_1", config)
125
+ ```
126
+
127
+ ### Infraestructura
128
+
129
+ ```python
130
+ # Servidores Control-M
131
+ servers = client.get_servers()
132
+
133
+ # Recursos cuantitativos
134
+ resources = client.get_resources()
135
+
136
+ # Permisos del usuario
137
+ rights = client.get_effective_rights()
138
+ ```
139
+
140
+ ### Exportadores
141
+
142
+ ```python
143
+ from ctm_web_client.exporters import CSVExporter, JSONExporter, TextExporter
144
+
145
+ CSVExporter.export(jobs, "jobs.csv")
146
+ JSONExporter.export(data, "data.json")
147
+ TextExporter.export(log_text, "job.log")
148
+ ```
149
+
150
+ ### Decoder Protobuf
151
+
152
+ ```python
153
+ from ctm_web_client import decode_nested, decode_strings
154
+
155
+ raw = client.get_servers_info()
156
+ parsed = decode_nested(raw)
157
+ ```
158
+
159
+ ## Tipos de reporte soportados (.em.json)
160
+
161
+ | Design | Descripcion |
162
+ |--------|-------------|
163
+ | `active-jobs.rptdesign` | Jobs en la red activa |
164
+ | `forecast-execution.rptdesign` | Historial de ejecuciones |
165
+ | `jobs-definitions.rptdesign` | Definiciones de jobs |
166
+
167
+ ## Requisitos
168
+
169
+ - Python 3.10+
170
+ - Acceso de red al servidor Control-M/EM Web (puerto 8443)
171
+ - Credenciales de usuario web de Control-M (no requiere privilegios de Automation API)
172
+
173
+ ## Notas
174
+
175
+ - El servidor tiene un limite bajo de sesiones concurrentes. Siempre usa `with` o llama `client.logout()`.
176
+ - Los certificados SSL son self-signed en la mayoria de instalaciones on-premise. Usa `verify_ssl=False`.
177
+ - Los `jobId` tienen formato `SERVIDOR:RUNID` (ej: `CTM_DATIOPROD:4e9uy`).
178
+
179
+ ## Licencia
180
+
181
+ GPL-3.0-or-later (Copyleft)
182
+
183
+ ## Manejo de errores
184
+
185
+ ```python
186
+ from ctm_web_client.exceptions import (
187
+ AuthenticationError,
188
+ SessionExpiredError,
189
+ ResourceNotFoundError,
190
+ )
191
+
192
+ try:
193
+ client.login("user", "wrong_pass")
194
+ except AuthenticationError as e:
195
+ print(f"Login fallido: {e}")
196
+
197
+ try:
198
+ log = client.get_job_log("ID_INVALIDO")
199
+ except ResourceNotFoundError:
200
+ print("Job no encontrado")
201
+ except SessionExpiredError:
202
+ client.login("user", "pass") # Re-autenticar
203
+ ```
204
+
205
+ ## Notas importantes
206
+
207
+ - La biblioteca interactúa con los endpoints internos de la interfaz web de Control-M/EM. Los paths exactos pueden variar según la versión instalada.
208
+ - Si tu Control-M usa paths diferentes, puedes sobrescribir `ControlMWebClient._ENDPOINTS`.
209
+ - Para certificados SSL autofirmados, usa `verify_ssl=False`.
210
+ - Compatible con Control-M/EM v9.x y v20.x (Web interface).
211
+
212
+ ## Personalizar endpoints
213
+
214
+ Si tu instalación de Control-M usa rutas diferentes:
215
+
216
+ ```python
217
+ client = ControlMWebClient("https://server:8443/ControlM")
218
+ client._ENDPOINTS["jobs"] = "/web/api/monitoring/jobs"
219
+ client._ENDPOINTS["job_log"] = "/web/api/job/{job_id}/log"
220
+ client.login("user", "pass")
221
+ ```
@@ -0,0 +1,190 @@
1
+ # ctm-web-client
2
+
3
+ Cliente Python para **Control-M/EM Web** (on-premise). Permite descargar reportes, logs de ejecucion y monitorear jobs sin necesidad de privilegios de Automation API.
4
+
5
+ Funciona usando los mismos endpoints internos que utiliza la interfaz web de Control-M.
6
+
7
+ ## Instalacion
8
+
9
+ ```bash
10
+ pip install ctm-web-client
11
+ ```
12
+
13
+ O desde el codigo fuente:
14
+
15
+ ```bash
16
+ pip install -e .
17
+ ```
18
+
19
+ ## Uso rapido
20
+
21
+ ```python
22
+ from ctm_web_client import ControlMWebClient
23
+
24
+ with ControlMWebClient("https://controlm-server:8443/ControlM", verify_ssl=False) as client:
25
+ client.login("usuario", "password")
26
+
27
+ # Jobs activos con filtros
28
+ jobs = client.get_jobs(status="Ended Not OK", limit=100)
29
+ for j in jobs:
30
+ print(f"{j['jobId']} | {j['name']} | {j['status']}")
31
+
32
+ # Log de ejecucion de un job
33
+ log = client.get_job_log("CTM_SERVER:runid")
34
+ print(log)
35
+
36
+ # Output del proceso
37
+ output = client.get_job_output("CTM_SERVER:runid")
38
+ print(output)
39
+ ```
40
+
41
+ ## Reportes desde .em.json
42
+
43
+ Ejecuta cualquier reporte exportado de Control-M Web (archivos `.em.json`):
44
+
45
+ ```python
46
+ import json
47
+
48
+ with open("mi_reporte.em.json") as f:
49
+ config = json.load(f)
50
+
51
+ csv_bytes = client.wait_and_download_report(config["reportName"], config)
52
+
53
+ with open("reporte.csv", "wb") as f:
54
+ f.write(csv_bytes)
55
+ ```
56
+
57
+ ## Funcionalidades
58
+
59
+ ### Jobs activos
60
+
61
+ ```python
62
+ # Listar todos (con limite)
63
+ jobs = client.get_jobs(limit=1000)
64
+
65
+ # Filtrar por nombre, folder, estado, servidor
66
+ jobs = client.get_jobs(
67
+ job_name="MCTD*",
68
+ status="Ended Not OK",
69
+ ctm_server="CTM_DATIOPROD",
70
+ )
71
+
72
+ # Estado de un job especifico
73
+ status = client.get_job_status("CTM_DATIOPROD:4e9uy")
74
+ ```
75
+
76
+ ### Logs y Output
77
+
78
+ ```python
79
+ # Log de Control-M (eventos, tiempos, recursos)
80
+ log = client.get_job_log("CTM_DATIOPROD:4e9uy")
81
+
82
+ # Output del proceso (stdout/stderr del script)
83
+ output = client.get_job_output("CTM_DATIOPROD:4e9uy")
84
+ ```
85
+
86
+ ### Reportes
87
+
88
+ ```python
89
+ # Ejecutar reporte por nombre
90
+ result = client.run_report("ACTIVO-MX-*", config)
91
+
92
+ # Todo en uno: ejecutar, esperar y descargar
93
+ csv_bytes = client.wait_and_download_report("Jobs Definitions_1", config)
94
+ ```
95
+
96
+ ### Infraestructura
97
+
98
+ ```python
99
+ # Servidores Control-M
100
+ servers = client.get_servers()
101
+
102
+ # Recursos cuantitativos
103
+ resources = client.get_resources()
104
+
105
+ # Permisos del usuario
106
+ rights = client.get_effective_rights()
107
+ ```
108
+
109
+ ### Exportadores
110
+
111
+ ```python
112
+ from ctm_web_client.exporters import CSVExporter, JSONExporter, TextExporter
113
+
114
+ CSVExporter.export(jobs, "jobs.csv")
115
+ JSONExporter.export(data, "data.json")
116
+ TextExporter.export(log_text, "job.log")
117
+ ```
118
+
119
+ ### Decoder Protobuf
120
+
121
+ ```python
122
+ from ctm_web_client import decode_nested, decode_strings
123
+
124
+ raw = client.get_servers_info()
125
+ parsed = decode_nested(raw)
126
+ ```
127
+
128
+ ## Tipos de reporte soportados (.em.json)
129
+
130
+ | Design | Descripcion |
131
+ |--------|-------------|
132
+ | `active-jobs.rptdesign` | Jobs en la red activa |
133
+ | `forecast-execution.rptdesign` | Historial de ejecuciones |
134
+ | `jobs-definitions.rptdesign` | Definiciones de jobs |
135
+
136
+ ## Requisitos
137
+
138
+ - Python 3.10+
139
+ - Acceso de red al servidor Control-M/EM Web (puerto 8443)
140
+ - Credenciales de usuario web de Control-M (no requiere privilegios de Automation API)
141
+
142
+ ## Notas
143
+
144
+ - El servidor tiene un limite bajo de sesiones concurrentes. Siempre usa `with` o llama `client.logout()`.
145
+ - Los certificados SSL son self-signed en la mayoria de instalaciones on-premise. Usa `verify_ssl=False`.
146
+ - Los `jobId` tienen formato `SERVIDOR:RUNID` (ej: `CTM_DATIOPROD:4e9uy`).
147
+
148
+ ## Licencia
149
+
150
+ GPL-3.0-or-later (Copyleft)
151
+
152
+ ## Manejo de errores
153
+
154
+ ```python
155
+ from ctm_web_client.exceptions import (
156
+ AuthenticationError,
157
+ SessionExpiredError,
158
+ ResourceNotFoundError,
159
+ )
160
+
161
+ try:
162
+ client.login("user", "wrong_pass")
163
+ except AuthenticationError as e:
164
+ print(f"Login fallido: {e}")
165
+
166
+ try:
167
+ log = client.get_job_log("ID_INVALIDO")
168
+ except ResourceNotFoundError:
169
+ print("Job no encontrado")
170
+ except SessionExpiredError:
171
+ client.login("user", "pass") # Re-autenticar
172
+ ```
173
+
174
+ ## Notas importantes
175
+
176
+ - La biblioteca interactúa con los endpoints internos de la interfaz web de Control-M/EM. Los paths exactos pueden variar según la versión instalada.
177
+ - Si tu Control-M usa paths diferentes, puedes sobrescribir `ControlMWebClient._ENDPOINTS`.
178
+ - Para certificados SSL autofirmados, usa `verify_ssl=False`.
179
+ - Compatible con Control-M/EM v9.x y v20.x (Web interface).
180
+
181
+ ## Personalizar endpoints
182
+
183
+ Si tu instalación de Control-M usa rutas diferentes:
184
+
185
+ ```python
186
+ client = ControlMWebClient("https://server:8443/ControlM")
187
+ client._ENDPOINTS["jobs"] = "/web/api/monitoring/jobs"
188
+ client._ENDPOINTS["job_log"] = "/web/api/job/{job_id}/log"
189
+ client.login("user", "pass")
190
+ ```
@@ -0,0 +1,32 @@
1
+ """
2
+ ctm_web_client - Biblioteca para extraer reportes y logs de Control-M/EM Web
3
+ sin necesidad de acceso al API oficial.
4
+
5
+ Uso básico:
6
+ from ctm_web_client import ControlMWebClient
7
+
8
+ client = ControlMWebClient("https://controlm-server:8443/ControlM")
9
+ client.login("usuario", "contraseña")
10
+
11
+ # Obtener jobs ejecutados
12
+ jobs = client.get_jobs(folder="MI_FOLDER", date="2026-08-20")
13
+
14
+ # Descargar log de un job
15
+ log = client.get_job_log(job_id="SERVER:00abc")
16
+
17
+ # Exportar reporte
18
+ client.export_report("ejecuciones", format="csv", output_path="reporte.csv")
19
+
20
+ client.logout()
21
+ """
22
+
23
+ from ctm_web_client.client_v2 import ControlMWebClient
24
+ from ctm_web_client.exporters import JSONExporter, CSVExporter, TextExporter
25
+ from ctm_web_client.proto_decoder import decode_em_response, decode_nested, decode_strings
26
+
27
+ __version__ = "2.0.0"
28
+ __all__ = [
29
+ "ControlMWebClient",
30
+ "JSONExporter", "CSVExporter", "TextExporter",
31
+ "decode_em_response", "decode_nested", "decode_strings",
32
+ ]