@@ -465,26 +465,20 @@ def list_environments(self):
465465 data .append (row )
466466 self .print (data , ignore_silent = True )
467467
468- # temporary fix till the new API is updated to return `profileEnvironmentProperties`
469- def _get_missing_env_properties (
470- self , app_id : str , app_type : str , env_id : str , profile_id : str , from_cache_command : bool
471- ) -> dict :
472- if app_type .lower () == 'kubernetes' and (from_cache_command or self .config .auto_refresh_kube_config ()):
473- if not self .listed_profiles :
474- self .listed_profiles = self .b .my_access .list_profiles ()
475- return next (
476- (
477- env ['profileEnvironmentProperties' ]
478- for app in self .listed_profiles
479- if app ['appContainerId' ] == app_id
480- for profile in app .get ('profiles' , [])
481- if profile ['profileId' ] == profile_id
482- for env in profile .get ('environments' , [])
483- if env ['environmentId' ] == env_id
484- ),
485- {},
486- )
487- return {}
468+ # temporary fix till the new API is updated to return `sessionAttributes`
469+ def _get_missing_session_attributes (self , app_id : str , profile_id : str ) -> dict :
470+ if not self .listed_profiles :
471+ self .listed_profiles = self .b .my_access .list_profiles ()
472+ return next (
473+ (
474+ profile ['sessionAttributes' ]
475+ for app in self .listed_profiles
476+ if app ['appContainerId' ] == app_id
477+ for profile in app .get ('profiles' , [])
478+ if profile ['profileId' ] == profile_id
479+ ),
480+ [],
481+ )
488482
489483 def _set_available_profiles (self , from_cache_command = False , profile_type : Optional [str ] = None ):
490484 if not self .available_profiles :
@@ -509,23 +503,23 @@ def _set_available_profiles(self, from_cache_command=False, profile_type: Option
509503 env = envs [env_id ]
510504 profile = profiles [profile_id ]
511505 row = {
512- 'app_name' : app ['catalogAppDisplayName' ],
506+ '2_part_profile_format_allowed' : app ['requiresHierarchicalModel' ],
507+ 'app_description' : app ['appDescription' ],
513508 'app_id' : app_id ,
509+ 'app_name' : app ['catalogAppDisplayName' ],
514510 'app_type' : app ['catalogAppName' ],
515- 'app_description' : app ['appDescription' ],
516- 'env_name' : env ['environmentName' ],
511+ 'env_description' : env ['environmentDescription' ],
517512 'env_id' : env_id ,
513+ 'env_name' : env ['environmentName' ],
514+ 'env_properties' : env ['profileEnvironmentProperties' ],
518515 'env_short_name' : env ['alternateEnvironmentName' ],
519- 'env_description' : env ['environmentDescription' ],
520- 'profile_name' : profile ['papName' ],
521- 'profile_id' : profile_id ,
522516 'profile_allows_console' : app .get ('consoleAccess' , False ),
523517 'profile_allows_programmatic' : app .get ('programmaticAccess' , False ),
524518 'profile_description' : profile ['papDescription' ],
525- '2_part_profile_format_allowed ' : app [ 'requiresHierarchicalModel' ] ,
526- 'env_properties ' : env [ 'profileEnvironmentProperties' ]
527- or self . _get_missing_env_properties (
528- app_id , app [ 'catalogAppName' ], env_id , profile_id , from_cache_command
519+ 'profile_id ' : profile_id ,
520+ 'profile_name ' : profile [ 'papName' ],
521+ 'session_attributes' : profile . get (
522+ 'sessionAttributes' , self . _get_missing_session_attributes ( app_id , profile_id )
529523 ),
530524 }
531525 if row not in access_output :
@@ -539,21 +533,21 @@ def _set_available_profiles(self, from_cache_command=False, profile_type: Option
539533 profiles = profiles ['data' ]
540534 for item in profiles :
541535 row = {
542- 'app_name' : None ,
536+ '2_part_profile_format_allowed' : False ,
537+ 'app_description' : None ,
543538 'app_id' : None ,
539+ 'app_name' : None ,
544540 'app_type' : 'Resources' ,
545- 'app_description' : None ,
546- 'env_name' : item ['resourceName' ],
541+ 'env_description' : None ,
547542 'env_id' : item ['resourceId' ],
543+ 'env_name' : item ['resourceName' ],
544+ 'env_properties' : item .get ('resourceLabels' , {}),
548545 'env_short_name' : item ['resourceName' ],
549- 'env_description' : None ,
550- 'profile_name' : item ['profileName' ],
551- 'profile_id' : item ['profileId' ],
552546 'profile_allows_console' : False ,
553547 'profile_allows_programmatic' : True ,
554548 'profile_description' : None ,
555- '2_part_profile_format_allowed ' : False ,
556- 'env_properties ' : item . get ( 'resourceLabels' , {}) ,
549+ 'profile_id ' : item [ 'profileId' ] ,
550+ 'profile_name ' : item [ 'profileName' ] ,
557551 }
558552 data .append (row )
559553 self .available_profiles = data
@@ -584,6 +578,7 @@ def construct_kube_config(self, from_cache_command=False):
584578 'profile' : p ['profile_name' ],
585579 'url' : url ,
586580 'cert' : cert ,
581+ 'session_attributes' : p ['session_attributes' ],
587582 }
588583 )
589584
@@ -978,6 +973,7 @@ def checkout(
978973 if self ._profile_is_for_resource (profile = profile , profile_type = profile_type ):
979974 app_type = 'Resources'
980975 k8s_processor = None
976+ console_fallback = False
981977 credentials = self ._resource_checkout (
982978 blocktime = blocktime ,
983979 justification = justification ,
0 commit comments