{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Job types" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from aapi import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobCommand\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_commandScript.htm#JobCommand)\n", "\n", "Job that executes an Operating System command\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **command**: The command to execute\n", "\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "job = JobCommand('JobCommandSample', command='echo Hello')" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "job = JobCommand('JobCommandSample',\n", " command='mycommand',\n", " run_as='user',\n", " host='myhost.com',\n", " pre_command='echo Precommand',\n", " post_command='echo Finished')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobScript\n", "\n", "[AutomationAPI Documentation](https://docs.bmc.com/docs/automation-api/monthly/job-types-993192279.html#Jobtypes-JobScriptJob:Script)\n", "\n", "Job that executes a script\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **file_name** : The name of the script\n", "- **file_path** : The path of the script\n", "\n", "Optional arguments:\n", "\n", "- **arguments**: An array of strings that are passed as argument to the script\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "job = JobScript('JobScriptSample', file_name='task.sh', file_path='/home/scripts')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "job = JobScript('JobScriptSame',\n", " file_name='task.sh',\n", " file_path='%%path',\n", " run_as='user',\n", " arguments=['arg1', 'arg2'],\n", " variables=[{'path': '/home/scripts'}])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobEmbeddedScript\n", "\n", "[AutomationAPI Documentation](https://docs.bmc.com/docs/automation-api/monthly/job-types-993192279.html#Jobtypes-JobEmbScriptJob:EmbeddedScript)\n", "\n", "Job that executes a script written in the job itself. Note that control characters need to be escaped\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **script** : The written script. (note: all control characters need to be escaped!)\n", "- **file_name** : The name of the script file. \n", "\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "job = JobEmbeddedScript('JobEmbeddedScriptSample',\n", " file_name='filename.sh',\n", " script=r'#!/bin/bash\\necho \"Hello\"\\necho \"Bye\"'),\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobFileTransfer\n", "\n", "[AutomationAPI Documentation](https://docs.bmc.com/docs/automation-api/monthly/job-types-993192279.html#Jobtypes-JobFileTransferJob:FileTransfer)\n", "\n", "Job that executes a list of file transfers\n", "\n", "Required arguments:\n", "\n", "- **object_name**: The name of the job\n", "- **file_transfers**: A list of `FileTransfer` object defining the transfers to be executed by the job\n", "\n", "In addition, a Connection Profile will be required to run the job. For a JobFileTransfer, you can either define a Dual Endpoint connection profile **connection_profile_dual_endpoint** or two connection profiles for source and destination (**connection_profile_src** and **connection_profile_dest**)\n", "\n", "Optional arguments:\n", "\n", "- **number_of_retries**: Number of connection attempts after a connection failure. Range of values: 0–99 as string (\"0\" to \"99\") or \"Default\" (to inherit the default). Default: 5 attempts. Note: the value should be passed as string. To define 10, it should be passed \"10\"\n", "- **s3_bucket_name**: For file transfers between a local filesystem and an Amazon S3 or S3-compatible storage service: The name of the S3 bucket\n", "- **s3_bucket_name_src**: For file transfers between two Amazon S3 or S3-compatible storage services: The name of the S3 bucket at the source\n", "- **s3_bucket_name_dest**: For file transfers between two Amazon S3 or S3-compatible storage services: The name of the S3 bucket at the destination\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "job = JobFileTransfer('JobFileTransferSample',\n", " connection_profile_src='CP1', connection_profile_dest='CP2',\n", " number_of_retries='7',\n", " file_transfers=[\n", " FileTransfer(src='/home/ctm/file1', dest='/home/cmt/file2',\n", " transfer_type=FileTransfer.TransferType.Binary,\n", " transfer_option=FileTransfer.TransferOption.SrcToDest),\n", "\n", " FileTransfer(src='/home/ctm/file1', dest='/home/cmt/file2',\n", " transfer_type=FileTransfer.TransferType.Binary,\n", " transfer_option=FileTransfer.TransferOption.SrcToDest),\n", " ])" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "# An example of a file transer from a S3 storage to a local filesystem:\n", "job = JobFileTransfer('TransferS3ToLocal',\n", " connection_profile_src='amazonCP', connection_profile_dest='localcp',\n", " s3_bucket_name='bucket')\n", "\n", "# Note that file_transfers is by default initialized as an empty list\n", "job.file_transfers.append(FileTransfer(src='folder/file1', dest='/home/file1'))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobFileWatcherCreate\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_FileWatcher.htm)\n", "\n", "Job that detects the successful completion of a file transfer activity that creates a file" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "job = JobFileWatcherCreate('JobFileWatcherCreateSample',\n", " path='C:\\\\path*.txt',\n", " search_interval='45',\n", " time_limit='22',\n", " start_time='201705041535',\n", " stop_time='201805041535',\n", " minimum_size='10B',\n", " wildcard=False,\n", " minimal_age='1Y',\n", " maximal_age='1D2H4MIN'\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobFileWatcherDelete\n", "[AutomationAPI Documentation](ttps://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_FileWatcher.htm)\n", "\n", "Job that detects the successful completion of a file transfer activity that deletes a file" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "job = JobFileWatcherDelete('JobFileWatcherDeleteSample',\n", " path='C:\\\\path*.txt',\n", " search_interval='45',\n", " time_limit='22',\n", " start_time='201705041535',\n", " stop_time='201805041535',\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobDatabaseEmbeddedQuery\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_Databases.htm#JobDatabaseEmbeddedQuery)\n", "\n", "Job that runs an embedded query\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **query** : The embedded SQL query that you want to run.\n", "The SQL query can contain auto edit variables. During job run, these variables are replaced by the values that you specify in Variables parameter (next row).\n", "For long queries, you can specify delimiters using \\\\n (new line) and \\\\t (tab).\n", "\n", "Optional arguments:\n", "\n", "- **autocommit**: Commits statements to the database that completes successfully\n", "- **output_execution_log**: Shows the execution log in the job output\n", "- **output_sql_output**: Shows the SQL sysout in the job output\n", "- **sql_output_format**: Defines the output format as either Text, XML, CSV, or HTML\n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "job = JobDatabaseEmbeddedQuery(\n", " 'JobEmbeddedQuerySample',\n", " query='SELECT %%firstParamName AS VAR1 \\\\n FROM DUMMY \\\\n ORDER BY \\\\t VAR1 DESC',\n", " connection_profile='CPDB',\n", " variables=[{'firstParamName': 'value'}],\n", " autocommit='N',\n", " output_execution_log='y',\n", " output_sql_output='y',\n", " sql_output_format='XML'\n", ")\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobDatabaseSQLScript\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_Databases.htm#JobDatabaseSQLScript)\n", "\n", "Job that runs a SQL script from a file system\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **sql_script** : The path of the script\n", "\n", "Optional arguments:\n", "\n", "- **parameters**: An array of dictionary with name and value. Every name that appears in the SQL script will be replaced by its value pair.\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "job = JobDatabaseSQLScript('JobDatabaseSQLScriptSample',\n", " connection_profile='CPDB',\n", " sql_script='/home/script.sql',\n", " parameters=[{'param1': 'val1'}, {'param2': 'val2'}])\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobDatabaseStoredProcedure\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_Databases.htm#JobDatabaseStoredProcedure)\n", "\n", "Job that runs a program that is stored on the database\n", "\n", "Required Arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **stored_procedure** : The name of the job\n", "- **schema** : The database schema where the stored procedure resides\n", "\n", "Optional arguments:\n", "\n", "- **parameters**: A comma-separated list of values and variables for all parameters in the procedure, in the order of their appearence in the procedure\n", "- **return_value**: A variable for the Return parameter (if the procedure contains such a parameter)\n", "- **package**: (Oracle only) Name of a package in the database where the stored procedure resides. The default is \"*\", that is, any package in the database." ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "job = JobDatabaseStoredProcedure('JobDatabaseStoredProcedureSample',\n", " connection_profile='CPDB',\n", " stored_procedure='procedure',\n", " schema='public',\n", " return_value='RV')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobDatabaseMSSQLAgentJob\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_Databases.htm#JobDatabaseMSSQLAgentJob)\n", "\n", "Job that manages a SQL server defined job\n", "\n", "*Note* : Only available with Automation API >= 9.0.19.210\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **job_name** : The name of the job defined in the SQL server\n", "\n", "Optional arguments:\n", "\n", "- **category**: The category of the job, as defined in the SQL server" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "job = JobDatabaseMSSQLAgentJob('JobDatabaseMSSQLAgentJobSample',\n", " job_name='get_version',\n", " connection_profile='CPDB',\n", " category='Data Collector')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobDatabaseMSSQL_SSIS\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_Databases.htm#JobDatabaseMSSQLSSIS)\n", "\n", "Job that executes of SQL Server Integration Services (SSIS) packages:\n", "\n", "*Note* : Only available with Automation API >= 9.0.19.220\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **package_source** : The source of the SSIS package\n", "- **package_name** : The name of the SSIS package\n", "\n", "Optional arguments:\n", "\n", "- **catalog_env**: The category of the job, as defined in the SQL server\n", "- **config_files**: Names of configuration files that contain specific data that you want to apply to the SSIS package\n", "- **properties**: Pairs of names and values for properties defined in the SSIS package. Each property name is replaced by its defined value during SSIS package execution." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "job = JobDatabaseMSSQL_SSIS('JobDatabaseMSSQL_SSISSample',\n", " connection_profile='CPDB',\n", " package_source=JobDatabaseMSSQL_SSIS.PackageSource.SSIS_Catalog,\n", " package_name='\\\\Data Collector\\\\SqlTraceCollect',\n", " catalog_env='ENV_NAME',\n", " config_files=[\n", " 'C:\\\\Users\\\\dbauser\\\\Desktop\\\\test.dtsConfig',\n", " 'C:\\\\Users\\\\dbauser\\\\Desktop\\\\test2.dtsConfig'\n", " ],\n", " properties=[{\n", " 'PropertyName': 'PropertyValue'\n", " },\n", " {\n", " 'PropertyName2': 'PropertyValue2'\n", " }]\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopSparkPython\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado)\n", "\n", "Job that runs a Spark Python program\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **spark_script** : The name of the Spark script\n", "- **package_name** : The name of the SSIS package\n", "\n", "Optional arguments:\n", "\n", "- **spark_options**: The options to be passed to the script" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopSparkPython('JobHadoopSparkPythonSample',\n", " connection_profile='CP',\n", " spark_script='/home/process.py') \n" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopSparkPython('JobHadoopSparkPythonSample',\n", " connection_profile='CP',\n", " spark_script='/home/process.py',\n", " arguments=[\n", " '1000',\n", " '120'\n", " ],\n", " spark_options=[{'--master': 'yarn'},\n", " {'--num': '-executors 50'}]\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopSparkScalaJava\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado2)\n", "\n" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopSparkScalaJava('JobHadoopSparkScalaJavaSample',\n", " connection_profile='CP',\n", " program_jar='/home/user/ScalaProgram.jar',\n", " main_class='com.mycomp.sparkScalaProgramName.mainClassName'\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopPig\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado3)\n", "\n" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopPig('JobHadoopPigSample',\n", " connection_profile='CP',\n", " pig_script='/home/user/script.pg'\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopSqoop\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado4)\n", "\n" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopSqoop('JobHadoopSqoopSample',\n", " connection_profile='CP',\n", " sqoop_command='import --table foo --target-dir /dest_dir',\n", " sqoop_options=[\n", " {\"--warehouse-dir\": \"/shared\"},\n", " {\"--default-character-set\": \"latin1\"}\n", " ]\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopHive\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado5)\n", "\n" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopHive('JobHadoopHiveSample',\n", " connection_profile='CP',\n", " hive_script='/home/user1/hive.script',\n", " parameters=[{'amount': '1000'}, {'topic': 'food'}],\n", " hive_options={'hive.root.logger': 'INFO, console'})\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopDistCp\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado6)\n", "\n" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopDistCp('JobHadoopDistCpSample',\n", " connection_profile='CP',\n", " target_path='hdfs://nns2:8020/foo/bar',\n", " source_paths=['hdfs://nns1:8020/foo/a'],\n", " distcp_options=[{'-m': '3'}, {'-filelimit': '100'}]\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopHDFSCommands\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado7)\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopHDFSCommands('JobHadoopHDFSCommandsSample',\n", " connection_profile='CP',\n", " commands=[{\"get\": \"hdfs://nn.example.com/user/hadoop/file localfile\"},\n", " {\"rm\": \"hdfs://nn.example.com/file /user/hadoop/emptydir\"}]\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopHDFSFileWatcher\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado13)\n", "\n" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopHDFSFileWatcher('JobHadoopHDFSFileWatcherSample',\n", " connection_profile='CP',\n", " hdfs_file_path='/input/filename',\n", " min_detected_size='1',\n", " max_wait_time='2'\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopOozie\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado8)\n", "\n" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopOozie('JobHadoopOozieSample',\n", " connection_profile='CP',\n", " job_properties_file='/home/user/job.properties',\n", " oozie_options=[{\"inputDir\": \"/usr/tucu/inputdir\"},\n", " {\"outputDir\": \"/usr/tucu/outputdir\"}]\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopMapReduce\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado9)\n", "\n" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopMapReduce('JobHadoopMapReduceSample',\n", " connection_profile='CP',\n", " program_jar='/home/user1/hadoop-jobs/hadoop-mapreduce-examples.jar',\n", " main_class='com.mycomp.mainClassName',\n", " arguments=[\n", " 'arg1',\n", " 'arg2'\n", " ])\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopMapredStreaming\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado10)\n", "\n" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopMapredStreaming('JobHadoopMapredStreamingSample',\n", " connection_profile='CP',\n", " input_path='/user/input/',\n", " output_path='/tmp/output',\n", " mapper_command='mapper.py',\n", " reducer_command='reducer.py',\n", " general_options=[\n", " {\"-D\": \"fs.permissions.umask-mode=000\"},\n", " {\"-files\": \"/home/user/hadoop-streaming/mapper.py,/home/user/hadoop-streaming/reducer.py\"}\n", " ]\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopTajoInputFile\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado11)\n", "\n" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopTajoInputFile('JobHadoopTajoInputFileSample',\n", " connection_profile='CP',\n", " full_file_path='/home/user/tajo_command.sh',\n", " tajo_options=[\n", " {\"amount\": \"1000\"},\n", " {\"volume\": \"120\"}\n", " ]\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobHadoopTajoQuery\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataProcessing.htm#Job:Hado12)\n", "\n" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [], "source": [ "job = JobHadoopTajoQuery('JobHadoopTajoQuerySample',\n", " connection_profile='CP',\n", " open_query='SELECT %%firstParamName AS VAR1 \\\\n FROM DUMMY \\\\n ORDER BY \\\\t VAR1 DESC')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobPeopleSoft\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_ERP.htm#JobPeopleSoft)\n", "\n", "Job that manages PeopleSoft jobs and processes\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "\n", "Optional arguments:\n", "\n", "- **user** : A PeopleSoft user ID that exists in the PeopleSoft Environment\n", "- **control_id** : Run Control ID for access to run controls at runtime\n", "- **process_type**: A PeopleSoft process type that the user is authorized to perform\n", "- **process_name**: The name of the PeopleSoft process to run\n", "- **append_to_output**: Whether to include PeopleSoft job output in the Control-M job output, either true or false\n", "- **bind_variables**: Values of up to 20 USERDEF variables for sharing data between Control-M and the PeopleSoft job or process" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "job = JobPeopleSoft('JobPeopleSoftSample',\n", " connection_profile='CP_PS',\n", " user='PS_User',\n", " control_id='controlid',\n", " server_name='server',\n", " process_type='ptype',\n", " process_name='pname',\n", " append_to_output=False,\n", " bind_variables=['val1', 'val2'])\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobInformatica\n", "\n", "[AutomationAPI Documentation]((https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_DataIntegration.htm#Job:Informatica)\n", "\n", "Job that manages Informatica workflows\n", "\n", "Required arguments:\n", "\n", "- **repository_folder** : The Repository folder that contains the workflow that you want to run\n", "- **workflow** : The workflow that you want to run in Control-M for Informatica\n", "\n", "Optional arguments:\n", "\n", "- **instance_name**: The specific instance of the workflow that you want to run\n", "- **os_profile**: The operating system profile in Informatica\n", "- **workflow_execution_mode**: The mode for executing the workflow\n", "- **workflow_restart_mode**: The operation to execute when the workflow is in a suspended satus\n", "- **restart_from_task**: The task from which to start running the workflow. This parameter is required only if you set WorkflowExecutionMode to StartFromTask.\n", "- **run_single_task**: The workflow task that you want to run. This parameter is required only if you set WorkflowExecutionMode to RunSingleTask.\n", "- **workflow_parameters_file**: The path and name of the workflow parameters file. This enables you to use the same workflow for different actions." ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "job = JobInformatica('JobInformaticaSample',\n", " connection_profile='CP_INF',\n", " repository_folder='POC',\n", " workflow='WF_TEST',\n", " instance_name='MyInstance',\n", " os_profile='OSPROFILE',\n", " workflow_execution_mode=JobInformatica.WorkflowExecutionMode.RunSingleTask,\n", " workflow_restart_mode=JobInformatica.WorkflowRestartMode.ForceRestartFromSpecificTask,\n", " restart_from_task='s_MapTest_Success',\n", " workflow_parameters_file='/opt/wf1.prop')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobAWSLambda\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_CloudCompute.htm#Job:AWS2)\n", "\n", "Job that executes an AWS Lambda service on an AWS server\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **function_name** : The Lambda function to execute\n", "\n", "Optional arguments:\n", "\n", "- **instance_name**: The specific instance of the workflow that you want to run\n", "- **version**: The Lambda function version. The default is $LATEST (the latest version).\n", "- **payload**: \tThe Lambda function payload, in JSON string format\n", "- **append_log**: \tWhether to add the log to the job’s output, either true (the default) or false" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [], "source": [ "job = JobAWSLambda('JobAWSLambdaSample',\n", " connection_profile='CPAWS',\n", " function_name='fname',\n", " version='1',\n", " payload='{\"myVar\":\"value1\", \"othervar\":\"value2\"}',\n", " append_log=True\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobAWSStepFunction\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_AppWorkflows.htm#Job:AWS)\n", "\n", "Job that executes an AWS Step Function service on an AWS server\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **state_machine** : The State Machine to use\n", "- **execution_name**: A name for the execution\n", "\n", "Optional arguments:\n", "\n", "- **input**: The Step Function input in JSON string format\n", "- **append_log**: \tWhether to add the log to the job’s output, either true (the default) or false" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [], "source": [ "job = JobAWSStepFunction('JobAWSStepFunctionSample',\n", " connection_profile='CPAWS',\n", " state_machine='smach1',\n", " execution_name='exec1',\n", " input='{\"var\":\"value\", \"othervar\":\"val2\"}',\n", " append_log=False)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobAWSBatch\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_CloudCompute.htm#Job:AWS)\n", "\n", "Job that executes an AWS Batch service on an AWS server\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **job_name** : The name of the batch job\n", "- **job_definition**: The job definition to use\n", "- **job_definition_revision**: The job definition revision\n", "- **job_queue**: The queue to which the job is submitted\n", "\n", "Optional arguments:\n", "\n", "- **aws_job_type**: The type of job, either Array or Single\n", "- **array_size**: (For a job of type Array) The size of the array (that is, the number of items in the array)\n", "- **depends_on**: Parameters that determine a job dependency\n", "- **command**: A command to send to the container that overrides the default command from the Docker image or the job definition\n", "- **memory**: The number of megabytes of memory reserved for the job\n", "- **v_cpus**: The number of vCPUs to reserve for the container\n", "- **job_attempts**: The number of retry attempts passed as string\n", "- **execution_timeout**: The timeout duration in seconds\n", "- **append_log**: \tWhether to add the log to the job’s output, either true (the default) or false\n" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "job = JobAWSBatch('JobAWSBatchSample',\n", " connection_profile='CPAWS',\n", " job_name='batchjob',\n", " job_definition='jobdef',\n", " job_definition_revision='3',\n", " job_queue='queue1',\n", " aws_job_type=JobAWSBatch.AwsJobType.Array,\n", " array_size='100',\n", " depends_on=JobAWSBatch.DependsOn(\n", " dependency_type=JobAWSBatch.DependsOn.DependencyType.Standard,\n", " job_depends_on='job5'),\n", " command='ls',\n", " memory='10',\n", " v_cpus='2',\n", " job_attempts='5',\n", " execution_timeout='60',\n", " append_log=False)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobAzureFunction\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_CloudCompute.htm#Job:Azur4)\n", "\n", "Job that executes an Azure function service. \n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **function** : The name of the Azure function to execute\n", "- **function_app**: The name of the Azure function app\n", "\n", "Optional arguments:\n", "\n", "- **parameters**: Function parameters defined as pairs of name and value\n", "- **append_log**: \tWhether to add the log to the job’s output, either true (the default) or false\n" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "job = JobAzureFunction('JobAzureFunctionSample',\n", " connection_profile='CPAZURE',\n", " function='AzureFunction',\n", " function_app='funcapp',\n", " append_log=False,\n", " parameters=[\n", " {\"firstParamName\": \"firstParamValue\"},\n", " {\"secondParamName\": \"secondParamValue\"}\n", " ])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobAzureLogicApps\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_AppWorkflows.htm#Job:Azur)\n", "\n", "Job that executes an Azure Logic App service\n", "\n", "Required arguments:\n", "\n", "- **object_name** : The name of the job\n", "- **logic_app_name** : The name of the Azure Logic App\n", "\n", "Optional arguments:\n", "\n", "- **request_body**: The JSON for the expected payload\n", "- **append_log**: \tWhether to add the log to the job’s output, either true (the default) or false" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "job = JobAzureLogicApps('JobAzureLogicAppsSample',\n", " connection_profile='CPAZURE',\n", " workflow='workflow_app',\n", " parameters='{\"name\":\"value\"}'\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobAzureBatchAccount\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_CloudCompute.htm#Job:Azur)\n", "\n", "Job that executes an Azure Batch Accounts service\n", "\n", "Required arguments:\n", " \n", "- **object_name** : The name of the job\n", "- **job_id** : The ID of the batch job\n", "- **command_line** : A command line that the batch job runs\n", "\n", "Optional arguments:\n", "\n", "- **wallclock**: Maximum limit for the job's run time\n", "- **max_tries**: If you do not include this parameter, the default is none (no retries).\n", "- **retention**: If you do not include this parameter, the default is none (no retries).\n", "- **append_log**: \t File retention period for the batch job. If you do not include this parameter, the default is an unlimited retention period." ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [], "source": [ "job = JobAzureBatchAccount('JobAzureBatchAccountSample',\n", " connection_profile='CPAZURE',\n", " job_id='azurejob',\n", " command_line='echo \"Hello\"',\n", " append_log=True,\n", " wallclock=JobAzureBatchAccount.Wallclock(\n", " time='70', unit=JobAzureBatchAccount.Wallclock.Unit.Minutes),\n", " max_tries=JobAzureBatchAccount.MaxTries(\n", " count='6', option=JobAzureBatchAccount.MaxTries.Option.Custom),\n", " retention=JobAzureBatchAccount.Retention(\n", " time='1', unit=JobAzureBatchAccount.Retention.Unit.Hours)\n", " )\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobWebServices\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_WebSrvc.htm#JobWebServices)\n", "\n", "*Note : Only available with Automation API >= 9.0.20.220*\n", "\n", "Job that executes standard web services, servlets, or RESTful web services. To manage Web Services jobs, you must have the Control-M for Web Services, Java, and Messaging (Control-M for WJM) plug-in installed in your Control-M environment" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [], "source": [ "job = JobWebServices('JobWebServicesSample',\n", " connection_profile='CP_WS',\n", " location='http://www.dneonline.com/calculator.asmx?WSDL',\n", " soap_header_file='c:\\\\myheader.txt',\n", " service='Calculator(Port:CalculatorSoap)',\n", " operation='Add',\n", " request_type=JobWebServices.RequestType.Parameter,\n", " override_url_endpoint='http://myoverridehost.com',\n", " override_content_type='*/*',\n", " http_connection_timeout='2345',\n", " preemptive_http_authentication='abc@bmc.com',\n", " include_title_in_output=True,\n", " exclude_job_output=False,\n", " output_parameters=[{\n", " \"Element\": \"AddResponse.AddResult\",\n", " \"HttpCode\": \"*\",\n", " \"Destination\": \"testResultAdd\",\n", " \"Type\": \"string\"\n", " }],\n", " input_parameters=[\n", " {\n", " \"Name\": \"intA\",\n", " \"Value\": \"97\",\n", " \"Type\": \"string\"\n", " },\n", " {\n", " \"Name\": \"intB\",\n", " \"Value\": \"345\",\n", " \"Type\": \"string\"\n", " },\n", " {\n", " \"Name\": \"accept-encoding\",\n", " \"Value\": \"*/*\",\n", " \"Type\": \"header\"\n", " }\n", " ],\n", " soap_request=[\n", " '''\n", " \n", " \n", " \n", " 98978\n", " 75675\n", " \n", " \n", " '''\n", " ],\n", " input_file='/home/usr/soap.xml')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobSLAManagement\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_sla.htm)" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [], "source": [ "job = JobSLAManagement('JobSLAManagementSample',\n", " service_name='SLA-service',\n", " service_priority='1',\n", " job_runs_deviations_tolerance='1',\n", " complete_in=JobSLAManagement.CompleteIn(time='00:01'),\n", " complete_by=JobSLAManagement.CompleteBy(\n", " time='21:40', days='3'),\n", " average_run_time_tolerance=JobSLAManagement.AverageRunTimeTolerance(\n", " average_run_time='10',\n", " units=JobSLAManagement.AverageRunTimeTolerance.Units.Minutes\n", " ))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JobZOS\n", "\n", "[AutomationAPI Documentation](https://documents.bmc.com/supportu/API/Monthly/en-US/Documentation/API_CodeRef_JobTypes_zOS.htm?Highlight=zos)" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [], "source": [ "job = JobZOSMember('JobZOSMemberSample', \n", " member_library='IOAQ.AAPI#AU.JCL',\n", " archiving=JobZOS.Archiving(archive_sys_data=True),\n", " must_end=JobZOS.MustEnd(hours='1', minutes='15', days=1),\n", " run_on_all_agents_in_group=True\n", " )\n" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [], "source": [ "job = JobZOSInStreamJCL('JobZOInStreamJCLSample', \n", " member_library='IOAQ.AAPI#AU.JCL',\n", " jcl=\"//AUTEST0 JOB ,ASM,CLASS=A,REGION=0M\\\\n// JCLLIB ORDER=IOAQ.AAPI#AU.PROCLIB\\\\n// INCLUDE MEMBER=IOASET\\\\n//S1 EXEC IOATEST,PARM='TERM=C0000'\",\n", " archiving=JobZOS.Archiving(archive_sys_data=True),\n", " run_on_all_agents_in_group=True,\n", " created_by='workbench',\n", " run_as='workbench'\n", " )" ] } ], "metadata": { "interpreter": { "hash": "e36608863334e111ac1975278d851976534d4d97e80edd449207481e04c86242" }, "kernelspec": { "display_name": "Python 3.10.4 ('venv': venv)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.9" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }