# Copyright (c) 2022 CloudZero - ALL RIGHTS RESERVED - PROPRIETARY AND CONFIDENTIAL
# Unauthorized copying of this file and/or project, via any medium is strictly prohibited.
# Direct all questions to legal@cloudzero.com
import os
from datetime import datetime
from enum import Enum
from typing import NamedTuple, Optional, List

import czc.internal_api.client as client

FEATURE_INSIGHTS_IAPI = {
    'namespace': lambda _: os.environ.get('BILLING_CONNECTIONS_NAMESPACE') or os.environ['NAMESPACE'],
    'feature': 'billing-connections',
    'account_id': lambda: os.environ.get('CORE_ACCOUNT_ID')
}


class CloudProvider(Enum):
    aws = 'AWS'
    snowflake = 'Snowflake'


class CloudAccountInfo(NamedTuple):
    cz_organization_id: str
    cloud_account_id: str
    cloud_provider: str
    role_arn: str
    external_id: str
    bucket_name: str
    bucket_path: str
    provisioning_process: Optional[str]
    is_enabled: bool
    creation_date: Optional[datetime]
    metadata: dict


@client.invoked(**FEATURE_INSIGHTS_IAPI, api='sync-connections')
def sync_connections(accounts: List[CloudAccountInfo]):
    pass
