1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

add object query fields

This commit is contained in:
Jake McDermott 2019-03-22 11:12:09 -04:00
parent da9abc087e
commit f9e081046c
No known key found for this signature in database
GPG Key ID: 9A6F084352C3A0B7

View File

@ -4,7 +4,7 @@ import os
import stat
import tempfile
import threading
from urllib.parse import quote, urljoin
from urllib.parse import quote, urlencode, urljoin
from django.utils.translation import ugettext_lazy as _
import requests
@ -26,30 +26,36 @@ aim_inputs = {
'type': 'string',
'secret': True,
'multiline': True,
'format': 'ssh_private_key',
}, {
'id': 'client_cert',
'label': _('Client Certificate'),
'type': 'string',
'secret': True,
'multiline': True,
'format': 'ssh_private_key',
}, {
'id': 'verify',
'label': _('Verify SSL Certificates'),
'type': 'boolean',
'default': True,
'label': _('Verify SSL Certificates'),
}],
'metadata': [{
'id': 'safe',
'label': _('Safe'),
'id': 'object_query',
'label': _('Object Query'),
'type': 'string',
'help_text': _('Lookup query for the object. Ex: "Safe=TestSafe;Object=testAccountName123"'),
}, {
'id': 'object',
'label': _('Object'),
'id': 'object_query_format',
'label': _('Object Query Format'),
'type': 'string',
'default': 'Exact',
'choices': ['Exact', 'Regexp']
}, {
'id': 'reason',
'label': _('Reason'),
'type': 'string',
'help_text': _('Object request reason. This is only needed if it is required by the object\'s policy.')
}],
'required': ['url', 'app_id', 'safe', 'object'],
'required': ['url', 'app_id', 'query'],
}
@ -73,14 +79,23 @@ def create_temporary_fifo(data):
def aim_backend(**kwargs):
url = kwargs['url']
verify = kwargs['verify']
client_cert = kwargs.get('client_cert', None)
client_key = kwargs.get('client_key', None)
app_id = quote(kwargs['app_id'])
safe = quote(kwargs['safe'])
object_ = quote(kwargs['object'])
verify = kwargs['verify']
app_id = kwargs['app_id']
object_query = kwargs['object_query']
object_query_format = kwargs['object_query_format']
reason = kwargs.get('reason', None)
request_qs = '?AppId={0}&Safe={1}&object={2}'.format(app_id, safe, object_)
query_params = {
'AppId': app_id,
'Query': object_query,
'QueryFormat': object_query_format,
}
if reason:
query_params['reason'] = reason
request_qs = '?' + urlencode(query_params, quote_via=quote)
request_url = urljoin(url, '/'.join(['AIMWebService', 'api', 'Accounts']))
cert = None