# 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.inline_response_2009 import InlineResponse2009
from ..types.v_1_cargo_response import V1CargoResponse
from ..types.v_1_door_response import V1DoorResponse
from ..types.v_1_humidity_response import V1HumidityResponse
from ..types.v_1_sensor_history_response import V1SensorHistoryResponse
from ..types.v_1_sensors_history_series import V1SensorsHistorySeries
from ..types.v_1_temperature_response import V1TemperatureResponse
from .raw_client import AsyncRawSensorsClient, RawSensorsClient
from .types.inline_object_6_fill_missing import InlineObject6FillMissing

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


class SensorsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawSensorsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawSensorsClient
        """
        return self._raw_client

    def v_1_get_sensors_cargo(
        self, *, sensors: typing.Sequence[int], request_options: typing.Optional[RequestOptions] = None
    ) -> V1CargoResponse:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get cargo monitor status (empty / full) for requested sensors.

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

        Parameters
        ----------
        sensors : typing.Sequence[int]
            List of sensor IDs to query.

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

        Returns
        -------
        V1CargoResponse
            List of sensor objects containing the current cargo status reported by each sensor.

        Examples
        --------
        from samsara import Samsara

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.sensors.v_1_get_sensors_cargo(
            sensors=[122],
        )
        """
        _response = self._raw_client.v_1_get_sensors_cargo(sensors=sensors, request_options=request_options)
        return _response.data

    def v_1_get_sensors_door(
        self, *, sensors: typing.Sequence[int], request_options: typing.Optional[RequestOptions] = None
    ) -> V1DoorResponse:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get door monitor status (closed / open) for requested sensors.

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

        Parameters
        ----------
        sensors : typing.Sequence[int]
            List of sensor IDs to query.

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

        Returns
        -------
        V1DoorResponse
            List of sensor objects containing the current door status reported by each sensor.

        Examples
        --------
        from samsara import Samsara

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.sensors.v_1_get_sensors_door(
            sensors=[122],
        )
        """
        _response = self._raw_client.v_1_get_sensors_door(sensors=sensors, request_options=request_options)
        return _response.data

    def v_1_get_sensors_history(
        self,
        *,
        end_ms: int,
        series: typing.Sequence[V1SensorsHistorySeries],
        start_ms: int,
        step_ms: int,
        fill_missing: typing.Optional[InlineObject6FillMissing] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> V1SensorHistoryResponse:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get historical data for specified sensors. This method returns a set of historical data for the specified sensors in the specified time range and at the specified time resolution.

         <b>Rate limit:</b> 100 requests/min (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

        Parameters
        ----------
        end_ms : int
            End of the time range, specified in milliseconds UNIX time.

        series : typing.Sequence[V1SensorsHistorySeries]

        start_ms : int
            Beginning of the time range, specified in milliseconds UNIX time.

        step_ms : int
            Time resolution for which data should be returned, in milliseconds. Specifying 3600000 will return data at hour intervals.

        fill_missing : typing.Optional[InlineObject6FillMissing]

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

        Returns
        -------
        V1SensorHistoryResponse
            List of results objects, each containing a time and a datapoint for each requested sensor/field pair.

        Examples
        --------
        from samsara import Samsara, V1SensorsHistorySeries

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.sensors.v_1_get_sensors_history(
            end_ms=1462881998034,
            series=[
                V1SensorsHistorySeries(
                    field="ambientTemperature",
                    widget_id=1,
                )
            ],
            start_ms=1462878398034,
            step_ms=3600000,
        )
        """
        _response = self._raw_client.v_1_get_sensors_history(
            end_ms=end_ms,
            series=series,
            start_ms=start_ms,
            step_ms=step_ms,
            fill_missing=fill_missing,
            request_options=request_options,
        )
        return _response.data

    def v_1_get_sensors_humidity(
        self, *, sensors: typing.Sequence[int], request_options: typing.Optional[RequestOptions] = None
    ) -> V1HumidityResponse:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get humidity for requested sensors. This method returns the current relative humidity for the requested sensors.

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

        Parameters
        ----------
        sensors : typing.Sequence[int]
            List of sensor IDs to query.

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

        Returns
        -------
        V1HumidityResponse
            List of sensor objects containing the current humidity reported by each sensor.

        Examples
        --------
        from samsara import Samsara

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.sensors.v_1_get_sensors_humidity(
            sensors=[122],
        )
        """
        _response = self._raw_client.v_1_get_sensors_humidity(sensors=sensors, request_options=request_options)
        return _response.data

    def v_1_get_sensors(self, *, request_options: typing.Optional[RequestOptions] = None) -> InlineResponse2009:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get sensor objects. This method returns a list of the sensor objects in the Samsara Cloud and information about them.

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

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

        Returns
        -------
        InlineResponse2009
            List of sensor objects.

        Examples
        --------
        from samsara import Samsara

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.sensors.v_1_get_sensors()
        """
        _response = self._raw_client.v_1_get_sensors(request_options=request_options)
        return _response.data

    def v_1_get_sensors_temperature(
        self, *, sensors: typing.Sequence[int], request_options: typing.Optional[RequestOptions] = None
    ) -> V1TemperatureResponse:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get temperature for requested sensors. This method returns the current ambient temperature (and probe temperature if applicable) for the requested sensors.

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

        Parameters
        ----------
        sensors : typing.Sequence[int]
            List of sensor IDs to query.

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

        Returns
        -------
        V1TemperatureResponse
            List of sensor objects containing the current temperature reported by each sensor.

        Examples
        --------
        from samsara import Samsara

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.sensors.v_1_get_sensors_temperature(
            sensors=[122],
        )
        """
        _response = self._raw_client.v_1_get_sensors_temperature(sensors=sensors, request_options=request_options)
        return _response.data


class AsyncSensorsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawSensorsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawSensorsClient
        """
        return self._raw_client

    async def v_1_get_sensors_cargo(
        self, *, sensors: typing.Sequence[int], request_options: typing.Optional[RequestOptions] = None
    ) -> V1CargoResponse:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get cargo monitor status (empty / full) for requested sensors.

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

        Parameters
        ----------
        sensors : typing.Sequence[int]
            List of sensor IDs to query.

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

        Returns
        -------
        V1CargoResponse
            List of sensor objects containing the current cargo status reported by each sensor.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.sensors.v_1_get_sensors_cargo(
                sensors=[122],
            )


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

    async def v_1_get_sensors_door(
        self, *, sensors: typing.Sequence[int], request_options: typing.Optional[RequestOptions] = None
    ) -> V1DoorResponse:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get door monitor status (closed / open) for requested sensors.

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

        Parameters
        ----------
        sensors : typing.Sequence[int]
            List of sensor IDs to query.

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

        Returns
        -------
        V1DoorResponse
            List of sensor objects containing the current door status reported by each sensor.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.sensors.v_1_get_sensors_door(
                sensors=[122],
            )


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

    async def v_1_get_sensors_history(
        self,
        *,
        end_ms: int,
        series: typing.Sequence[V1SensorsHistorySeries],
        start_ms: int,
        step_ms: int,
        fill_missing: typing.Optional[InlineObject6FillMissing] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> V1SensorHistoryResponse:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get historical data for specified sensors. This method returns a set of historical data for the specified sensors in the specified time range and at the specified time resolution.

         <b>Rate limit:</b> 100 requests/min (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

        Parameters
        ----------
        end_ms : int
            End of the time range, specified in milliseconds UNIX time.

        series : typing.Sequence[V1SensorsHistorySeries]

        start_ms : int
            Beginning of the time range, specified in milliseconds UNIX time.

        step_ms : int
            Time resolution for which data should be returned, in milliseconds. Specifying 3600000 will return data at hour intervals.

        fill_missing : typing.Optional[InlineObject6FillMissing]

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

        Returns
        -------
        V1SensorHistoryResponse
            List of results objects, each containing a time and a datapoint for each requested sensor/field pair.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara, V1SensorsHistorySeries

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.sensors.v_1_get_sensors_history(
                end_ms=1462881998034,
                series=[
                    V1SensorsHistorySeries(
                        field="ambientTemperature",
                        widget_id=1,
                    )
                ],
                start_ms=1462878398034,
                step_ms=3600000,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.v_1_get_sensors_history(
            end_ms=end_ms,
            series=series,
            start_ms=start_ms,
            step_ms=step_ms,
            fill_missing=fill_missing,
            request_options=request_options,
        )
        return _response.data

    async def v_1_get_sensors_humidity(
        self, *, sensors: typing.Sequence[int], request_options: typing.Optional[RequestOptions] = None
    ) -> V1HumidityResponse:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get humidity for requested sensors. This method returns the current relative humidity for the requested sensors.

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

        Parameters
        ----------
        sensors : typing.Sequence[int]
            List of sensor IDs to query.

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

        Returns
        -------
        V1HumidityResponse
            List of sensor objects containing the current humidity reported by each sensor.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.sensors.v_1_get_sensors_humidity(
                sensors=[122],
            )


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

    async def v_1_get_sensors(self, *, request_options: typing.Optional[RequestOptions] = None) -> InlineResponse2009:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get sensor objects. This method returns a list of the sensor objects in the Samsara Cloud and information about them.

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

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

        Returns
        -------
        InlineResponse2009
            List of sensor objects.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.sensors.v_1_get_sensors()


        asyncio.run(main())
        """
        _response = await self._raw_client.v_1_get_sensors(request_options=request_options)
        return _response.data

    async def v_1_get_sensors_temperature(
        self, *, sensors: typing.Sequence[int], request_options: typing.Optional[RequestOptions] = None
    ) -> V1TemperatureResponse:
        """
        <n class="warning">
        <nh>
        <i class="fa fa-exclamation-circle"></i>
        This endpoint is still on our legacy API.
        </nh>
        </n>

        Get temperature for requested sensors. This method returns the current ambient temperature (and probe temperature if applicable) for the requested sensors.

         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        To use this endpoint, select **Write Sensors** under the Equipment category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>

        Parameters
        ----------
        sensors : typing.Sequence[int]
            List of sensor IDs to query.

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

        Returns
        -------
        V1TemperatureResponse
            List of sensor objects containing the current temperature reported by each sensor.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.sensors.v_1_get_sensors_temperature(
                sensors=[122],
            )


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