jira: (#21701)
- Add timeout param. - Some improvement on params description.
This commit is contained in:
parent
2cd6e56dc2
commit
ea2b27f931
1 changed files with 27 additions and 19 deletions
|
@ -35,7 +35,7 @@ options:
|
||||||
uri:
|
uri:
|
||||||
required: true
|
required: true
|
||||||
description:
|
description:
|
||||||
- Base URI for the JIRA instance
|
- Base URI for the JIRA instance.
|
||||||
|
|
||||||
operation:
|
operation:
|
||||||
required: true
|
required: true
|
||||||
|
@ -99,25 +99,32 @@ options:
|
||||||
required: false
|
required: false
|
||||||
version_added: 2.3
|
version_added: 2.3
|
||||||
description:
|
description:
|
||||||
- Set type of link, when action 'link' selected
|
- Set type of link, when action 'link' selected.
|
||||||
|
|
||||||
inwardissue:
|
inwardissue:
|
||||||
required: false
|
required: false
|
||||||
version_added: 2.3
|
version_added: 2.3
|
||||||
description:
|
description:
|
||||||
- set issue from which link will be created
|
- Set issue from which link will be created.
|
||||||
|
|
||||||
outwardissue:
|
outwardissue:
|
||||||
required: false
|
required: false
|
||||||
version_added: 2.3
|
version_added: 2.3
|
||||||
description:
|
description:
|
||||||
- set issue to which link will be created
|
- Set issue to which link will be created.
|
||||||
|
|
||||||
fields:
|
fields:
|
||||||
required: false
|
required: false
|
||||||
description:
|
description:
|
||||||
- This is a free-form data structure that can contain arbitrary data. This is passed directly to the JIRA REST API (possibly after merging with other required data, as when passed to create). See examples for more information, and the JIRA REST API for the structure required for various fields.
|
- This is a free-form data structure that can contain arbitrary data. This is passed directly to the JIRA REST API (possibly after merging with other required data, as when passed to create). See examples for more information, and the JIRA REST API for the structure required for various fields.
|
||||||
|
|
||||||
|
timeout:
|
||||||
|
required: false
|
||||||
|
version_added: 2.3
|
||||||
|
description:
|
||||||
|
- Set timeout, in seconds, on requests to JIRA API.
|
||||||
|
default: 10
|
||||||
|
|
||||||
notes:
|
notes:
|
||||||
- "Currently this only works with basic-auth."
|
- "Currently this only works with basic-auth."
|
||||||
|
|
||||||
|
@ -237,7 +244,7 @@ from ansible.module_utils.basic import *
|
||||||
from ansible.module_utils.urls import *
|
from ansible.module_utils.urls import *
|
||||||
from ansible.module_utils.pycompat24 import get_exception
|
from ansible.module_utils.pycompat24 import get_exception
|
||||||
|
|
||||||
def request(url, user, passwd, data=None, method=None):
|
def request(url, user, passwd, timeout, data=None, method=None):
|
||||||
if data:
|
if data:
|
||||||
data = json.dumps(data)
|
data = json.dumps(data)
|
||||||
|
|
||||||
|
@ -249,7 +256,7 @@ def request(url, user, passwd, data=None, method=None):
|
||||||
# inject the basic-auth header up-front to ensure that JIRA treats
|
# inject the basic-auth header up-front to ensure that JIRA treats
|
||||||
# the requests as authorized for this user.
|
# the requests as authorized for this user.
|
||||||
auth = base64.encodestring('%s:%s' % (user, passwd)).replace('\n', '')
|
auth = base64.encodestring('%s:%s' % (user, passwd)).replace('\n', '')
|
||||||
response, info = fetch_url(module, url, data=data, method=method,
|
response, info = fetch_url(module, url, data=data, method=method, timeout=timeout,
|
||||||
headers={'Content-Type':'application/json',
|
headers={'Content-Type':'application/json',
|
||||||
'Authorization':"Basic %s" % auth})
|
'Authorization':"Basic %s" % auth})
|
||||||
|
|
||||||
|
@ -263,14 +270,14 @@ def request(url, user, passwd, data=None, method=None):
|
||||||
else:
|
else:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def post(url, user, passwd, data):
|
def post(url, user, passwd, timeout, data):
|
||||||
return request(url, user, passwd, data=data, method='POST')
|
return request(url, user, passwd, timeout, data=data, method='POST')
|
||||||
|
|
||||||
def put(url, user, passwd, data):
|
def put(url, user, passwd, timeout, data):
|
||||||
return request(url, user, passwd, data=data, method='PUT')
|
return request(url, user, passwd, timeout, data=data, method='PUT')
|
||||||
|
|
||||||
def get(url, user, passwd):
|
def get(url, user, passwd, timeout):
|
||||||
return request(url, user, passwd)
|
return request(url, user, passwd, timeout)
|
||||||
|
|
||||||
|
|
||||||
def create(restbase, user, passwd, params):
|
def create(restbase, user, passwd, params):
|
||||||
|
@ -288,7 +295,7 @@ def create(restbase, user, passwd, params):
|
||||||
|
|
||||||
url = restbase + '/issue/'
|
url = restbase + '/issue/'
|
||||||
|
|
||||||
ret = post(url, user, passwd, data)
|
ret = post(url, user, passwd, params['timeout'], data)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -300,7 +307,7 @@ def comment(restbase, user, passwd, params):
|
||||||
|
|
||||||
url = restbase + '/issue/' + params['issue'] + '/comment'
|
url = restbase + '/issue/' + params['issue'] + '/comment'
|
||||||
|
|
||||||
ret = post(url, user, passwd, data)
|
ret = post(url, user, passwd, params['timeout'], data)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -312,21 +319,21 @@ def edit(restbase, user, passwd, params):
|
||||||
|
|
||||||
url = restbase + '/issue/' + params['issue']
|
url = restbase + '/issue/' + params['issue']
|
||||||
|
|
||||||
ret = put(url, user, passwd, data)
|
ret = put(url, user, passwd, params['timeout'],data)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def fetch(restbase, user, passwd, params):
|
def fetch(restbase, user, passwd, params):
|
||||||
url = restbase + '/issue/' + params['issue']
|
url = restbase + '/issue/' + params['issue']
|
||||||
ret = get(url, user, passwd)
|
ret = get(url, user, passwd, params['timeout'])
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def transition(restbase, user, passwd, params):
|
def transition(restbase, user, passwd, params):
|
||||||
# Find the transition id
|
# Find the transition id
|
||||||
turl = restbase + '/issue/' + params['issue'] + "/transitions"
|
turl = restbase + '/issue/' + params['issue'] + "/transitions"
|
||||||
tmeta = get(turl, user, passwd)
|
tmeta = get(turl, user, passwd, params['timeout'])
|
||||||
|
|
||||||
target = params['status']
|
target = params['status']
|
||||||
tid = None
|
tid = None
|
||||||
|
@ -343,7 +350,7 @@ def transition(restbase, user, passwd, params):
|
||||||
data = { 'transition': { "id" : tid },
|
data = { 'transition': { "id" : tid },
|
||||||
'fields': params['fields']}
|
'fields': params['fields']}
|
||||||
|
|
||||||
ret = post(url, user, passwd, data)
|
ret = post(url, user, passwd, params['timeout'], data)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -356,7 +363,7 @@ def link(restbase, user, passwd, params):
|
||||||
|
|
||||||
url = restbase + '/issueLink/'
|
url = restbase + '/issueLink/'
|
||||||
|
|
||||||
ret = post(url, user, passwd, data)
|
ret = post(url, user, passwd, params['timeout'], data)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -390,6 +397,7 @@ def main():
|
||||||
linktype=dict(),
|
linktype=dict(),
|
||||||
inwardissue=dict(),
|
inwardissue=dict(),
|
||||||
outwardissue=dict(),
|
outwardissue=dict(),
|
||||||
|
timeout=dict(type='float', default=10),
|
||||||
),
|
),
|
||||||
supports_check_mode=False
|
supports_check_mode=False
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue