(self, params, **kwargs)
| 287 | return switch_to_mc_parser |
| 288 | |
| 289 | def execute(self, params, **kwargs): |
| 290 | global current_mc_id, msp_params |
| 291 | if current_mc_id is not None: |
| 292 | raise CommandError('switch-to-mc', |
| 293 | f"Already switched to Managed Company id={current_mc_id}") |
| 294 | |
| 295 | managed_companies = params.enterprise['managed_companies'] |
| 296 | mc_input = kwargs.get('mc') |
| 297 | current_mc = get_mc_by_name_or_id(managed_companies, mc_input) |
| 298 | if not current_mc: |
| 299 | raise CommandError('switch-to-mc', f'Managed Company \"{mc_input}\" not found') |
| 300 | |
| 301 | current_mc_id = current_mc['mc_enterprise_id'] |
| 302 | |
| 303 | if current_mc_id not in mc_params_dict: |
| 304 | mc_params = api.login_and_get_mc_params_login_v3(params, current_mc_id) |
| 305 | mc_params_dict[current_mc_id] = mc_params |
| 306 | else: |
| 307 | mc_params = mc_params_dict[current_mc_id] |
| 308 | api.query_enterprise(mc_params) |
| 309 | |
| 310 | msp_params = params |
| 311 | logging.info("Switched to MC '%s'", current_mc['mc_enterprise_name']) |
| 312 | |
| 313 | |
| 314 | class MSPInfoCommand(EnterpriseCommand, MSPMixin): |
nothing calls this directly
no test coverage detected