@@ -342,8 +342,8 @@ def list_resources(self):
342342 self .login ()
343343 found_resource_names = []
344344 resources = []
345- if resource_profile_limit := int (self .config .my_resources_retrieval_limit ):
346- profiles = self .b .my_resources .list (size = resource_profile_limit )['data' ]
345+ if resource_limit := int (self .config .my_resources_retrieval_limit ):
346+ profiles = self .b .my_resources .list (size = resource_limit )['data' ]
347347 else :
348348 profiles = self .b .my_resources .list_profiles ()
349349 for item in profiles :
@@ -464,41 +464,47 @@ def _set_available_profiles(self, from_cache_command=False, profile_type: Option
464464 if not self .available_profiles :
465465 data = []
466466 if not profile_type or profile_type == 'my-access' :
467- access_profile_limit = int (self .config .my_access_retrieval_limit )
468- access_data = self .b .my_access .list (size = access_profile_limit )
469- apps = {app ['appContainerId' ]: app for app in access_data ['apps' ]}
470- envs = {env ['environmentId' ]: env for env in access_data ['environments' ]}
471- accs = {
472- p : {'env_id' : v , 'types' : [t ['accessType' ] for t in access_data ['accesses' ] if t ['papId' ] == p ]}
473- for p , v in {(a ['papId' ], a ['environmentId' ]) for a in access_data ['accesses' ]}
474- }
475- for profile in access_data ['profiles' ]:
476- acc = accs .get (profile ['papId' ], {})
477- env = envs .get (acc .get ('env_id' ), {}) # Get environment info or default to empty dict
478- app = apps .get (profile ['appContainerId' ], {})
467+ access_limit = int (self .config .my_access_retrieval_limit )
468+ increase = 0
469+ while (access_data := self .b .my_access .list (size = access_limit + increase ))['count' ] > len (
470+ access_data ['accesses' ]
471+ ) and len ({a ['papId' ] for a in access_data ['accesses' ]}) < access_limit :
472+ increase += max (25 , round (access_data ['count' ] * 0.25 ))
473+ access_output = []
474+ for access in access_data ['accesses' ]:
475+ appContainerId = access ['appContainerId' ]
476+ environmentId = access ['environmentId' ]
477+ papId = access ['papId' ]
478+ app = next ((a for a in access_data .get ('apps' , []) if a ['appContainerId' ] == appContainerId ), {})
479+ environment = next (
480+ (e for e in access_data .get ('environments' , []) if e ['environmentId' ] == environmentId ), {}
481+ )
482+ profile = next ((p for p in access_data .get ('profiles' , []) if p ['papId' ] == papId ), {})
479483 row = {
480- 'app_name' : profile [ 'catalogAppDisplayName ' ],
481- 'app_id' : profile [ ' appContainerId' ] ,
482- 'app_type' : profile [ 'catalogAppName ' ],
483- 'app_description' : app . get ( 'appDescription' ) ,
484- 'env_name' : env . get ( 'environmentName' , '' ), # Pull from `environments`
485- 'env_id' : env . get ( ' environmentId' , '' ), # Pull from `environments`
486- 'env_short_name' : env . get ( 'alternateEnvironmentName' , '' ), # Pull from `environments`
487- 'env_description' : env . get ( 'environmentDescription' , '' ), # Pull from `environments`
484+ 'app_name' : app [ 'catalogAppName ' ],
485+ 'app_id' : appContainerId ,
486+ 'app_type' : app [ 'catalogAppDisplayName ' ],
487+ 'app_description' : app [ 'appDescription' ] ,
488+ 'env_name' : environment [ 'environmentName' ],
489+ 'env_id' : environmentId ,
490+ 'env_short_name' : environment [ 'alternateEnvironmentName' ],
491+ 'env_description' : environment [ 'environmentDescription' ],
488492 'profile_name' : profile ['papName' ],
489- 'profile_id' : profile [ ' papId' ] ,
490- 'profile_allows_console' : 'CONSOLE' in acc .get ('types' ),
491- 'profile_allows_programmatic' : 'PROGRAMMATIC' in acc .get ('types' ),
493+ 'profile_id' : papId ,
494+ 'profile_allows_console' : app .get ('consoleAccess' , False ),
495+ 'profile_allows_programmatic' : app .get ('programmaticAccess' , False ),
492496 'profile_description' : profile ['papDescription' ],
493- '2_part_profile_format_allowed' : app ['requiresHierarchicalModel ' ],
494- 'env_properties' : env .get ('profileEnvironmentProperties' , {}), # Pull from `environments`
497+ '2_part_profile_format_allowed' : app ['supportsMultipleProfilesCheckoutConsole ' ],
498+ 'env_properties' : environment .get ('profileEnvironmentProperties' , {}),
495499 }
496- data .append (row )
500+ if row not in access_output :
501+ access_output .append (row )
502+ data += access_output [:access_limit ]
497503 if self .b .feature_flags .get ('server-access' ) and (not profile_type or profile_type == 'my-resources' ):
498- if not (resource_profile_limit := int (self .config .my_resources_retrieval_limit )):
504+ if not (resource_limit := int (self .config .my_resources_retrieval_limit )):
499505 profiles = self .b .my_resources .list_profiles ()
500506 else :
501- profiles = self .b .my_resources .list (size = resource_profile_limit )
507+ profiles = self .b .my_resources .list (size = resource_limit )
502508 profiles = profiles ['data' ]
503509 for item in profiles :
504510 row = {
0 commit comments