Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds import export to awx cli for schedules as a top level object #12351

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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