def upgrade(account):
    """Transforms data from a v1 format to a v2 format"""
    environ = 'test'
    if 'prod' in account['tags']:
        environ = 'prod'
    owner = 'netflix'
    if not account['ours']:
        owner = 'third-party'
    services = []
    if account['metadata'].get('s3_name'):
        services.append(dict(name='s3', metadata=dict(name=account[
            'metadata']['s3_name']), status=[dict(region='all', enabled=True)])
            )
    if account['metadata'].get('cloudtrail_index'):
        services.append(dict(name='cloudtrail', metadata=dict(esIndex=
            account['metadata']['cloudtrail_index'], kibanaUrl=account[
            'metadata']['cloudtrail_kibana_url']), status=[dict(region=
            'all', enabled=True)]))
    if account.get('bastion'):
        services.append(dict(name='bastion', metadata=dict(hostname=account
            ['bastion']), status=[dict(region='all', enabled=True)]))
    for service in account['services'].keys():
        s = dict(name=service, status=[dict(region='all', enabled=account[
            'services'][service].get('enabled', True))])
        if service == 'spinnaker':
            s['metadata'] = {'name': account['services'][service]['name']}
        if service == 'lazyfalcon':
            if account['services'][service].get('owner'):
                s['metadata'] = {'owner': account['services'][service]['owner']
                    }
        if service == 'titus':
            s['metadata'] = {'stacks': account['services'][service]['stacks']}
        services.append(s)
    if account['metadata'].get('project_id'):
        item_id = account['metadata']['project_id']
    elif account['metadata'].get('account_number'):
        item_id = account['metadata']['account_number']
    else:
        raise Exception('No id found, are you sure this is in v1 swag format.')
    status = []
    if account['type'] == 'aws':
        status = [{'region': 'us-east-1', 'status': 'ready'}, {'region':
            'us-west-2', 'status': 'ready'}, {'region': 'eu-west-1',
            'status': 'ready'}, {'region': 'us-east-2', 'status':
            'in-active'}, {'region': 'us-west-1', 'status': 'in-active'}, {
            'region': 'ca-central-1', 'status': 'in-active'}, {'region':
            'ap-south-1', 'status': 'in-active'}, {'region':
            'ap-northeast-2', 'status': 'in-active'}, {'region':
            'ap-northeast-1', 'status': 'in-active'}, {'region':
            'ap-southeast-1', 'status': 'in-active'}, {'region':
            'ap-southeast-2', 'status': 'in-active'}, {'region':
            'eu-west-2', 'status': 'in-active'}, {'region': 'eu-central-1',
            'status': 'in-active'}, {'region': 'sa-east-1', 'status':
            'in-active'}]
    return dict(id=item_id, email=account['metadata'].get('email'), name=
        account['name'], contacts=account['owners'], provider=account[
        'type'], status=status, tags=list(set(account['tags'])),
        environment=environ, description=account['description'], sensitive=
        account['cmc_required'], owner=owner, aliases=account['alias'],
        services=services, account_status=account['account_status'])
