# 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.assets_location_link_request_config_object import AssetsLocationLinkRequestConfigObject
from ..types.assets_near_location_link_config_object import AssetsNearLocationLinkConfigObject
from ..types.assets_on_route_link_config_object import AssetsOnRouteLinkConfigObject
from ..types.live_sharing_links_create_live_sharing_link_response_body import (
    LiveSharingLinksCreateLiveSharingLinkResponseBody,
)
from ..types.live_sharing_links_get_live_sharing_links_response_body import (
    LiveSharingLinksGetLiveSharingLinksResponseBody,
)
from ..types.live_sharing_links_update_live_sharing_link_response_body import (
    LiveSharingLinksUpdateLiveSharingLinkResponseBody,
)
from .raw_client import AsyncRawLiveSharingLinksClient, RawLiveSharingLinksClient
from .types.get_live_sharing_links_request_type import GetLiveSharingLinksRequestType
from .types.live_sharing_links_create_live_sharing_link_request_body_type import (
    LiveSharingLinksCreateLiveSharingLinkRequestBodyType,
)

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


class LiveSharingLinksClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawLiveSharingLinksClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawLiveSharingLinksClient
        """
        return self._raw_client

    def get_live_sharing_links(
        self,
        *,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        type: typing.Optional[GetLiveSharingLinksRequestType] = None,
        limit: typing.Optional[int] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LiveSharingLinksGetLiveSharingLinksResponseBody:
        """
        Returns all non-expired Live Sharing Links.

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

        To use this endpoint, select **Read Live Sharing Links** under the Driver Workflow 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>


         **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.

        Parameters
        ----------
        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A filter on the data based on this comma-separated list of Live Share Link IDs

        type : typing.Optional[GetLiveSharingLinksRequestType]
            A filter on the data based on the Live Sharing Link type.  Valid values: `all`, `assetsLocation`, `assetsNearLocation`, `assetsOnRoute`

        limit : typing.Optional[int]
            The limit for how many objects will be in the response. Default and max for this value is 100 objects.

        after : typing.Optional[str]
             If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.

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

        Returns
        -------
        LiveSharingLinksGetLiveSharingLinksResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.live_sharing_links.get_live_sharing_links()
        """
        _response = self._raw_client.get_live_sharing_links(
            ids=ids, type=type, limit=limit, after=after, request_options=request_options
        )
        return _response.data

    def create_live_sharing_link(
        self,
        *,
        name: str,
        type: LiveSharingLinksCreateLiveSharingLinkRequestBodyType,
        assets_location_link_config: typing.Optional[AssetsLocationLinkRequestConfigObject] = OMIT,
        assets_near_location_link_config: typing.Optional[AssetsNearLocationLinkConfigObject] = OMIT,
        assets_on_route_link_config: typing.Optional[AssetsOnRouteLinkConfigObject] = OMIT,
        description: typing.Optional[str] = OMIT,
        expires_at_time: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LiveSharingLinksCreateLiveSharingLinkResponseBody:
        """
        Create Live Sharing Link.

         <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>).

        To use this endpoint, select **Write Live Sharing Links** under the Driver Workflow 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>


         **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.

        Parameters
        ----------
        name : str
            Name of the Live Sharing Link.

        type : LiveSharingLinksCreateLiveSharingLinkRequestBodyType
            Type of the Live Sharing Link. This field specifies which one of '<type>LinkConfig' objects will be used to configure the sharing link.  Valid values: `assetsLocation`, `assetsNearLocation`, `assetsOnRoute`

        assets_location_link_config : typing.Optional[AssetsLocationLinkRequestConfigObject]

        assets_near_location_link_config : typing.Optional[AssetsNearLocationLinkConfigObject]

        assets_on_route_link_config : typing.Optional[AssetsOnRouteLinkConfigObject]

        description : typing.Optional[str]
            Description for the Live Sharing Link (not applicable for 'assetsOnRoute' type).

        expires_at_time : typing.Optional[str]
            Date that this link expires in RFC 3339 format. Can't be set in the past. If not provided then link will never expire.

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

        Returns
        -------
        LiveSharingLinksCreateLiveSharingLinkResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.live_sharing_links.create_live_sharing_link(
            name="Example Live Sharing Link name",
            type="assetsLocation",
        )
        """
        _response = self._raw_client.create_live_sharing_link(
            name=name,
            type=type,
            assets_location_link_config=assets_location_link_config,
            assets_near_location_link_config=assets_near_location_link_config,
            assets_on_route_link_config=assets_on_route_link_config,
            description=description,
            expires_at_time=expires_at_time,
            request_options=request_options,
        )
        return _response.data

    def delete_live_sharing_link(self, *, id: str, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Delete Live Sharing Link.

         <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>).

        To use this endpoint, select **Write Live Sharing Links** under the Driver Workflow 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>


         **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.

        Parameters
        ----------
        id : str
            Unique identifier for the Live Sharing Link.

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

        Returns
        -------
        None

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.live_sharing_links.delete_live_sharing_link(
            id="id",
        )
        """
        _response = self._raw_client.delete_live_sharing_link(id=id, request_options=request_options)
        return _response.data

    def update_live_sharing_link(
        self,
        *,
        id: str,
        name: str,
        description: typing.Optional[str] = OMIT,
        expires_at_time: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LiveSharingLinksUpdateLiveSharingLinkResponseBody:
        """
        Update Live Sharing Link.

         <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>).

        To use this endpoint, select **Write Live Sharing Links** under the Driver Workflow 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>


         **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.

        Parameters
        ----------
        id : str
            Unique identifier for the Live Sharing Link.

        name : str
            Name of the Live Sharing Link.

        description : typing.Optional[str]
            Description for the Live Sharing Link (not applicable for 'assetsOnRoute' type).

        expires_at_time : typing.Optional[str]
            Date that this link expires in RFC 3339 format. Can't be set in the past. If not provided then link will never expire.

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

        Returns
        -------
        LiveSharingLinksUpdateLiveSharingLinkResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.live_sharing_links.update_live_sharing_link(
            id="id",
            name="Example Live Sharing Link name",
        )
        """
        _response = self._raw_client.update_live_sharing_link(
            id=id, name=name, description=description, expires_at_time=expires_at_time, request_options=request_options
        )
        return _response.data


class AsyncLiveSharingLinksClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawLiveSharingLinksClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawLiveSharingLinksClient
        """
        return self._raw_client

    async def get_live_sharing_links(
        self,
        *,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        type: typing.Optional[GetLiveSharingLinksRequestType] = None,
        limit: typing.Optional[int] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LiveSharingLinksGetLiveSharingLinksResponseBody:
        """
        Returns all non-expired Live Sharing Links.

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

        To use this endpoint, select **Read Live Sharing Links** under the Driver Workflow 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>


         **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.

        Parameters
        ----------
        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A filter on the data based on this comma-separated list of Live Share Link IDs

        type : typing.Optional[GetLiveSharingLinksRequestType]
            A filter on the data based on the Live Sharing Link type.  Valid values: `all`, `assetsLocation`, `assetsNearLocation`, `assetsOnRoute`

        limit : typing.Optional[int]
            The limit for how many objects will be in the response. Default and max for this value is 100 objects.

        after : typing.Optional[str]
             If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.

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

        Returns
        -------
        LiveSharingLinksGetLiveSharingLinksResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.live_sharing_links.get_live_sharing_links()


        asyncio.run(main())
        """
        _response = await self._raw_client.get_live_sharing_links(
            ids=ids, type=type, limit=limit, after=after, request_options=request_options
        )
        return _response.data

    async def create_live_sharing_link(
        self,
        *,
        name: str,
        type: LiveSharingLinksCreateLiveSharingLinkRequestBodyType,
        assets_location_link_config: typing.Optional[AssetsLocationLinkRequestConfigObject] = OMIT,
        assets_near_location_link_config: typing.Optional[AssetsNearLocationLinkConfigObject] = OMIT,
        assets_on_route_link_config: typing.Optional[AssetsOnRouteLinkConfigObject] = OMIT,
        description: typing.Optional[str] = OMIT,
        expires_at_time: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LiveSharingLinksCreateLiveSharingLinkResponseBody:
        """
        Create Live Sharing Link.

         <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>).

        To use this endpoint, select **Write Live Sharing Links** under the Driver Workflow 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>


         **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.

        Parameters
        ----------
        name : str
            Name of the Live Sharing Link.

        type : LiveSharingLinksCreateLiveSharingLinkRequestBodyType
            Type of the Live Sharing Link. This field specifies which one of '<type>LinkConfig' objects will be used to configure the sharing link.  Valid values: `assetsLocation`, `assetsNearLocation`, `assetsOnRoute`

        assets_location_link_config : typing.Optional[AssetsLocationLinkRequestConfigObject]

        assets_near_location_link_config : typing.Optional[AssetsNearLocationLinkConfigObject]

        assets_on_route_link_config : typing.Optional[AssetsOnRouteLinkConfigObject]

        description : typing.Optional[str]
            Description for the Live Sharing Link (not applicable for 'assetsOnRoute' type).

        expires_at_time : typing.Optional[str]
            Date that this link expires in RFC 3339 format. Can't be set in the past. If not provided then link will never expire.

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

        Returns
        -------
        LiveSharingLinksCreateLiveSharingLinkResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.live_sharing_links.create_live_sharing_link(
                name="Example Live Sharing Link name",
                type="assetsLocation",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_live_sharing_link(
            name=name,
            type=type,
            assets_location_link_config=assets_location_link_config,
            assets_near_location_link_config=assets_near_location_link_config,
            assets_on_route_link_config=assets_on_route_link_config,
            description=description,
            expires_at_time=expires_at_time,
            request_options=request_options,
        )
        return _response.data

    async def delete_live_sharing_link(
        self, *, id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete Live Sharing Link.

         <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>).

        To use this endpoint, select **Write Live Sharing Links** under the Driver Workflow 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>


         **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.

        Parameters
        ----------
        id : str
            Unique identifier for the Live Sharing Link.

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.live_sharing_links.delete_live_sharing_link(
                id="id",
            )


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

    async def update_live_sharing_link(
        self,
        *,
        id: str,
        name: str,
        description: typing.Optional[str] = OMIT,
        expires_at_time: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> LiveSharingLinksUpdateLiveSharingLinkResponseBody:
        """
        Update Live Sharing Link.

         <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>).

        To use this endpoint, select **Write Live Sharing Links** under the Driver Workflow 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>


         **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.

        Parameters
        ----------
        id : str
            Unique identifier for the Live Sharing Link.

        name : str
            Name of the Live Sharing Link.

        description : typing.Optional[str]
            Description for the Live Sharing Link (not applicable for 'assetsOnRoute' type).

        expires_at_time : typing.Optional[str]
            Date that this link expires in RFC 3339 format. Can't be set in the past. If not provided then link will never expire.

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

        Returns
        -------
        LiveSharingLinksUpdateLiveSharingLinkResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.live_sharing_links.update_live_sharing_link(
                id="id",
                name="Example Live Sharing Link name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_live_sharing_link(
            id=id, name=name, description=description, expires_at_time=expires_at_time, request_options=request_options
        )
        return _response.data
