(self, params, **kwargs)
| 316 | return msp_info_parser |
| 317 | |
| 318 | def execute(self, params, **kwargs): |
| 319 | report_format = kwargs.get('format') |
| 320 | output_file = kwargs.get('output') |
| 321 | if kwargs.get('restriction'): |
| 322 | permits = next((x['msp_permits'] for x in params.enterprise.get('licenses', []) if 'msp_permits' in x), None) |
| 323 | if permits: |
| 324 | all_products = {x[1].lower(): x[2] for x in constants.MSP_PLANS} |
| 325 | all_addons = {x[0].lower(): x[3] for x in constants.MSP_ADDONS} |
| 326 | all_file_plans = {x[1].lower(): x[2] for x in constants.MSP_FILE_PLANS} |
| 327 | max_file_plan = permits['max_file_plan_type'] |
| 328 | table = [ |
| 329 | ['Allow Unlimited Licenses', permits['allow_unlimited_licenses']], |
| 330 | ['Allowed Products', [x + f' ({all_products.get(x.lower(), "")})' for x in permits['allowed_mc_products']]], |
| 331 | ['Allowed Add-Ons', [x + f' ({all_addons.get(x.lower(), "")})' for x in permits['allowed_add_ons']]], |
| 332 | ['Max File Storage plan', all_file_plans.get(max_file_plan.lower(), max_file_plan)] |
| 333 | ] |
| 334 | return dump_report_data(table, ['Permit Name', 'Value'], fmt=report_format, filename=output_file) |
| 335 | else: |
| 336 | logging.info('MSP has no restrictions') |
| 337 | return |
| 338 | |
| 339 | if kwargs.get('pricing'): |
| 340 | pricing = MSPMixin.get_msp_pricing(params) |
| 341 | |
| 342 | header = ['category', 'name', 'code', 'price'] |
| 343 | table = [] |
| 344 | if 'mc_base_plans' in pricing: |
| 345 | plans = pricing['mc_base_plans'] |
| 346 | for plan in constants.MSP_PLANS: |
| 347 | code = plan[1] |
| 348 | if code in plans: |
| 349 | info = plans[code] |
| 350 | row = ['Product', plan[2], code, MSPMixin.price_text(info)] |
| 351 | table.append(row) |
| 352 | if 'mc_addons' in pricing: |
| 353 | addons = pricing['mc_addons'] |
| 354 | for addon in constants.MSP_ADDONS: |
| 355 | code = addon[0] |
| 356 | if code in addons: |
| 357 | info = addons[code] |
| 358 | row = ['Addon', addon[1], code, MSPMixin.price_text(info)] |
| 359 | table.append(row) |
| 360 | |
| 361 | if 'mc_file_plans' in pricing: |
| 362 | plans = pricing['mc_file_plans'] |
| 363 | for addon in constants.MSP_FILE_PLANS: |
| 364 | plan = addon[1] |
| 365 | if plan in plans: |
| 366 | info = plans[plan] |
| 367 | row = ['File Plan', addon[2], plan, MSPMixin.price_text(info)] |
| 368 | table.append(row) |
| 369 | if report_format != 'json': |
| 370 | header = [field_to_title(x) for x in header] |
| 371 | return dump_report_data(table, header, fmt=report_format, filename=output_file) |
| 372 | |
| 373 | if 'managed_companies' in params.enterprise: |
| 374 | sort_dict = {x[0]: i for i, x in enumerate(constants.MSP_ADDONS)} |
| 375 | verbose = kwargs.get('verbose') |
nothing calls this directly
no test coverage detected