# 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 .raw_client import AsyncRawTracesClient, RawTracesClient
from .types.traces_create_request_resource_spans_item import (
    TracesCreateRequestResourceSpansItem,
)
from .types.traces_create_response import TracesCreateResponse

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


class TracesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTracesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawTracesClient
        """
        return self._raw_client

    def create(
        self,
        *,
        resource_spans: typing.Sequence[TracesCreateRequestResourceSpansItem],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TracesCreateResponse:
        """
        Parameters
        ----------
        resource_spans : typing.Sequence[TracesCreateRequestResourceSpansItem]

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

        Returns
        -------
        TracesCreateResponse
            Success

        Examples
        --------
        from mirascope.api._generated import Mirascope
        from mirascope.api._generated.traces import (
            TracesCreateRequestResourceSpansItem,
            TracesCreateRequestResourceSpansItemScopeSpansItem,
            TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem,
        )

        client = Mirascope()
        client.traces.create(
            resource_spans=[
                TracesCreateRequestResourceSpansItem(
                    scope_spans=[
                        TracesCreateRequestResourceSpansItemScopeSpansItem(
                            spans=[
                                TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem(
                                    trace_id="traceId",
                                    span_id="spanId",
                                    name="name",
                                    start_time_unix_nano="startTimeUnixNano",
                                    end_time_unix_nano="endTimeUnixNano",
                                )
                            ],
                        )
                    ],
                )
            ],
        )
        """
        _response = self._raw_client.create(
            resource_spans=resource_spans, request_options=request_options
        )
        return _response.data


class AsyncTracesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTracesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawTracesClient
        """
        return self._raw_client

    async def create(
        self,
        *,
        resource_spans: typing.Sequence[TracesCreateRequestResourceSpansItem],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> TracesCreateResponse:
        """
        Parameters
        ----------
        resource_spans : typing.Sequence[TracesCreateRequestResourceSpansItem]

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

        Returns
        -------
        TracesCreateResponse
            Success

        Examples
        --------
        import asyncio

        from mirascope.api._generated import AsyncMirascope
        from mirascope.api._generated.traces import (
            TracesCreateRequestResourceSpansItem,
            TracesCreateRequestResourceSpansItemScopeSpansItem,
            TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem,
        )

        client = AsyncMirascope()


        async def main() -> None:
            await client.traces.create(
                resource_spans=[
                    TracesCreateRequestResourceSpansItem(
                        scope_spans=[
                            TracesCreateRequestResourceSpansItemScopeSpansItem(
                                spans=[
                                    TracesCreateRequestResourceSpansItemScopeSpansItemSpansItem(
                                        trace_id="traceId",
                                        span_id="spanId",
                                        name="name",
                                        start_time_unix_nano="startTimeUnixNano",
                                        end_time_unix_nano="endTimeUnixNano",
                                    )
                                ],
                            )
                        ],
                    )
                ],
            )


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