"""
This type stub file was generated by pyright.
"""

import temporalio.service
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Mapping, Optional, Union
from typing_extensions import TypeAlias, TypedDict

"""Environment and file-based configuration for Temporal clients.

This module provides utilities to load Temporal client configuration from TOML files
and environment variables.
"""
DataSource: TypeAlias = Union[Path, str, bytes]
class ClientConfigTLSDict(TypedDict, total=False):
    """Dictionary representation of TLS config for TOML."""
    disabled: bool
    server_name: str
    server_ca_cert: Mapping[str, str]
    client_cert: Mapping[str, str]
    client_key: Mapping[str, str]
    ...


class ClientConfigProfileDict(TypedDict, total=False):
    """Dictionary representation of a client config profile for TOML."""
    address: str
    namespace: str
    api_key: str
    tls: ClientConfigTLSDict
    grpc_meta: Mapping[str, str]
    ...


@dataclass(frozen=True)
class ClientConfigTLS:
    """TLS configuration as specified as part of client configuration

    .. warning::
        Experimental API.
    """
    disabled: bool = ...
    server_name: Optional[str] = ...
    server_root_ca_cert: Optional[DataSource] = ...
    client_cert: Optional[DataSource] = ...
    client_private_key: Optional[DataSource] = ...
    def to_dict(self) -> ClientConfigTLSDict:
        """Convert to a dictionary that can be used for TOML serialization."""
        ...
    
    def to_connect_tls_config(self) -> Union[bool, temporalio.service.TLSConfig]:
        """Create a `temporalio.service.TLSConfig` from this profile."""
        ...
    
    @staticmethod
    def from_dict(d: Optional[ClientConfigTLSDict]) -> Optional[ClientConfigTLS]:
        """Create a ClientConfigTLS from a dictionary."""
        ...
    


class ClientConnectConfig(TypedDict, total=False):
    """Arguments for `temporalio.client.Client.connect` that are configurable via
    environment configuration.

    .. warning::
        Experimental API.
    """
    target_host: str
    namespace: str
    api_key: str
    tls: Union[bool, temporalio.service.TLSConfig]
    rpc_metadata: Mapping[str, str]
    ...


@dataclass(frozen=True)
class ClientConfigProfile:
    """Represents a client configuration profile.

    This class holds the configuration as loaded from a file or environment.
    See `to_connect_config` to transform the profile to `ClientConnectConfig`,
    which can be used to create a client.

    .. warning::
        Experimental API.
    """
    address: Optional[str] = ...
    namespace: Optional[str] = ...
    api_key: Optional[str] = ...
    tls: Optional[ClientConfigTLS] = ...
    grpc_meta: Mapping[str, str] = ...
    @staticmethod
    def from_dict(d: ClientConfigProfileDict) -> ClientConfigProfile:
        """Create a ClientConfigProfile from a dictionary."""
        ...
    
    def to_dict(self) -> ClientConfigProfileDict:
        """Convert to a dictionary that can be used for TOML serialization."""
        ...
    
    def to_client_connect_config(self) -> ClientConnectConfig:
        """Create a `ClientConnectConfig` from this profile."""
        ...
    
    @staticmethod
    def load(profile: Optional[str] = ..., *, config_source: Optional[DataSource] = ..., disable_file: bool = ..., disable_env: bool = ..., config_file_strict: bool = ..., override_env_vars: Optional[Mapping[str, str]] = ...) -> ClientConfigProfile:
        """Load a single client profile from given sources, applying env
        overrides.

        To get a :py:class:`ClientConnectConfig`, use the
        :py:meth:`to_client_connect_config` method on the returned profile.

        Args:
            profile: Profile to load from the config.
            config_source: If present, this is used as the configuration source
                instead of default file locations. This can be a path to the file
                or the string/byte contents of the file.
            disable_file: If true, file loading is disabled. This is only used
                when ``config_source`` is not present.
            disable_env: If true, environment variable loading and overriding
                is disabled. This takes precedence over the ``override_env_vars``
                parameter.
            config_file_strict: If true, will error on unrecognized keys.
            override_env_vars: The environment to use for loading and overrides.
                If not provided, the current process's environment is used. To
                use a specific set of environment variables, provide them here.
                To disable environment variable loading, set ``disable_env`` to
                true.

        Returns:
            The client configuration profile.
        """
        ...
    


@dataclass
class ClientConfig:
    """Client configuration loaded from TOML and environment variables.

    This contains a mapping of profile names to client profiles. Use
    `ClientConfigProfile.to_connect_config` to create a `ClientConnectConfig`
    from a profile. See `load_profile` to load an individual profile.

    .. warning::
        Experimental API.
    """
    profiles: Mapping[str, ClientConfigProfile]
    def to_dict(self) -> Mapping[str, ClientConfigProfileDict]:
        """Convert to a dictionary that can be used for TOML serialization."""
        ...
    
    @staticmethod
    def from_dict(d: Mapping[str, Mapping[str, Any]]) -> ClientConfig:
        """Create a ClientConfig from a dictionary."""
        ...
    
    @staticmethod
    def load(*, config_source: Optional[DataSource] = ..., disable_file: bool = ..., config_file_strict: bool = ..., override_env_vars: Optional[Mapping[str, str]] = ...) -> ClientConfig:
        """Load all client profiles from given sources.

        This does not apply environment variable overrides to the profiles, it
        only uses an environment variable to find the default config file path
        (``TEMPORAL_CONFIG_FILE``). To get a single profile with environment variables
        applied, use :py:meth:`ClientConfigProfile.load`.

        Args:
            config_source: If present, this is used as the configuration source
                instead of default file locations. This can be a path to the file
                or the string/byte contents of the file.
            disable_file: If true, file loading is disabled. This is only used
                when ``config_source`` is not present.
            config_file_strict: If true, will TOML file parsing will error on
                unrecognized keys.
            override_env_vars: The environment variables to use for locating the
                default config file. If not provided, the current process's
                environment is used to check for ``TEMPORAL_CONFIG_FILE``. To
                use a specific set of environment variables, provide them here.
                To disable environment variable loading, set ``disable_file`` to
                true or pass an empty dictionary for this parameter.
        """
        ...
    
    @staticmethod
    def load_client_connect_config(profile: Optional[str] = ..., *, config_file: Optional[str] = ..., disable_file: bool = ..., disable_env: bool = ..., config_file_strict: bool = ..., override_env_vars: Optional[Mapping[str, str]] = ...) -> ClientConnectConfig:
        """Load a single client profile and convert to connect config.

        This is a convenience function that combines loading a profile and
        converting it to a connect config dictionary. This will use the current
        process's environment for overrides unless disabled.

        Args:
            profile: The profile to load from the config. Defaults to "default".
            config_file: Path to a specific TOML config file. If not provided,
                default file locations are used. This is ignored if
                ``disable_file`` is true.
            disable_file: If true, file loading is disabled.
            disable_env: If true, environment variable loading and overriding
                is disabled.
            config_file_strict: If true, will error on unrecognized keys in the
                TOML file.
            override_env_vars: A dictionary of environment variables to use for
                loading and overrides. If not provided, the current process's
                environment is used. To use a specific set of environment
                variables, provide them here. To disable environment variable
                loading, set ``disable_env`` to true.

        Returns:
            TypedDict of keyword arguments for
            :py:meth:`temporalio.client.Client.connect`.
        """
        ...
    


