MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / execute

Method execute

keepercommander/commands/msp.py:1090–1113  ·  view source on GitHub ↗
(self, params, **kwargs)

Source from the content-addressed store, hash-verified

1088 return msp_remove_parser
1089
1090 def execute(self, params, **kwargs):
1091 mc_input = kwargs.get('mc', '')
1092 if not mc_input:
1093 raise CommandError('msp-remove', 'Managed Company name or id is required')
1094 managed_companies = params.enterprise.get('managed_companies', [])
1095 current_mc = get_mc_by_name_or_id(managed_companies, mc_input)
1096 if not current_mc:
1097 raise CommandError('msp-remove', f'Managed Company \"{mc_input}\" not found')
1098 if kwargs.get('force') is True:
1099 answer = 'y'
1100 else:
1101 answer = user_choice(bcolors.FAIL + bcolors.BOLD + 'ALERT!\n' + bcolors.ENDC + 'Remove Managed Company.\n\n' +
1102 'Removing will expire the licences for the managed company and your admin access for the account.\n' +
1103 f'Managed Company Name: \"{current_mc["mc_enterprise_name"]}\", Licences: {current_mc["number_of_seats"]}\n\n' +
1104 'I want to remove these licences managed vault folder and my access to the admin console from my MSP account.', 'yn', 'n')
1105 if answer.lower() == 'y':
1106 rq = {
1107 'command': 'enterprise_remove_by_msp',
1108 'enterprise_id': current_mc['mc_enterprise_id']
1109 }
1110 rs = api.communicate(params, rq)
1111 if rs:
1112 logging.info('Managed company \"%s\" removed. ID=%d', current_mc['mc_enterprise_name'], current_mc['mc_enterprise_id'])
1113 api.query_enterprise(params)
1114
1115
1116def get_mc_by_name_or_id(msc, name_or_id):

Callers

nothing calls this directly

Calls 7

get_mc_by_name_or_idFunction · 0.85
user_choiceFunction · 0.85
communicateMethod · 0.80
CommandErrorClass · 0.70
getMethod · 0.45
infoMethod · 0.45
query_enterpriseMethod · 0.45

Tested by

no test coverage detected