@@ -23,7 +23,7 @@ def main():
2323 #
2424 parser = argparse .ArgumentParser (description = 'Customfield Editor Plugin REST API CLI Client.' )
2525
26- parser .add_argument ("-a" , "--action" , help = 'Which action to execute.' , choices = ['adminListFields' , 'adminGrantPermission' , 'userListFields' , 'userListOptions' ])
26+ parser .add_argument ("-a" , "--action" , help = 'Which action to execute.' , choices = ['adminListFields' , 'adminGrantPermission' , 'userListFields' , 'userListOptions' , 'userInsertOptions' ])
2727 parser .add_argument ("-url" , "--baseUrl" , help = 'baseUrl to JIRA instance e.g. http://server:port/jira/' )
2828 parser .add_argument ("-user" , "--authUsername" , help = 'username for basic auth.' )
2929 parser .add_argument ("-pass" , "--authPassword" , help = 'password for basic auth.' )
@@ -35,6 +35,7 @@ def main():
3535 parser .add_argument ("-ctx" , "--contextId" , type = int , help = 'The ID of the custom field context.' )
3636 parser .add_argument ("-ulist" , "--userList" , nargs = '+' , help = 'space separated user names to grant permission' )
3737 parser .add_argument ("-glist" , "--groupList" , nargs = '+' , help = 'space separated group names to grant permission' )
38+ parser .add_argument ("-f" , "--payloadFile" , help = 'Payload JSON file.' )
3839
3940 args = parser .parse_args ()
4041 if not args .action :
@@ -55,6 +56,10 @@ def main():
5556 print (' list options:' )
5657 print (' $> cep-client -a userListOptions --customFieldId 10001 -url http://localhost:2990/jira/ -user admin -pass admin' )
5758 print (' OPTIONAL: --contextId specify if you want another context other than default context' )
59+ print ('' )
60+ print (' insert options:' )
61+ print (' $> cep-client -a userInsertOptions --customFieldId 10001 -f ./test-data/options-to-insert.json -url http://localhost:2990/jira/ -user admin -pass admin' )
62+ print (' FILE FORMAT: https://github.com/codeclou/customfield-editor-plugin/tree/cep-client/test-data/options-to-insert.json ' )
5863
5964 sys .exit (1 )
6065
@@ -98,8 +103,6 @@ def main():
98103 #
99104 if args .action == 'adminListFields' :
100105 adminOperations .list_fields ()
101-
102-
103106 if args .action == 'adminGrantPermission' :
104107 adminOperations .grant_permission (args .customFieldId , args .userList , args .groupList )
105108
@@ -109,9 +112,15 @@ def main():
109112 #
110113 if args .action == 'userListFields' :
111114 userOperations .list_fields ()
112-
113115 if args .action == 'userListOptions' :
114116 userOperations .list_options (args .customFieldId , args .contextId )
117+ if args .action == 'userInsertOptions' :
118+ try :
119+ with open (args .payloadFile ) as payloadFile :
120+ userOperations .insert_options (args .customFieldId , args .contextId , payloadFile )
121+ except FileNotFoundError as ex :
122+ printHelper .error ('payloadFile not found: {0}' .format (args .payloadFile ))
123+ raise ApiHelperException ('payloadFile not found' )
115124
116125
117126 except requests .ConnectionError as ex :
0 commit comments