@@ -243,7 +243,7 @@ def debug(self, data: object, ignore_silent: bool = False):
243243 if debug_enabled :
244244 self .print (data = data , ignore_silent = ignore_silent )
245245
246- # will be passed to the britive checkout_by_name progress_func parameter when appropriate
246+ # will be passed to the britive checkout progress_func parameter when appropriate
247247 def checkout_callback_printer (self , message : str ):
248248 if self .silent or not sys .stdout .isatty ():
249249 return
@@ -474,8 +474,7 @@ def _set_available_profiles(self, from_cache_command=False, profile_type: Option
474474 envs = {e ['environmentId' ]: e for e in access_data .get ('environments' , [])}
475475 profiles = {p ['papId' ]: p for p in access_data .get ('profiles' , [])}
476476 accesses = [
477- tuple ([a ['appContainerId' ], a ['environmentId' ], a ['papId' ]])
478- for a in access_data .get ('accesses' , [])
477+ ([a ['appContainerId' ], a ['environmentId' ], a ['papId' ]]) for a in access_data .get ('accesses' , [])
479478 ]
480479 access_output = []
481480 for app_id , env_id , profile_id in accesses :
@@ -572,6 +571,14 @@ def _get_app_type(self, application_id):
572571 for profile in self .available_profiles :
573572 if profile ['app_id' ] == application_id :
574573 return profile ['app_type' ]
574+ if self .config .my_access_retrieval_limit :
575+ return next (
576+ iter (
577+ a ['catalogAppName' ]
578+ for a in self .b .get (f'{ self .b .base_url } /access/apps/' )
579+ if a ['appContainerId' ] == application_id
580+ )
581+ )
575582 raise click .ClickException (f'Application { application_id } not found' )
576583
577584 def __get_cloud_credential_printer (
@@ -1242,6 +1249,34 @@ def _convert_names_to_ids(self, profile_name: str, environment_name: str, applic
12421249
12431250 # let's first check to ensure we have only 1 profile
12441251 if len (found_profiles ) == 0 :
1252+ if self .config .my_access_retrieval_limit :
1253+ try :
1254+ app_id = next (
1255+ iter (
1256+ a ['appContainerId' ]
1257+ for a in self .b .get (f'{ self .b .base_url } /access/apps/' )
1258+ if a ['catalogAppDisplayName' ].lower () == application_name
1259+ )
1260+ )
1261+ env_id = next (
1262+ iter (
1263+ e ['environmentId' ]
1264+ for e in self .b .get (f'{ self .b .base_url } /access/apps/{ app_id } /environments/' )
1265+ if e ['environmentName' ].lower () == environment_name
1266+ or e ['environmentId' ] == environment_name
1267+ or e ['alternateEnvironmentName' ].lower () == environment_name
1268+ )
1269+ )
1270+ pap_id = next (
1271+ iter (
1272+ p ['papId' ]
1273+ for p in self .b .get (f'{ self .b .base_url } /access/apps/{ app_id } /environments/{ env_id } /paps' )
1274+ if p ['papName' ].lower () == profile_name
1275+ )
1276+ )
1277+ return {'profile_id' : pap_id , 'environment_id' : env_id }
1278+ except StopIteration :
1279+ pass
12451280 raise click .ClickException ('no profile found with the provided application, environment, and profile names' )
12461281 if len (found_profiles ) > 1 :
12471282 raise click .ClickException ('multiple matching profiles found - cannot determine which profile to use' )
0 commit comments