'ensure that parameters which conditionally required are present'

def _check_required_if(self, spec, param=None):

    if (spec is None):
        return
    if (param is None):
        param = self.params
    for sp in spec:
        missing = []
        max_missing_count = 0
        is_one_of = False
        if (len(sp) == 4):
            (key, val, requirements, is_one_of) = sp
        else:
            (key, val, requirements) = sp
        if is_one_of:
            max_missing_count = len(requirements)
        if ((key in param) and (param[key] == val)):
            for check in requirements:
                count = self._count_terms((check,), param)
                if (count == 0):
                    missing.append(check)
        if (len(missing) and (len(missing) >= max_missing_count)):
            msg = ('%s    is    %s    but    the    following    are    missing:    %s' % (key, val, ','.join(missing)))
            if self._options_context:
                msg += ('    found    in    %s' % '    ->    '.join(self._options_context))
            self.fail_json(msg=msg)
