@exceptions_handled
    @marshal_with(responses_v2_1.MaintenanceMode)
    def post(self, maintenance_action, **_):
        maintenance_file_path = get_maintenance_file_path()

        if maintenance_action == 'activate':
            if os.path.isfile(maintenance_file_path):
                state = utils.read_json_file(maintenance_file_path)
                return state, 304

            now = str(datetime.now())

            try:
                user = rest_security.get_username()
            except __HOLE__:
                user = ''

            remaining_executions = get_running_executions()
            utils.mkdirs(config.instance().maintenance_folder)
            new_state = prepare_maintenance_dict(
                    status=MAINTENANCE_MODE_ACTIVATING,
                    activation_requested_at=now,
                    remaining_executions=remaining_executions,
                    requested_by=user)
            utils.write_dict_to_json_file(maintenance_file_path, new_state)

            return new_state

        if maintenance_action == 'deactivate':
            if not os.path.isfile(maintenance_file_path):
                return prepare_maintenance_dict(
                        MAINTENANCE_MODE_DEACTIVATED), 304
            os.remove(maintenance_file_path)
            return prepare_maintenance_dict(MAINTENANCE_MODE_DEACTIVATED)

        valid_actions = ['activate', 'deactivate']
        raise BadParametersError(
                'Invalid action: {0}, Valid action '
                'values are: {1}'.format(maintenance_action, valid_actions))
dataset/ETHPy150Open cloudify-cosmo/cloudify-manager/rest-service/manager_rest/resources_v2_1.py/MaintenanceModeAction.post