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

import typing
from json.decoder import JSONDecodeError

from ..core.api_error import ApiError
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.http_response import AsyncHttpResponse, HttpResponse
from ..core.jsonable_encoder import jsonable_encoder
from ..core.pydantic_utilities import parse_obj_as
from ..core.request_options import RequestOptions
from ..core.serialization import convert_and_respect_annotation_metadata
from ..types.attribute_expanded_response import AttributeExpandedResponse
from ..types.create_attribute_request_entities import CreateAttributeRequestEntities
from ..types.get_attributes_by_entity_type_response import GetAttributesByEntityTypeResponse
from .types.create_attribute_request_attribute_type import CreateAttributeRequestAttributeType
from .types.create_attribute_request_entity_type import CreateAttributeRequestEntityType
from .types.create_attribute_request_unit import CreateAttributeRequestUnit
from .types.delete_attributes_request_entity_type import DeleteAttributesRequestEntityType
from .types.get_attribute_request_entity_type import GetAttributeRequestEntityType
from .types.get_attributes_by_entity_type_request_entity_type import GetAttributesByEntityTypeRequestEntityType
from .types.update_attribute_request_attribute_type import UpdateAttributeRequestAttributeType
from .types.update_attribute_request_entity_type import UpdateAttributeRequestEntityType

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


class RawAttributesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def get_attributes_by_entity_type(
        self,
        *,
        entity_type: GetAttributesByEntityTypeRequestEntityType,
        limit: typing.Optional[int] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[GetAttributesByEntityTypeResponse]:
        """
        Fetch all attributes in an organization associated with either drivers or assets.

         **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 **Read Attributes** under the Setup & Administration 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
        ----------
        entity_type : GetAttributesByEntityTypeRequestEntityType
            Denotes the type of entity, driver or asset.

        limit : typing.Optional[int]
            The limit for how many objects will be in the response. Default and max for this value is 512 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
        -------
        HttpResponse[GetAttributesByEntityTypeResponse]
            All attributes in an organization for an entity type
        """
        _response = self._client_wrapper.httpx_client.request(
            "attributes",
            method="GET",
            params={
                "entityType": entity_type,
                "limit": limit,
                "after": after,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetAttributesByEntityTypeResponse,
                    parse_obj_as(
                        type_=GetAttributesByEntityTypeResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def create_attribute(
        self,
        *,
        attribute_type: CreateAttributeRequestAttributeType,
        entity_type: CreateAttributeRequestEntityType,
        name: str,
        entities: typing.Optional[typing.Sequence[CreateAttributeRequestEntities]] = OMIT,
        number_values: typing.Optional[typing.Sequence[float]] = OMIT,
        string_values: typing.Optional[typing.Sequence[str]] = OMIT,
        unit: typing.Optional[CreateAttributeRequestUnit] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[AttributeExpandedResponse]:
        """
        Creates a new attribute in the organization.

         **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 Attributes** under the Setup & Administration 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
        ----------
        attribute_type : CreateAttributeRequestAttributeType
            Denotes the data type of the attribute's values. Valid values: `single-select`, `multi-select`, `text`, `freeform-multi-select`, `number`, `date`.

        entity_type : CreateAttributeRequestEntityType
            Denotes the type of entity, driver or asset.

        name : str
            Name

        entities : typing.Optional[typing.Sequence[CreateAttributeRequestEntities]]
            Entities that will be applied to this attribute

        number_values : typing.Optional[typing.Sequence[float]]
            Number values that can be associated with this attribute

        string_values : typing.Optional[typing.Sequence[str]]
            String values that can be associated with this attribute

        unit : typing.Optional[CreateAttributeRequestUnit]
            Unit of the attribute (only for Number attributes).

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

        Returns
        -------
        HttpResponse[AttributeExpandedResponse]
            Newly created attribute object with ID.
        """
        _response = self._client_wrapper.httpx_client.request(
            "attributes",
            method="POST",
            json={
                "attributeType": attribute_type,
                "entities": convert_and_respect_annotation_metadata(
                    object_=entities, annotation=typing.Sequence[CreateAttributeRequestEntities], direction="write"
                ),
                "entityType": entity_type,
                "name": name,
                "numberValues": number_values,
                "stringValues": string_values,
                "unit": unit,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AttributeExpandedResponse,
                    parse_obj_as(
                        type_=AttributeExpandedResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def get_attribute(
        self,
        id: str,
        *,
        entity_type: GetAttributeRequestEntityType,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[AttributeExpandedResponse]:
        """
        Fetch an attribute by id, including all of its applications.

         **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 **Read Attributes** under the Setup & Administration 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
        ----------
        id : str
            Samsara-provided UUID of the attribute.

        entity_type : GetAttributeRequestEntityType
            Denotes the type of entity, driver or asset.

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

        Returns
        -------
        HttpResponse[AttributeExpandedResponse]
            The attribute corresponding to request id.
        """
        _response = self._client_wrapper.httpx_client.request(
            f"attributes/{jsonable_encoder(id)}",
            method="GET",
            params={
                "entityType": entity_type,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AttributeExpandedResponse,
                    parse_obj_as(
                        type_=AttributeExpandedResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def delete(
        self,
        id: str,
        *,
        entity_type: DeleteAttributesRequestEntityType,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[None]:
        """
        Delete an attribute by id, including all of its applications.

         **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 Attributes** under the Setup & Administration 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
        ----------
        id : str
            Samsara-provided UUID of the attribute.

        entity_type : DeleteAttributesRequestEntityType
            Denotes the type of entity, driver or asset.

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

        Returns
        -------
        HttpResponse[None]
        """
        _response = self._client_wrapper.httpx_client.request(
            f"attributes/{jsonable_encoder(id)}",
            method="DELETE",
            params={
                "entityType": entity_type,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return HttpResponse(response=_response, data=None)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    def update_attribute(
        self,
        id: str,
        *,
        entity_type: UpdateAttributeRequestEntityType,
        attribute_type: typing.Optional[UpdateAttributeRequestAttributeType] = OMIT,
        entities: typing.Optional[typing.Sequence[CreateAttributeRequestEntities]] = OMIT,
        name: typing.Optional[str] = OMIT,
        number_values: typing.Optional[typing.Sequence[float]] = OMIT,
        string_values: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> HttpResponse[AttributeExpandedResponse]:
        """
        Updates an attribute in the organization.

         **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 Attributes** under the Setup & Administration 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
        ----------
        id : str
            Samsara-provided UUID of the attribute.

        entity_type : UpdateAttributeRequestEntityType
            Denotes the type of entity, driver or asset.

        attribute_type : typing.Optional[UpdateAttributeRequestAttributeType]
            Denotes the data type of the attribute's values. Valid values: `single-select`, `multi-select`, `text`, `freeform-multi-select`, `number`, `date`.

        entities : typing.Optional[typing.Sequence[CreateAttributeRequestEntities]]
            Entities that will be applied to this attribute

        name : typing.Optional[str]
            Name

        number_values : typing.Optional[typing.Sequence[float]]
            Number values that can be associated with this attribute

        string_values : typing.Optional[typing.Sequence[str]]
            String values that can be associated with this attribute

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

        Returns
        -------
        HttpResponse[AttributeExpandedResponse]
            Newly created attribute object with ID.
        """
        _response = self._client_wrapper.httpx_client.request(
            f"attributes/{jsonable_encoder(id)}",
            method="PATCH",
            json={
                "attributeType": attribute_type,
                "entities": convert_and_respect_annotation_metadata(
                    object_=entities, annotation=typing.Sequence[CreateAttributeRequestEntities], direction="write"
                ),
                "entityType": entity_type,
                "name": name,
                "numberValues": number_values,
                "stringValues": string_values,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AttributeExpandedResponse,
                    parse_obj_as(
                        type_=AttributeExpandedResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return HttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)


class AsyncRawAttributesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def get_attributes_by_entity_type(
        self,
        *,
        entity_type: GetAttributesByEntityTypeRequestEntityType,
        limit: typing.Optional[int] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[GetAttributesByEntityTypeResponse]:
        """
        Fetch all attributes in an organization associated with either drivers or assets.

         **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 **Read Attributes** under the Setup & Administration 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
        ----------
        entity_type : GetAttributesByEntityTypeRequestEntityType
            Denotes the type of entity, driver or asset.

        limit : typing.Optional[int]
            The limit for how many objects will be in the response. Default and max for this value is 512 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
        -------
        AsyncHttpResponse[GetAttributesByEntityTypeResponse]
            All attributes in an organization for an entity type
        """
        _response = await self._client_wrapper.httpx_client.request(
            "attributes",
            method="GET",
            params={
                "entityType": entity_type,
                "limit": limit,
                "after": after,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    GetAttributesByEntityTypeResponse,
                    parse_obj_as(
                        type_=GetAttributesByEntityTypeResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def create_attribute(
        self,
        *,
        attribute_type: CreateAttributeRequestAttributeType,
        entity_type: CreateAttributeRequestEntityType,
        name: str,
        entities: typing.Optional[typing.Sequence[CreateAttributeRequestEntities]] = OMIT,
        number_values: typing.Optional[typing.Sequence[float]] = OMIT,
        string_values: typing.Optional[typing.Sequence[str]] = OMIT,
        unit: typing.Optional[CreateAttributeRequestUnit] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[AttributeExpandedResponse]:
        """
        Creates a new attribute in the organization.

         **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 Attributes** under the Setup & Administration 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
        ----------
        attribute_type : CreateAttributeRequestAttributeType
            Denotes the data type of the attribute's values. Valid values: `single-select`, `multi-select`, `text`, `freeform-multi-select`, `number`, `date`.

        entity_type : CreateAttributeRequestEntityType
            Denotes the type of entity, driver or asset.

        name : str
            Name

        entities : typing.Optional[typing.Sequence[CreateAttributeRequestEntities]]
            Entities that will be applied to this attribute

        number_values : typing.Optional[typing.Sequence[float]]
            Number values that can be associated with this attribute

        string_values : typing.Optional[typing.Sequence[str]]
            String values that can be associated with this attribute

        unit : typing.Optional[CreateAttributeRequestUnit]
            Unit of the attribute (only for Number attributes).

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

        Returns
        -------
        AsyncHttpResponse[AttributeExpandedResponse]
            Newly created attribute object with ID.
        """
        _response = await self._client_wrapper.httpx_client.request(
            "attributes",
            method="POST",
            json={
                "attributeType": attribute_type,
                "entities": convert_and_respect_annotation_metadata(
                    object_=entities, annotation=typing.Sequence[CreateAttributeRequestEntities], direction="write"
                ),
                "entityType": entity_type,
                "name": name,
                "numberValues": number_values,
                "stringValues": string_values,
                "unit": unit,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AttributeExpandedResponse,
                    parse_obj_as(
                        type_=AttributeExpandedResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def get_attribute(
        self,
        id: str,
        *,
        entity_type: GetAttributeRequestEntityType,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[AttributeExpandedResponse]:
        """
        Fetch an attribute by id, including all of its applications.

         **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 **Read Attributes** under the Setup & Administration 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
        ----------
        id : str
            Samsara-provided UUID of the attribute.

        entity_type : GetAttributeRequestEntityType
            Denotes the type of entity, driver or asset.

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

        Returns
        -------
        AsyncHttpResponse[AttributeExpandedResponse]
            The attribute corresponding to request id.
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"attributes/{jsonable_encoder(id)}",
            method="GET",
            params={
                "entityType": entity_type,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AttributeExpandedResponse,
                    parse_obj_as(
                        type_=AttributeExpandedResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def delete(
        self,
        id: str,
        *,
        entity_type: DeleteAttributesRequestEntityType,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[None]:
        """
        Delete an attribute by id, including all of its applications.

         **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 Attributes** under the Setup & Administration 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
        ----------
        id : str
            Samsara-provided UUID of the attribute.

        entity_type : DeleteAttributesRequestEntityType
            Denotes the type of entity, driver or asset.

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

        Returns
        -------
        AsyncHttpResponse[None]
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"attributes/{jsonable_encoder(id)}",
            method="DELETE",
            params={
                "entityType": entity_type,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return AsyncHttpResponse(response=_response, data=None)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)

    async def update_attribute(
        self,
        id: str,
        *,
        entity_type: UpdateAttributeRequestEntityType,
        attribute_type: typing.Optional[UpdateAttributeRequestAttributeType] = OMIT,
        entities: typing.Optional[typing.Sequence[CreateAttributeRequestEntities]] = OMIT,
        name: typing.Optional[str] = OMIT,
        number_values: typing.Optional[typing.Sequence[float]] = OMIT,
        string_values: typing.Optional[typing.Sequence[str]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncHttpResponse[AttributeExpandedResponse]:
        """
        Updates an attribute in the organization.

         **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 Attributes** under the Setup & Administration 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
        ----------
        id : str
            Samsara-provided UUID of the attribute.

        entity_type : UpdateAttributeRequestEntityType
            Denotes the type of entity, driver or asset.

        attribute_type : typing.Optional[UpdateAttributeRequestAttributeType]
            Denotes the data type of the attribute's values. Valid values: `single-select`, `multi-select`, `text`, `freeform-multi-select`, `number`, `date`.

        entities : typing.Optional[typing.Sequence[CreateAttributeRequestEntities]]
            Entities that will be applied to this attribute

        name : typing.Optional[str]
            Name

        number_values : typing.Optional[typing.Sequence[float]]
            Number values that can be associated with this attribute

        string_values : typing.Optional[typing.Sequence[str]]
            String values that can be associated with this attribute

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

        Returns
        -------
        AsyncHttpResponse[AttributeExpandedResponse]
            Newly created attribute object with ID.
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"attributes/{jsonable_encoder(id)}",
            method="PATCH",
            json={
                "attributeType": attribute_type,
                "entities": convert_and_respect_annotation_metadata(
                    object_=entities, annotation=typing.Sequence[CreateAttributeRequestEntities], direction="write"
                ),
                "entityType": entity_type,
                "name": name,
                "numberValues": number_values,
                "stringValues": string_values,
            },
            headers={
                "content-type": "application/json",
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                _data = typing.cast(
                    AttributeExpandedResponse,
                    parse_obj_as(
                        type_=AttributeExpandedResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                return AsyncHttpResponse(response=_response, data=_data)
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
        raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
