File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+
3
+ import argparse
4
+ import json
5
+ import logging
6
+ import sys
7
+
8
+
9
+ from blackduck .HubRestApi import HubInstance
10
+
11
+
12
+ def check_minimum (value ):
13
+ minimum = 1800
14
+ ivalue = int (value )
15
+ if ivalue < minimum :
16
+ raise argparse .ArgumentTypeError ("Timeout value must be greater than or equal to {} (seconds). You gave {}" .format (
17
+ minimum , ivalue ))
18
+ return ivalue
19
+
20
+ parser = argparse .ArgumentParser ("Set the user session timeout - applies to both local and SSO authenticated sessions" )
21
+ parser .add_argument ("timeout" , type = check_minimum , help = "The (integer) timeout value in seconds" )
22
+ args = parser .parse_args ()
23
+
24
+ logging .basicConfig (format = '%(asctime)s%(levelname)s:%(message)s' , stream = sys .stderr , level = logging .DEBUG )
25
+ logging .getLogger ("requests" ).setLevel (logging .WARNING )
26
+ logging .getLogger ("urllib3" ).setLevel (logging .WARNING )
27
+
28
+ hub = HubInstance ()
29
+
30
+ url = hub .get_apibase () + "/system-oauth-client"
31
+
32
+ new_timeout = {
33
+ "accessTokenValiditySeconds" : args .timeout
34
+ }
35
+
36
+ response = hub .execute_put (url , data = new_timeout )
37
+ print ("Result code for attempting to set session timeout to {} seconds was: {}" .format (
38
+ args .timeout , response .status_code ))
You can’t perform that action at this time.
0 commit comments