@@ -153,10 +153,10 @@ def list_profiles(self, checked_out: bool = False):
153153 self .login ()
154154 self ._set_available_profiles ()
155155 data = []
156- checked_out = [p ['papId' ] for p in self .b .my_access .list_checked_out_profiles ()] if checked_out else []
156+ checked_out_profiles = [p ['papId' ] for p in self .b .my_access .list_checked_out_profiles ()] if checked_out else []
157157
158158 for profile in self .available_profiles :
159- if not checked_out or profile ['profileId ' ] in checked_out :
159+ if not checked_out or profile ['profile_id ' ] in checked_out_profiles :
160160 row = {
161161 'Application' : profile ['app_name' ],
162162 'Environment' : profile ['env_name' ],
@@ -275,18 +275,12 @@ def __get_cloud_credential_printer(self, app_type, console, mode, profile, silen
275275
276276 def checkin (self , profile ):
277277 self .login ()
278- profile = self .config .profile_aliases .get (profile , profile )
279- parts = profile .split ('/' )
280- if len (parts ) != 3 :
281- raise click .ClickException ('Provided profile string does not have the required 3 parts.' )
282- app_name = parts [0 ]
283- env_name = parts [1 ]
284- profile_name = parts [2 ]
278+ parts = self ._split_profile_into_parts (profile )
285279
286280 self .b .my_access .checkin_by_name (
287- profile_name = profile_name ,
288- environment_name = env_name ,
289- application_name = app_name
281+ profile_name = parts [ 'profile' ] ,
282+ environment_name = parts [ 'env' ] ,
283+ application_name = parts [ 'app' ]
290284 )
291285
292286 def _checkout (self , profile_name , env_name , app_name , programmatic , blocktime , maxpolltime , justification ):
@@ -311,6 +305,19 @@ def _checkout(self, profile_name, env_name, app_name, programmatic, blocktime, m
311305 def _should_check_force_renew (app , force_renew , console ):
312306 return app in ['AWS' , 'AWS Standalone' ] and force_renew and not console
313307
308+
309+ def _split_profile_into_parts (self , profile ):
310+ profile_real = self .config .profile_aliases .get (profile , profile )
311+ parts = profile_real .split ('/' )
312+ if len (parts ) != 3 :
313+ raise click .ClickException ('Provided profile string does not have the required 3 parts.' )
314+ parts_dict = {
315+ 'app' : parts [0 ],
316+ 'env' : parts [1 ],
317+ 'profile' : parts [2 ]
318+ }
319+ return parts_dict
320+
314321 def checkout (self , alias , blocktime , console , justification , mode , maxpolltime , profile , passphrase ,
315322 force_renew , aws_credentials_file ):
316323 credentials = None
@@ -335,16 +342,13 @@ def checkout(self, alias, blocktime, console, justification, mode, maxpolltime,
335342 else :
336343 credential_process_creds_found = True
337344
338- profile_real = self .config .profile_aliases .get (profile , profile )
339- parts = profile_real .split ('/' )
340- if len (parts ) != 3 :
341- raise click .ClickException ('Provided profile string does not have the required 3 parts.' )
345+ parts = self ._split_profile_into_parts (profile )
342346
343347 # create this params once so we can use it multiple places
344348 params = {
345- 'profile_name' : parts [2 ],
346- 'env_name' : parts [1 ],
347- 'app_name' : parts [0 ],
349+ 'profile_name' : parts ['profile' ],
350+ 'env_name' : parts ['env' ],
351+ 'app_name' : parts ['app' ],
348352 'programmatic' : False if console else True ,
349353 'blocktime' : blocktime ,
350354 'maxpolltime' : maxpolltime ,
@@ -504,6 +508,28 @@ def cache_clear():
504508 def configure_update (self , section , field , value ):
505509 self .config .update (section = section , field = field , value = value )
506510
511+ def request_submit (self , profile , justification ):
512+ self .login ()
513+ parts = self ._split_profile_into_parts (profile )
514+
515+ self .b .my_access .request_approval_by_name (
516+ profile_name = parts ['profile' ],
517+ environment_name = parts ['env' ],
518+ application_name = parts ['app' ],
519+ block_until_disposition = False ,
520+ justification = justification
521+ )
522+
523+ def request_withdraw (self , profile ):
524+ self .login ()
525+ parts = self ._split_profile_into_parts (profile )
526+
527+ self .b .my_access .withdraw_approval_request_by_name (
528+ profile_name = parts ['profile' ],
529+ environment_name = parts ['env' ],
530+ application_name = parts ['app' ]
531+ )
532+
507533
508534
509535
0 commit comments