Add new add_label method to the wfjt node and schedules awxkit models

This commit is contained in:
Oleksii Baranov 2022-09-15 12:28:07 +02:00 committed by Alan Rominger
parent efeeeefd4c
commit 4579ab0d60
No known key found for this signature in database
GPG Key ID: C2D7EAAA12B63559
2 changed files with 12 additions and 0 deletions

View File

@ -47,6 +47,12 @@ class Schedules(page.PageList, Schedule):
with suppress(exc.NoContent):
self.related.credentials.post(dict(id=cred.id, disassociate=True))
def add_label(self, label):
if isinstance(label, page.Page):
label = label.json
with suppress(exc.NoContent):
self.related.labels.post(label)
page.register_page([resources.schedules, resources.related_schedules], Schedules)

View File

@ -92,6 +92,12 @@ class WorkflowJobTemplateNode(HasCreate, base.Base):
candidates = workflow_job.get_related('workflow_nodes', identifier=self.identifier)
return candidates.results.pop()
def add_label(self, label):
if isinstance(label, page.Page):
label = label.json
with suppress(exc.NoContent):
self.related.labels.post(label)
page.register_page(
[resources.workflow_job_template_node, (resources.workflow_job_template_nodes, 'post'), (resources.workflow_job_template_workflow_nodes, 'post')],