Source code for cfme.generic_objects.definition.associations

# -*- coding: utf-8 -*-

# TODO: add more association types
_ASSOCIATION_TYPES_MAPPING = {
    'Service': {'rest_collection': 'services'},
    'Vms': {'rest_collection': 'vms'},
}


[docs]def get_rest_resource(appliance, association_type, resource): mapping = _ASSOCIATION_TYPES_MAPPING.get(association_type) if not mapping: raise NotImplementedError('Mapping is not implemented for `{}`.'.format(association_type)) rest_collection = getattr(appliance.rest_api.collections, mapping['rest_collection']) return rest_collection.find_by(name=resource.name)