From ad89c5eea732d6bf18a52062b035fafaa077b620 Mon Sep 17 00:00:00 2001 From: beeankha Date: Thu, 10 Oct 2019 16:38:15 -0400 Subject: [PATCH 1/4] Enable approval notification support for CLI --- awxkit/awxkit/cli/custom.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/awxkit/awxkit/cli/custom.py b/awxkit/awxkit/cli/custom.py index ad2af3b433..903f2e4fc7 100644 --- a/awxkit/awxkit/cli/custom.py +++ b/awxkit/awxkit/cli/custom.py @@ -225,6 +225,7 @@ class AssociationMixin(object): def __init__(self, connection, resource): self.conn = connection self.resource = { + 'approval_notification': 'notification_templates', 'start_notification': 'notification_templates', 'success_notification': 'notification_templates', 'failure_notification': 'notification_templates', @@ -299,11 +300,27 @@ JobTemplateNotificationDisAssociation.targets.update({ class WorkflowJobTemplateNotificationAssociation(NotificationAssociateMixin, CustomAction): resource = 'workflow_job_templates' action = 'associate' + targets = dict( + **NotificationAssociateMixin.targets, + **{'approval_notification': [ + 'notification_templates_approvals', + 'notification_template' + ] + }, + ) class WorkflowJobTemplateNotificationDisAssociation(NotificationAssociateMixin, CustomAction): resource = 'workflow_job_templates' action = 'disassociate' + targets = dict( + **NotificationAssociateMixin.targets, + **{'approval_notification': [ + 'notification_templates_approvals', + 'notification_template' + ] + }, + ) class ProjectNotificationAssociation(NotificationAssociateMixin, CustomAction): @@ -329,11 +346,27 @@ class InventorySourceNotificationDisAssociation(NotificationAssociateMixin, Cust class OrganizationNotificationAssociation(NotificationAssociateMixin, CustomAction): resource = 'organizations' action = 'associate' + targets = dict( + **NotificationAssociateMixin.targets, + **{'approval_notification': [ + 'notification_templates_approvals', + 'notification_template' + ] + }, + ) class OrganizationNotificationDisAssociation(NotificationAssociateMixin, CustomAction): resource = 'organizations' action = 'disassociate' + targets = dict( + **NotificationAssociateMixin.targets, + **{'approval_notification': [ + 'notification_templates_approvals', + 'notification_template' + ] + }, + ) class SettingsList(CustomAction): From fdddba18be16a6bacc4ce4a28d1c8d324949ae49 Mon Sep 17 00:00:00 2001 From: beeankha Date: Fri, 11 Oct 2019 10:05:03 -0400 Subject: [PATCH 2/4] Update code to be compatible with py2 --- awxkit/awxkit/cli/custom.py | 51 ++++++++++++++----------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/awxkit/awxkit/cli/custom.py b/awxkit/awxkit/cli/custom.py index 903f2e4fc7..f9077acab5 100644 --- a/awxkit/awxkit/cli/custom.py +++ b/awxkit/awxkit/cli/custom.py @@ -300,27 +300,21 @@ JobTemplateNotificationDisAssociation.targets.update({ class WorkflowJobTemplateNotificationAssociation(NotificationAssociateMixin, CustomAction): resource = 'workflow_job_templates' action = 'associate' - targets = dict( - **NotificationAssociateMixin.targets, - **{'approval_notification': [ - 'notification_templates_approvals', - 'notification_template' - ] - }, - ) + targets = NotificationAssociateMixin.targets.copy() class WorkflowJobTemplateNotificationDisAssociation(NotificationAssociateMixin, CustomAction): resource = 'workflow_job_templates' action = 'disassociate' - targets = dict( - **NotificationAssociateMixin.targets, - **{'approval_notification': [ - 'notification_templates_approvals', - 'notification_template' - ] - }, - ) + targets = NotificationAssociateMixin.targets.copy() + + +WorkflowJobTemplateNotificationAssociation.targets.update({ + 'approval_notification': ['notification_templates_approvals', 'notification_template'], +}) +WorkflowJobTemplateNotificationDisAssociation.targets.update({ + 'approval_notification': ['notification_templates_approvals', 'notification_template'], +}) class ProjectNotificationAssociation(NotificationAssociateMixin, CustomAction): @@ -346,29 +340,22 @@ class InventorySourceNotificationDisAssociation(NotificationAssociateMixin, Cust class OrganizationNotificationAssociation(NotificationAssociateMixin, CustomAction): resource = 'organizations' action = 'associate' - targets = dict( - **NotificationAssociateMixin.targets, - **{'approval_notification': [ - 'notification_templates_approvals', - 'notification_template' - ] - }, - ) + targets = NotificationAssociateMixin.targets.copy() class OrganizationNotificationDisAssociation(NotificationAssociateMixin, CustomAction): resource = 'organizations' action = 'disassociate' - targets = dict( - **NotificationAssociateMixin.targets, - **{'approval_notification': [ - 'notification_templates_approvals', - 'notification_template' - ] - }, - ) + targets = NotificationAssociateMixin.targets.copy() +OrganizationNotificationAssociation.targets.update({ + 'approval_notification': ['notification_templates_approvals', 'notification_template'], +}) +OrganizationNotificationDisAssociation.targets.update({ + 'approval_notification': ['notification_templates_approvals', 'notification_template'], +}) + class SettingsList(CustomAction): action = 'list' resource = 'settings' From aa4f5ccca91f10ff1f9dfd460fa67d645c134c51 Mon Sep 17 00:00:00 2001 From: beeankha Date: Fri, 11 Oct 2019 11:38:47 -0400 Subject: [PATCH 3/4] Add blank line (flake8) --- awxkit/awxkit/cli/custom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/awxkit/awxkit/cli/custom.py b/awxkit/awxkit/cli/custom.py index f9077acab5..45146b493e 100644 --- a/awxkit/awxkit/cli/custom.py +++ b/awxkit/awxkit/cli/custom.py @@ -356,6 +356,7 @@ OrganizationNotificationDisAssociation.targets.update({ 'approval_notification': ['notification_templates_approvals', 'notification_template'], }) + class SettingsList(CustomAction): action = 'list' resource = 'settings' From 62e4ebb85d579f6a9330901760f3f90a92ccf3fd Mon Sep 17 00:00:00 2001 From: beeankha Date: Wed, 16 Oct 2019 09:29:50 -0400 Subject: [PATCH 4/4] Minor change to README, plus a rebase. --- awxkit/awxkit/cli/docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awxkit/awxkit/cli/docs/README.md b/awxkit/awxkit/cli/docs/README.md index 11676ee5dd..d8f1dfc85a 100644 --- a/awxkit/awxkit/cli/docs/README.md +++ b/awxkit/awxkit/cli/docs/README.md @@ -1,7 +1,7 @@ AWX Command Line Interface ========================== -awx is the official command-line client for AWX. It: +`awx` is the official command-line client for AWX. It: * Uses naming and structure consistent with the AWX HTTP API * Provides consistent output formats with optional machine-parsable formats