1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-27 17:55:10 +03:00

add arguments to awxkit for webhooks on jt or wfjt

This commit is contained in:
Elijah DeLee 2019-09-24 16:35:40 -04:00 committed by Jeff Bradberry
parent a4873d97d8
commit d4c8167b1b
2 changed files with 29 additions and 3 deletions

View File

@ -86,6 +86,8 @@ class JobTemplate(
'vault_credential',
'verbosity',
'job_slice_count',
'webhook_service',
'webhook_credential',
'scm_branch')
update_payload(payload, optional_fields, kwargs)
@ -102,6 +104,15 @@ class JobTemplate(
payload.update(inventory=kwargs.get('inventory').id)
if kwargs.get('credential'):
payload.update(credential=kwargs.get('credential').id)
if kwargs.get('webhook_credential'):
webhook_cred = kwargs.get('webhook_credential')
if isinstance(webhook_cred, int):
payload.update(webhook_credential=int(webhook_cred))
elif hasattr(webhook_cred, 'id'):
payload.update(webhook_credential=webhook_cred.id)
else:
raise AttributeError("Webhook credential must either be integer of pkid or Credential object")
return payload
def add_label(self, label):

View File

@ -36,9 +36,15 @@ class WorkflowJobTemplate(HasCopy, HasCreate, HasNotifications, HasSurvey, Unifi
optional_fields = (
"allow_simultaneous",
"ask_variables_on_launch", "ask_inventory_on_launch", "ask_scm_branch_on_launch", "ask_limit_on_launch",
"limit", "scm_branch",
"survey_enabled"
"ask_variables_on_launch",
"ask_inventory_on_launch",
"ask_scm_branch_on_launch",
"ask_limit_on_launch",
"limit",
"scm_branch",
"survey_enabled",
"webhook_service",
"webhook_credential",
)
update_payload(payload, optional_fields, kwargs)
@ -54,6 +60,15 @@ class WorkflowJobTemplate(HasCopy, HasCreate, HasNotifications, HasSurvey, Unifi
if kwargs.get('inventory'):
payload.inventory = kwargs.get('inventory').id
if kwargs.get('webhook_credential'):
webhook_cred = kwargs.get('webhook_credential')
if isinstance(webhook_cred, int):
payload.update(webhook_credential=int(webhook_cred))
elif hasattr(webhook_cred, 'id'):
payload.update(webhook_credential=webhook_cred.id)
else:
raise AttributeError("Webhook credential must either be integer of pkid or Credential object")
return payload
def create_payload(self, name='', description='', organization=None, **kwargs):