'BETA function for uploading/overwriting dashboards to Plotly.
:param (dict) dashboard: the JSON dashboard to be uploaded. Use
plotly.dashboard_objs.dashboard_objs to create a Dashboard
object.
:param (str) filename: the name of the dashboard to be saved in
your Plotly account. Will overwrite a dashboard of the same
name if it already exists in your files.
:param (str) sharing: can be set to either \'public\', \'private\'
or \'secret\'. If \'public\', your dashboard will be viewable by
all other users. If \'private\' only you can see your dashboard.
If \'secret\', the url will be returned with a sharekey appended
to the url. Anyone with the url may view the dashboard.
:param (bool) auto_open: automatically opens the dashboard in the
browser.'

@classmethod
def upload(cls, dashboard, filename, sharing='public', auto_open=True):

    if (sharing == 'public'):
        world_readable = True
    elif (sharing == 'private'):
        world_readable = False
    elif (sharing == 'secret'):
        world_readable = False
    data = {'content': json.dumps(dashboard), 'filename': filename, 'world_readable': world_readable}
    try:
        lookup_res = v2.files.lookup(filename)
        matching_file = json.loads(lookup_res.content)
        if (matching_file['filetype'] == 'dashboard'):
            old_fid = matching_file['fid']
            res = v2.dashboards.update(old_fid, data)
        else:
            raise exceptions.PlotlyError("'{filename}'    is    already    a    {filetype}    in    your    account.    While    you    can    overwrite    dashboards    with    the    same    name,    you    can't    change    overwrite    files    with    a    different    type.    Try    deleting    '{filename}'    in    your    account    or    changing    the    filename.".format(filename=filename, filetype=matching_file['filetype']))
    except exceptions.PlotlyRequestError:
        res = v2.dashboards.create(data)
    res.raise_for_status()
    url = res.json()['web_url']
    if (sharing == 'secret'):
        url = add_share_key_to_url(url)
    if auto_open:
        webbrowser.open_new(res.json()['web_url'])
    return url
