# *************************************************************************
#
#  Copyright (c) 2026 - Datatailr Inc.
#  All Rights Reserved.
#
#  This file is part of Datatailr and subject to the terms and conditions
#  defined in 'LICENSE.txt'. Unauthorized copying and/or distribution
#  of this file, in parts or full, via any medium is strictly prohibited.
# *************************************************************************

"""
Datatailr - Python SDK
======================

The **datatailr** package provides a Python SDK for interacting with the Datatailr platform.

For a quickstart guide please launch the default workstation
on your installation and open the README file.

Datatailr provides a simple interface for scheduling and managing data tasks,
handling user access control, working with data blobs and secrets, and more.

"""

from datatailr.wrapper import dt__System, mock_cli_tool
from datatailr.group import Group
from datatailr.user import User
from datatailr.acl import ACL
from datatailr.acl import Permission
from datatailr.blob import Blob
from datatailr.build import Image
from datatailr.utils import Environment, is_dt_installed
from datatailr.version import __version__
from datatailr.kv import KV
from datatailr.scheduler import (
    App,
    Service,
    ExcelAddin,
    Resources,
    Workflow,
    workflow,
    Task,
    task,
    Schedule,
    set_allow_unsafe_scheduling,
)
from datatailr.secrets import Secrets

system = dt__System()


def __getattr__(name):
    if name == "__provider__":
        if isinstance(system, mock_cli_tool):
            provider = "not installed"
        else:
            try:
                provider = system.provider()
            except Exception as e:
                if "datatailr login" in str(e):
                    print(
                        "Please run 'datatailr login' outside of Python to authenticate."
                    )
                provider = "not installed"
        globals()[name] = provider
        return provider
    raise AttributeError(f"module 'datatailr' has no attribute {name!r}")


__all__ = [
    "ACL",
    "Permission",
    "Blob",
    "Environment",
    "Group",
    "Image",
    "User",
    "__version__",
    "__provider__",
    "is_dt_installed",
    "App",
    "Service",
    "ExcelAddin",
    "Resources",
    "workflow",
    "task",
    "Schedule",
    "set_allow_unsafe_scheduling",
    "Secrets",
    "KV",
    "Workflow",
    "Task",
]
