Skip to content

Commit 714f037

Browse files
authored
Merge pull request #107 from controlm/run-on-demand-documentation
support run on-demand Automation-API #89
2 parents 867ed58 + 0afab2c commit 714f037

33 files changed

+903
-12
lines changed

docs/_sources/index.rst.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Control-M Python Client is built for data scientists and developers who prefer a
2121
notebooks/jobtypes
2222
notebooks/jobproperties
2323
notebooks/connectionprofiles
24+
notebooks/run_ondemand
2425
beyond
2526

2627
.. toctree::
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Run On Demand"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 1,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"from ctm_python_client.core.comm import Environment\n",
17+
"from aapi import *"
18+
]
19+
},
20+
{
21+
"cell_type": "markdown",
22+
"metadata": {},
23+
"source": [
24+
"[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_Services_RunService.htm#run2)\n",
25+
"\n",
26+
"The `run_on_demand()` method in the Control-M Python Client allows you to execute individual jobs, folders, or subfolders dynamically without using Workflow. You do not need to deploy the jobs to the Control-M/EM database and the User Daily job does not need to trigger them. This is useful for event-driven job executions.\n",
27+
"\n",
28+
"This guide demonstrates how to use `run_on_demand()` with the `Job`, `Folder`, and `SubFolder` classes.\n",
29+
"\n",
30+
"***Requires Control-M/EM version 9.0.21.200***"
31+
]
32+
},
33+
{
34+
"cell_type": "markdown",
35+
"metadata": {},
36+
"source": [
37+
"### Code Example:"
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": null,
43+
"metadata": {},
44+
"outputs": [
45+
{
46+
"name": "stdout",
47+
"output_type": "stream",
48+
"text": [
49+
"+ echo Hello\n",
50+
"Hello\n",
51+
"\n",
52+
"Run Status\n",
53+
"--------------------------------------------------\n",
54+
" run_on_demand928 .................. Ended OK\n",
55+
" HelloJob ...................... Ended OK\n",
56+
"\n",
57+
"Run Status\n",
58+
"--------------------------------------------------\n",
59+
" TestFolder ........................ Ended OK\n",
60+
" HelloJob .......................... Ended OK\n",
61+
"\n"
62+
]
63+
}
64+
],
65+
"source": [
66+
"import time\n",
67+
"# Step 1: Define the Job, Folder, Sub-Folder\n",
68+
"demand_job = JobCommand('HelloJob', command='echo Hello')\n",
69+
"demand_sub_folder = SubFolder(\"TestSubFolder\", job_list=[demand_job])\n",
70+
"demand_folder = Folder(\"TestFolder\", job_list=[demand_job])\n",
71+
"\n",
72+
"# Step 2: Define an Environment\n",
73+
"env = Environment.create_onprem(host='controlm', username='***', password='****')\n",
74+
"# Step 3: Run the Job On Demand\n",
75+
"run_demand_job = demand_job.run_on_demand(\n",
76+
" environment=env,\n",
77+
" run_as='user',\n",
78+
" controlm_server='ControlM'\n",
79+
" )\n",
80+
"time.sleep(4)\n",
81+
"run_demand_job.print_output('HelloJob')\n",
82+
"\n",
83+
"# Step 4: Run the SubFolder On Demand\n",
84+
"run_demand_sub_folder = demand_sub_folder.run_on_demand(\n",
85+
" environment=env,\n",
86+
" run_as='user',\n",
87+
" controlm_server='ControlM'\n",
88+
" )\n",
89+
"time.sleep(4)\n",
90+
"run_demand_sub_folder.print_statuses()\n",
91+
"\n",
92+
"# Step 5: Run the Folder On Demand\n",
93+
"run_demand_folder = demand_folder.run_on_demand(\n",
94+
" environment=env,\n",
95+
" run_as='user',\n",
96+
" controlm_server='ControlM'\n",
97+
" )\n",
98+
"time.sleep(4)\n",
99+
"run_demand_folder.print_statuses()\n"
100+
]
101+
},
102+
{
103+
"cell_type": "markdown",
104+
"metadata": {},
105+
"source": [
106+
"### Additional Notes:\n",
107+
"\n",
108+
"- Ensure that the *Control-M/EM version is 9.0.21.200* or higher. Older versions not support the `run_on_demand()` method.\n",
109+
"- `Folder`s and `Subfolder`s must include at least one `Job`. If a `Folder` or `SubFolder` does not contain any jobs, an exception will be raised with the error:\n",
110+
"`\"Run is not allowed for JSON without jobs\"`\n",
111+
"- The `run_as` user must have the necessary permissions in Control-M.\n",
112+
"- The `controlm_server` parameter specifies the Control-M server responsible for execution."
113+
]
114+
}
115+
],
116+
"metadata": {
117+
"kernelspec": {
118+
"display_name": "venv",
119+
"language": "python",
120+
"name": "python3"
121+
},
122+
"language_info": {
123+
"codemirror_mode": {
124+
"name": "ipython",
125+
"version": 3
126+
},
127+
"file_extension": ".py",
128+
"mimetype": "text/x-python",
129+
"name": "python",
130+
"nbconvert_exporter": "python",
131+
"pygments_lexer": "ipython3",
132+
"version": "3.8.9"
133+
}
134+
},
135+
"nbformat": 4,
136+
"nbformat_minor": 2
137+
}

docs/aapi.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobtypes.html">Job types</a></li>
230230
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobproperties.html">Job and Folder Properties</a></li>
231231
<li class="toctree-l1"><a class="reference internal" href="notebooks/connectionprofiles.html">Connection Profiles</a></li>
232+
<li class="toctree-l1"><a class="reference internal" href="notebooks/run_ondemand.html">Run On Demand</a></li>
232233
<li class="toctree-l1"><a class="reference internal" href="beyond.html">Going Forward</a></li>
233234
</ul>
234235
<p class="caption" role="heading"><span class="caption-text">References:</span></p>

docs/aapi.integration_factory.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobtypes.html">Job types</a></li>
230230
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobproperties.html">Job and Folder Properties</a></li>
231231
<li class="toctree-l1"><a class="reference internal" href="notebooks/connectionprofiles.html">Connection Profiles</a></li>
232+
<li class="toctree-l1"><a class="reference internal" href="notebooks/run_ondemand.html">Run On Demand</a></li>
232233
<li class="toctree-l1"><a class="reference internal" href="beyond.html">Going Forward</a></li>
233234
</ul>
234235
<p class="caption" role="heading"><span class="caption-text">References:</span></p>

docs/beyond.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head><meta charset="utf-8"/>
44
<meta name="viewport" content="width=device-width,initial-scale=1"/>
55
<meta name="color-scheme" content="light dark"><meta name="viewport" content="width=device-width, initial-scale=1" />
6-
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="aapi package" href="aapi.html" /><link rel="prev" title="Connection Profiles" href="notebooks/connectionprofiles.html" />
6+
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="aapi package" href="aapi.html" /><link rel="prev" title="Run On Demand" href="notebooks/run_ondemand.html" />
77

88
<link rel="shortcut icon" href="_static/favicon.ico"/><!-- Generated with Sphinx 7.1.2 and Furo 2024.05.06 -->
99
<title>Going Forward - Control-M Python Client documentation</title>
@@ -229,6 +229,7 @@
229229
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobtypes.html">Job types</a></li>
230230
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobproperties.html">Job and Folder Properties</a></li>
231231
<li class="toctree-l1"><a class="reference internal" href="notebooks/connectionprofiles.html">Connection Profiles</a></li>
232+
<li class="toctree-l1"><a class="reference internal" href="notebooks/run_ondemand.html">Run On Demand</a></li>
232233
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Going Forward</a></li>
233234
</ul>
234235
<p class="caption" role="heading"><span class="caption-text">References:</span></p>
@@ -316,14 +317,14 @@ <h2>Extending Control-M Python Client<a class="headerlink" href="#extending-cont
316317
</div>
317318
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
318319
</a>
319-
<a class="prev-page" href="notebooks/connectionprofiles.html">
320+
<a class="prev-page" href="notebooks/run_ondemand.html">
320321
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
321322
<div class="page-info">
322323
<div class="context">
323324
<span>Previous</span>
324325
</div>
325326

326-
<div class="title">Connection Profiles</div>
327+
<div class="title">Run On Demand</div>
327328

328329
</div>
329330
</a>

docs/ctm_python_client.core.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobtypes.html">Job types</a></li>
230230
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobproperties.html">Job and Folder Properties</a></li>
231231
<li class="toctree-l1"><a class="reference internal" href="notebooks/connectionprofiles.html">Connection Profiles</a></li>
232+
<li class="toctree-l1"><a class="reference internal" href="notebooks/run_ondemand.html">Run On Demand</a></li>
232233
<li class="toctree-l1"><a class="reference internal" href="beyond.html">Going Forward</a></li>
233234
</ul>
234235
<p class="caption" role="heading"><span class="caption-text">References:</span></p>

docs/ctm_python_client.ext.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobtypes.html">Job types</a></li>
230230
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobproperties.html">Job and Folder Properties</a></li>
231231
<li class="toctree-l1"><a class="reference internal" href="notebooks/connectionprofiles.html">Connection Profiles</a></li>
232+
<li class="toctree-l1"><a class="reference internal" href="notebooks/run_ondemand.html">Run On Demand</a></li>
232233
<li class="toctree-l1"><a class="reference internal" href="beyond.html">Going Forward</a></li>
233234
</ul>
234235
<p class="caption" role="heading"><span class="caption-text">References:</span></p>

docs/ctm_python_client.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobtypes.html">Job types</a></li>
230230
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobproperties.html">Job and Folder Properties</a></li>
231231
<li class="toctree-l1"><a class="reference internal" href="notebooks/connectionprofiles.html">Connection Profiles</a></li>
232+
<li class="toctree-l1"><a class="reference internal" href="notebooks/run_ondemand.html">Run On Demand</a></li>
232233
<li class="toctree-l1"><a class="reference internal" href="beyond.html">Going Forward</a></li>
233234
</ul>
234235
<p class="caption" role="heading"><span class="caption-text">References:</span></p>

docs/genindex.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobtypes.html">Job types</a></li>
228228
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobproperties.html">Job and Folder Properties</a></li>
229229
<li class="toctree-l1"><a class="reference internal" href="notebooks/connectionprofiles.html">Connection Profiles</a></li>
230+
<li class="toctree-l1"><a class="reference internal" href="notebooks/run_ondemand.html">Run On Demand</a></li>
230231
<li class="toctree-l1"><a class="reference internal" href="beyond.html">Going Forward</a></li>
231232
</ul>
232233
<p class="caption" role="heading"><span class="caption-text">References:</span></p>

docs/gettingstarted.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@
229229
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobtypes.html">Job types</a></li>
230230
<li class="toctree-l1"><a class="reference internal" href="notebooks/jobproperties.html">Job and Folder Properties</a></li>
231231
<li class="toctree-l1"><a class="reference internal" href="notebooks/connectionprofiles.html">Connection Profiles</a></li>
232+
<li class="toctree-l1"><a class="reference internal" href="notebooks/run_ondemand.html">Run On Demand</a></li>
232233
<li class="toctree-l1"><a class="reference internal" href="beyond.html">Going Forward</a></li>
233234
</ul>
234235
<p class="caption" role="heading"><span class="caption-text">References:</span></p>

0 commit comments

Comments
 (0)