mirror of
https://github.com/ansible/awx.git
synced 2026-02-16 10:40:01 -03:30
Add a new extra_credentials endpoint for Jobs and JobTemplates
additionally, add backwards compatible support for `cloud_credential` and `network_credential` in /api/v1/job_templates/ and /api/v1/jobs/. see: #5807
This commit is contained in:
@@ -2659,6 +2659,21 @@ class JobTemplateNotificationTemplatesSuccessList(SubListCreateAttachDetachAPIVi
|
||||
new_in_300 = True
|
||||
|
||||
|
||||
class JobTemplateExtraCredentialsList(SubListCreateAttachDetachAPIView):
|
||||
|
||||
model = Credential
|
||||
serializer_class = CredentialSerializer
|
||||
parent_model = JobTemplate
|
||||
relationship = 'extra_credentials'
|
||||
new_in_320 = True
|
||||
new_in_api_v2 = True
|
||||
|
||||
def is_valid_relation(self, parent, sub, created=False):
|
||||
if sub.credential_type.kind not in ('net', 'cloud'):
|
||||
return {'error': _('Extra credentials must be network or cloud.')}
|
||||
return super(JobTemplateExtraCredentialsList, self).is_valid_relation(parent, sub, created)
|
||||
|
||||
|
||||
class JobTemplateLabelList(DeleteLastUnattachLabelMixin, SubListCreateAttachDetachAPIView):
|
||||
|
||||
model = Label
|
||||
@@ -3420,6 +3435,21 @@ class JobDetail(RetrieveUpdateDestroyAPIView):
|
||||
return super(JobDetail, self).destroy(request, *args, **kwargs)
|
||||
|
||||
|
||||
class JobExtraCredentialsList(SubListCreateAttachDetachAPIView):
|
||||
|
||||
model = Credential
|
||||
serializer_class = CredentialSerializer
|
||||
parent_model = Job
|
||||
relationship = 'extra_credentials'
|
||||
new_in_320 = True
|
||||
new_in_api_v2 = True
|
||||
|
||||
def is_valid_relation(self, parent, sub, created=False):
|
||||
if sub.credential_type.kind not in ('net', 'cloud'):
|
||||
return {'error': _('Extra credentials must be network or cloud.')}
|
||||
return super(JobExtraCredentialsList, self).is_valid_relation(parent, sub, created)
|
||||
|
||||
|
||||
class JobLabelList(SubListAPIView):
|
||||
|
||||
model = Label
|
||||
|
||||
Reference in New Issue
Block a user