# This file was auto-generated by Fern from our API Definition.

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.metrics_ingestion_response import MetricsIngestionResponse
from ..types.trace_ingestion_response import TraceIngestionResponse
from .raw_client import AsyncRawTelemetryClient, RawTelemetryClient

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class TelemetryClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTelemetryClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawTelemetryClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawTelemetryClient
        """
        return self._raw_client

    def agent_metrics_ingest(
        self,
        *,
        resource_metrics: typing.Sequence[typing.Dict[str, typing.Any]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MetricsIngestionResponse:
        """
        Ingest OpenTelemetry metrics from an agent. Requires agent API key authentication.

        Parameters
        ----------
        resource_metrics : typing.Sequence[typing.Dict[str, typing.Any]]
            Array of ResourceMetrics as per OTLP JSON format

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        MetricsIngestionResponse
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.telemetry.agent_metrics_ingest(
            resource_metrics=[{"key": "value"}],
        )
        """
        _response = self._raw_client.agent_metrics_ingest(
            resource_metrics=resource_metrics, request_options=request_options
        )
        return _response.data

    def traces_ingest(
        self,
        *,
        resource_spans: typing.Sequence[typing.Dict[str, typing.Any]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TraceIngestionResponse:
        """
        Ingest OpenTelemetry traces from an agent. Requires agent API key authentication.

        Parameters
        ----------
        resource_spans : typing.Sequence[typing.Dict[str, typing.Any]]
            Array of ResourceSpans as per OTLP JSON format

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        TraceIngestionResponse
            Successful Response

        Examples
        --------
        from terminaluse import TerminalUseBase

        client = TerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.telemetry.traces_ingest(
            resource_spans=[{"key": "value"}],
        )
        """
        _response = self._raw_client.traces_ingest(resource_spans=resource_spans, request_options=request_options)
        return _response.data


class AsyncTelemetryClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTelemetryClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawTelemetryClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawTelemetryClient
        """
        return self._raw_client

    async def agent_metrics_ingest(
        self,
        *,
        resource_metrics: typing.Sequence[typing.Dict[str, typing.Any]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> MetricsIngestionResponse:
        """
        Ingest OpenTelemetry metrics from an agent. Requires agent API key authentication.

        Parameters
        ----------
        resource_metrics : typing.Sequence[typing.Dict[str, typing.Any]]
            Array of ResourceMetrics as per OTLP JSON format

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        MetricsIngestionResponse
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.telemetry.agent_metrics_ingest(
                resource_metrics=[{"key": "value"}],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.agent_metrics_ingest(
            resource_metrics=resource_metrics, request_options=request_options
        )
        return _response.data

    async def traces_ingest(
        self,
        *,
        resource_spans: typing.Sequence[typing.Dict[str, typing.Any]],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TraceIngestionResponse:
        """
        Ingest OpenTelemetry traces from an agent. Requires agent API key authentication.

        Parameters
        ----------
        resource_spans : typing.Sequence[typing.Dict[str, typing.Any]]
            Array of ResourceSpans as per OTLP JSON format

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        TraceIngestionResponse
            Successful Response

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminalUseBase

        client = AsyncTerminalUseBase(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.telemetry.traces_ingest(
                resource_spans=[{"key": "value"}],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.traces_ingest(resource_spans=resource_spans, request_options=request_options)
        return _response.data
