Extract the path variables from an Resource operation.

    Return {'mandatory': [<list-of-pnames>], 'optional': [<list-of-pnames>]}

def extract_pathvars(callback):
    '''Extract the path variables from an Resource operation.

    Return {'mandatory': [<list-of-pnames>], 'optional': [<list-of-pnames>]}
    '''
    mandatory = []
    optional = []
    # We loop on the signature because the order of the parameters is
    # important, and signature is an OrderedDict, while annotations is a
    # regular dictionary
    for pname in callback.signature.parameters.keys():
        try:
            anno = callback.__annotations__[pname]
        except KeyError:  # unannotated params, like "cls" or "request"
            continue
        if anno[0] != Ptypes.path:
            continue
        # At this point we are only considering path variables, but
        # we have to generate different (present/absent) if these
        # parameters have a default.
        if callback.signature.parameters[pname].default == inspect._empty:
            mandatory.append(pname)
        else:
            optional.append(pname)
    return {'mandatory': mandatory, 'optional': optional}