From 02e7424f515f6c22c65ff9c4006d060dceae8f35 Mon Sep 17 00:00:00 2001 From: Alex Corey Date: Wed, 8 Jun 2022 17:03:41 -0400 Subject: [PATCH] Adds import export to awx cli for schedules as a top level object --- awxkit/awxkit/api/pages/api.py | 15 ++------------- awxkit/awxkit/api/pages/schedules.py | 7 ++++--- awxkit/awxkit/api/pages/system_job_templates.py | 2 ++ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/awxkit/awxkit/api/pages/api.py b/awxkit/awxkit/api/pages/api.py index 14eb14d3d9..a5d469f00e 100644 --- a/awxkit/awxkit/api/pages/api.py +++ b/awxkit/awxkit/api/pages/api.py @@ -26,18 +26,11 @@ EXPORTABLE_RESOURCES = [ 'workflow_job_templates', 'execution_environments', 'applications', + 'schedules', ] -EXPORTABLE_RELATIONS = [ - 'Roles', - 'NotificationTemplates', - 'WorkflowJobTemplateNodes', - 'Credentials', - 'Hosts', - 'Groups', - 'ExecutionEnvironments', -] +EXPORTABLE_RELATIONS = ['Roles', 'NotificationTemplates', 'WorkflowJobTemplateNodes', 'Credentials', 'Hosts', 'Groups', 'ExecutionEnvironments', 'Schedules'] # These are special-case related objects, where we want only in this @@ -45,13 +38,9 @@ EXPORTABLE_RELATIONS = [ DEPENDENT_EXPORT = [ ('JobTemplate', 'labels'), ('JobTemplate', 'survey_spec'), - ('JobTemplate', 'schedules'), ('WorkflowJobTemplate', 'labels'), ('WorkflowJobTemplate', 'survey_spec'), - ('WorkflowJobTemplate', 'schedules'), ('WorkflowJobTemplate', 'workflow_nodes'), - ('Project', 'schedules'), - ('InventorySource', 'schedules'), ('Inventory', 'groups'), ('Inventory', 'hosts'), ('Inventory', 'labels'), diff --git a/awxkit/awxkit/api/pages/schedules.py b/awxkit/awxkit/api/pages/schedules.py index 9bc280b7bf..68a4a812fb 100644 --- a/awxkit/awxkit/api/pages/schedules.py +++ b/awxkit/awxkit/api/pages/schedules.py @@ -1,6 +1,7 @@ from contextlib import suppress -from awxkit.api.pages import UnifiedJob +from awxkit.api.pages import SystemJobTemplate +from awxkit.api.mixins import HasCreate from awxkit.api.resources import resources from awxkit.config import config import awxkit.exceptions as exc @@ -9,8 +10,8 @@ from . import page from . import base -class Schedule(UnifiedJob): - +class Schedule(HasCreate, base.Base): + dependencies = [SystemJobTemplate] NATURAL_KEY = ('unified_job_template', 'name') def silent_delete(self): diff --git a/awxkit/awxkit/api/pages/system_job_templates.py b/awxkit/awxkit/api/pages/system_job_templates.py index cc0d28857a..985d15deb4 100644 --- a/awxkit/awxkit/api/pages/system_job_templates.py +++ b/awxkit/awxkit/api/pages/system_job_templates.py @@ -5,6 +5,8 @@ from . import page class SystemJobTemplate(UnifiedJobTemplate, HasNotifications): + NATURAL_KEY = ('name', 'organization') + def launch(self, payload={}): """Launch the system_job_template using related->launch endpoint.""" result = self.related.launch.post(payload)