Skip to content

Commit

Permalink
Merge pull request #12351 from AlexSCorey/5673-t-importExportSchedules
Browse files Browse the repository at this point in the history
Adds import export to awx cli for schedules as a top level object
  • Loading branch information
jbradberry committed Jun 22, 2022
2 parents 989b389 + 02e7424 commit b44442c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
15 changes: 2 additions & 13 deletions awxkit/awxkit/api/pages/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,21 @@
'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
# case to export a full object instead of a natural key reference.
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'),
Expand Down
7 changes: 4 additions & 3 deletions awxkit/awxkit/api/pages/schedules.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,8 +10,8 @@
from . import base


class Schedule(UnifiedJob):

class Schedule(HasCreate, base.Base):
dependencies = [SystemJobTemplate]
NATURAL_KEY = ('unified_job_template', 'name')

def silent_delete(self):
Expand Down
2 changes: 2 additions & 0 deletions awxkit/awxkit/api/pages/system_job_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@


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)
Expand Down

0 comments on commit b44442c

Please sign in to comment.