Skip to content

Commit edc6bdc

Browse files
author
Bernhard Grünewaldt
committed
insert options and setting default value working for select field
1 parent ebb7cbb commit edc6bdc

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

customfield_editor_plugin_client/cli_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def main():
131131
sys.exit(1)
132132
except ApiHelperException as ex:
133133
printHelper.pretty(ex.args[0])
134+
#if 'details' in ex:
135+
# printHelper.pretty(ex.details)
134136
printHelper.error('There seemed to a be problem with your request. Check errors above. EXIT')
135137
sys.exit(1)
136138

customfield_editor_plugin_client/helper/api_helper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,7 @@ def _handle_response_errors(self, response):
8181
elif response.status_code == 403:
8282
raise ApiHelperException('FORBIDDEN (403). Insufficient rights - OR - too many failed login attempts. (Log into JIRA in the browser to solve CAPTCHA).')
8383
else:
84-
raise ApiHelperException('request failed with HTTP {0}'.format(response.status_code))
84+
ex = ApiHelperException('request failed with HTTP {0}'.format(response.status_code))
85+
self.printHelper.pretty(response)
86+
ex.details = response.json()
87+
raise ex

customfield_editor_plugin_client/helper/api_helper_exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class ApiHelperException(Exception):
2+
details = None
23
def __init__(self, value):
34
self.value = value
45
def __str__(self):

customfield_editor_plugin_client/modules/user_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def insert_options(self, customfield_id, context_id, options):
3838
if created_option and 'id' in created_option:
3939
self._print.pretty(created_option)
4040
if 'default' in option:
41-
self._api.post('/user/customfields/{0}/contexts/{1}/options/default'.format(customfield_id, context_infix),
41+
self._api.put('/user/customfields/{0}/contexts/{1}/options/default'.format(customfield_id, context_infix),
4242
{
4343
"optionId": created_option['id']
4444
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"optionvalue" : "windows"
4+
},
5+
{
6+
"optionvalue" : "linux"
7+
},
8+
{
9+
"optionvalue" : "mac",
10+
"default": "true"
11+
}
12+
]

test-data/options-to-insert.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)