import json
import click


def upload_config(mwdb, family, config_file, config_type, parent, private, public, share_with):
    """Upload config object"""
    with click.open_file(config_file, 'rb') as f:
        content = json.loads(f.read())
    obj = mwdb.upload_config(
        family=family,
        cfg=content,
        config_type=config_type,
        parent=parent,
        private=private,
        public=public,
        share_with=share_with
    )
    return dict(message="Uploaded config {object_id}",
                object_id=obj.id)