1414
1515# Global Variables
1616VERSION = '1.1.0'
17+ DEFAULT_API_VERSION = '1.12'
1718HEADER = 'Pure Storage List Volumes (' + VERSION + ')'
1819BANNER = ('=' * 102 )
1920DEBUG_LEVEL = 0
@@ -35,7 +36,7 @@ def create_session(flashArray, user, password, api_token):
3536 'username' : password
3637 }
3738 params = json .dumps (data )
38- path = '/api/1.12 /auth/apitoken'
39+ path = '/api' + API_VERSION + ' /auth/apitoken'
3940 url = 'https://%s%s' % (flashArray ,path )
4041
4142 # Perform action
@@ -66,7 +67,7 @@ def create_session(flashArray, user, password, api_token):
6667 }
6768
6869 params = json .dumps (data )
69- path = '/api/1.12 /auth/session'
70+ path = '/api/' + API_VERSION + ' /auth/session'
7071 url = 'https://%s%s' % (flashArray ,path )
7172
7273 # Perform action
@@ -150,7 +151,7 @@ def list_volumes(flashArray):
150151 data = ''
151152 params = json .dumps (data )
152153
153- path = '/api/1.12 /volume?space=true'
154+ path = '/api/' + API_VERSION + ' /volume?space=true'
154155
155156 # Perform action
156157 jsonData = get_url (flashArray ,path ,params )
@@ -218,6 +219,12 @@ def parsecl():
218219 dest = 'api_token' ,
219220 help = 'Pure Api Token' )
220221
222+ parser .add_option ('-V' , '--apiversion' ,
223+ action = 'store' ,
224+ type = 'string' ,
225+ dest = 'API_VERSION' ,
226+ help = 'Pure FlashArray API Version' )
227+
221228 parser .add_option ('-u' , '--user' ,
222229 action = 'store' ,
223230 type = 'string' ,
@@ -246,6 +253,7 @@ def main():
246253 # Setup variables
247254 global DEBUG_LEVEL
248255 global VERBOSE_FLAG
256+ global API_VERSION
249257 exit_code = 0
250258
251259 # Check for command line parameters
@@ -256,6 +264,7 @@ def main():
256264 api_token = options .api_token
257265 DEBUG_LEVEL = options .DEBUG_LEVEL
258266 VERBOSE_FLAG = options .VERBOSE_FLAG
267+ API_VERSION = options .API_VERSION
259268
260269 if DEBUG_LEVEL != 0 :
261270 print ('Password' , password )
@@ -268,6 +277,9 @@ def main():
268277 if flashArray == None :
269278 sys .exit ('Exiting: You must provide FlashArray details' )
270279
280+ if API_VERSION == None :
281+ API_VERSION = DEFAULT_API_VERSION
282+
271283 if api_token == None and user == None :
272284 sys .exit ('Exiting: You must provide either API Token details or username and password' )
273285
0 commit comments