<s> from __future__ import absolute_import , unicode_literals <EOL> import click <EOL> from tower_cli import models , resources <EOL> from tower_cli . api import client <EOL> from tower_cli . utils import debug , exceptions as exc , types <EOL> from tower_cli . utils . data_structures import OrderedDict <EOL> class Resource ( models . ExeResource ) : <EOL> """<STR_LIT>""" <EOL> cli_help = '<STR_LIT>' <EOL> endpoint = '<STR_LIT>' <EOL> job_explanation = models . Field ( required = False , display = False ) <EOL> created = models . Field ( required = False , display = True ) <EOL> status = models . Field ( required = False , display = True ) <EOL> elapsed = models . Field ( required = False , display = True ) <EOL> job_type = models . Field ( <EOL> default = '<STR_LIT>' , <EOL> display = False , <EOL> show_default = True , <EOL> type = click . Choice ( [ '<STR_LIT>' , '<STR_LIT>' ] ) , <EOL> ) <EOL> inventory = models . Field ( type = types . Related ( '<STR_LIT>' ) ) <EOL> machine_credential = models . Field ( <EOL> '<STR_LIT>' , <EOL> display = False , <EOL> type = types . Related ( '<STR_LIT>' ) , <EOL> ) <EOL> cloud_credential = models . Field ( type = types . Related ( '<STR_LIT>' ) , <EOL> required = False , display = False ) <EOL> module_name = models . Field ( required = False , display = True , <EOL> default = "<STR_LIT>" , show_default = True ) <EOL> module_args = models . Field ( required = False , display = False ) <EOL> forks = models . Field ( type = int , required = False , display = False ) <EOL> limit = models . Field ( required = False , display = False ) <EOL> verbosity = models . Field ( <EOL> display = False , <EOL> type = types . MappedChoice ( [ <EOL> ( <NUM_LIT:0> , '<STR_LIT:default>' ) , <EOL> ( <NUM_LIT:1> , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:2> , '<STR_LIT>' ) , <EOL> ] ) , <EOL> required = False , <EOL> ) <EOL> @ resources . command ( <EOL> use_fields_as_options = ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> ) <EOL> ) <EOL> @ click . option ( '<STR_LIT>' , is_flag = True , default = False , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , required = False , type = int , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , required = False , is_flag = True , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> def launch ( self , monitor = False , timeout = None , become = False , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> r = client . get ( '<STR_LIT:/>' ) <EOL> if '<STR_LIT>' not in r . json ( ) : <EOL> raise exc . TowerCLIError ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . _pop_none ( kwargs ) <EOL> if become : <EOL> kwargs [ '<STR_LIT>' ] = True <EOL> debug . log ( '<STR_LIT>' , header = '<STR_LIT>' ) <EOL> result = client . post ( self . endpoint , data = kwargs ) <EOL> command = result . json ( ) <EOL> command_id = command [ '<STR_LIT:id>' ] <EOL> if monitor : <EOL> return self . monitor ( command_id , timeout = timeout ) <EOL> answer = OrderedDict ( ( <EOL> ( '<STR_LIT>' , True ) , <EOL> ( '<STR_LIT:id>' , command_id ) , <EOL> ) ) <EOL> answer . update ( result . json ( ) ) <EOL> return answer </s>
