From d4c8167b1b3f104ec0b9008278a5ba70edca61a4 Mon Sep 17 00:00:00 2001 From: Elijah DeLee Date: Tue, 24 Sep 2019 16:35:40 -0400 Subject: [PATCH] add arguments to awxkit for webhooks on jt or wfjt --- awxkit/awxkit/api/pages/job_templates.py | 11 ++++++++++ .../api/pages/workflow_job_templates.py | 21 ++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/awxkit/awxkit/api/pages/job_templates.py b/awxkit/awxkit/api/pages/job_templates.py index 894b938e2e..e7d74f7cec 100644 --- a/awxkit/awxkit/api/pages/job_templates.py +++ b/awxkit/awxkit/api/pages/job_templates.py @@ -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): diff --git a/awxkit/awxkit/api/pages/workflow_job_templates.py b/awxkit/awxkit/api/pages/workflow_job_templates.py index 52c89d8eea..1d67a0a171 100644 --- a/awxkit/awxkit/api/pages/workflow_job_templates.py +++ b/awxkit/awxkit/api/pages/workflow_job_templates.py @@ -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):