From 616f60807f53b08aa21dbe831510250440239669 Mon Sep 17 00:00:00 2001 From: theborch Date: Mon, 10 Mar 2025 14:56:50 -0500 Subject: [PATCH 1/2] refactor:fallback to profile check when limit used --- src/pybritive/britive_cli.py | 41 +++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/pybritive/britive_cli.py b/src/pybritive/britive_cli.py index e2d7611..d837c38 100644 --- a/src/pybritive/britive_cli.py +++ b/src/pybritive/britive_cli.py @@ -243,7 +243,7 @@ def debug(self, data: object, ignore_silent: bool = False): if debug_enabled: self.print(data=data, ignore_silent=ignore_silent) - # will be passed to the britive checkout_by_name progress_func parameter when appropriate + # will be passed to the britive checkout progress_func parameter when appropriate def checkout_callback_printer(self, message: str): if self.silent or not sys.stdout.isatty(): return @@ -474,8 +474,7 @@ def _set_available_profiles(self, from_cache_command=False, profile_type: Option envs = {e['environmentId']: e for e in access_data.get('environments', [])} profiles = {p['papId']: p for p in access_data.get('profiles', [])} accesses = [ - tuple([a['appContainerId'], a['environmentId'], a['papId']]) - for a in access_data.get('accesses', []) + ([a['appContainerId'], a['environmentId'], a['papId']]) for a in access_data.get('accesses', []) ] access_output = [] for app_id, env_id, profile_id in accesses: @@ -572,6 +571,14 @@ def _get_app_type(self, application_id): for profile in self.available_profiles: if profile['app_id'] == application_id: return profile['app_type'] + if self.config.my_access_retrieval_limit: + return next( + iter( + a['catalogAppName'] + for a in self.b.get(f'{self.b.base_url}/access/apps/') + if a['appContainerId'] == application_id + ) + ) raise click.ClickException(f'Application {application_id} not found') def __get_cloud_credential_printer( @@ -1242,6 +1249,34 @@ def _convert_names_to_ids(self, profile_name: str, environment_name: str, applic # let's first check to ensure we have only 1 profile if len(found_profiles) == 0: + if self.config.my_access_retrieval_limit: + try: + app_id = next( + iter( + a['appContainerId'] + for a in self.b.get(f'{self.b.base_url}/access/apps/') + if a['catalogAppDisplayName'].lower() == application_name + ) + ) + env_id = next( + iter( + e['environmentId'] + for e in self.b.get(f'{self.b.base_url}/access/apps/{app_id}/environments/') + if e['environmentName'].lower() == environment_name + or e['environmentId'] == environment_name + or e['alternateEnvironmentName'].lower() == environment_name + ) + ) + pap_id = next( + iter( + p['papId'] + for p in self.b.get(f'{self.b.base_url}/access/apps/{app_id}/environments/{env_id}/paps') + if p['papName'].lower() == profile_name + ) + ) + return {'profile_id': pap_id, 'environment_id': env_id} + except StopIteration: + pass raise click.ClickException('no profile found with the provided application, environment, and profile names') if len(found_profiles) > 1: raise click.ClickException('multiple matching profiles found - cannot determine which profile to use') From fed61a8afd15b720a3b22fe5b34129cee2c95e59 Mon Sep 17 00:00:00 2001 From: theborch Date: Mon, 10 Mar 2025 15:28:00 -0500 Subject: [PATCH 2/2] v2.1.0 --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ src/pybritive/__init__.py | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40fb60d..4252d78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,34 @@ > As of v1.4.0, release candidates will be published in an effort to get new features out faster while still allowing > time for full QA testing before moving the release candidate to a full release. +## v2.1.0 [2025-03-10] + +__What's New:__ + +* `pybritive-aws-cred-process` can now prompt users for `otp` or `justification` when needed. +* `my_resource` profile checkouts can now specify a `response_template` by appending `/{template name}` to the profile. +* Added "Global Settings" section to docs site. + +__Enhancements:__ + +* Added ITSM `--ticket-type` `--ticket-id` options. +* Additional `global` config settings: `my_[access|resources]_retrieval_limit` to limit size of retrieved items. + +__Bug Fixes:__ + +* Fixed missing `exceptions.StepUpAuthRequiredButNotProvided` catch during `checkout`. + +__Dependencies:__ + +* `britive>=4.1.2,<5.0` +* `colored>=2.2.5` + +__Other:__ + +* Python 3.8 is EOL, so support is dropped. +* Allow `_` uniformity for `auto_refresh_[kube_config|profile_cache]` in `global` config. +* Tests and Documentation updates for SDK alignment. + ## v2.1.0-rc.7 [2025-03-10] __What's New:__ diff --git a/src/pybritive/__init__.py b/src/pybritive/__init__.py index 1eb5a33..a33997d 100644 --- a/src/pybritive/__init__.py +++ b/src/pybritive/__init__.py @@ -1 +1 @@ -__version__ = '2.1.0-rc.7' +__version__ = '2.1.0'