# Path: devicehive/api_request.py
# class AuthApiRequest(ApiRequest):
#     """Auth api request class."""
# 
#     def execute(self, error_message):
#         self.header(*self._api.token.auth_header)
#         try:
#             return super(AuthApiRequest, self).execute(error_message)
#         except ApiResponseError as api_response_error:
#             if api_response_error.code != 401:
#                 raise
#         self._api.token.auth()
#         self.header(*self._api.token.auth_header)
#         return super(AuthApiRequest, self).execute(error_message)
# 
# Path: devicehive/api_request.py
# class ApiRequestError(TransportError):
#     """Api request error."""


from devicehive.api_request import AuthApiRequest
from devicehive.api_request import ApiRequestError
            return
        raise DeviceTypeError('DeviceType does not exist.')

    @property
    def id(self):
        return self._id

    def get(self, device_type_id):
        auth_api_request = AuthApiRequest(self._api)
        auth_api_request.url('devicetype/{deviceTypeId}',
                             deviceTypeId=device_type_id)
        auth_api_request.action('devicetype/get')
        auth_api_request.response_key('deviceType')
        devicetype = auth_api_request.execute('DeviceType get failure.')
        self._init(devicetype)

    def save(self):
        self._ensure_exists()
        device_type = {self.ID_KEY: self._id,
                       self.NAME_KEY: self.name,
                       self.DESCRIPTION_KEY: self.description}
        auth_api_request = AuthApiRequest(self._api)
        auth_api_request.method('PUT')
        auth_api_request.url('devicetype/{deviceTypeId}', deviceTypeId=self._id)
        auth_api_request.action('devicetype/update')
        auth_api_request.set('deviceType', device_type, True)
        auth_api_request.execute('DeviceType save failure.')

    def remove(self, force=False):
        self._ensure_exists()

# Path: devicehive/api_request.py
# class AuthApiRequest(ApiRequest):
#     """Auth api request class."""
# 
#     def execute(self, error_message):
#         self.header(*self._api.token.auth_header)
#         try:
#             return super(AuthApiRequest, self).execute(error_message)
#         except ApiResponseError as api_response_error:
#             if api_response_error.code != 401:
#                 raise
#         self._api.token.auth()
#         self.header(*self._api.token.auth_header)
#         return super(AuthApiRequest, self).execute(error_message)
# 
# Path: devicehive/api_request.py
# class ApiRequestError(TransportError):
#     """Api request error."""


# Path: devicehive/device_type.py
from devicehive.api_request import AuthApiRequest
from devicehive.api_request import ApiRequestError

            return
        raise DeviceTypeError('DeviceType does not exist.')

    @property
    def id(self):
        return self._id

    def get(self, device_type_id):
        auth_api_request = AuthApiRequest(self._api)
        auth_api_request.url('devicetype/{deviceTypeId}',
                             deviceTypeId=device_type_id)
        auth_api_request.action('devicetype/get')
        auth_api_request.response_key('deviceType')
        devicetype = auth_api_request.execute('DeviceType get failure.')
        self._init(devicetype)

    def save(self):
        self._ensure_exists()
        device_type = {self.ID_KEY: self._id,
                       self.NAME_KEY: self.name,
                       self.DESCRIPTION_KEY: self.description}
        auth_api_request = AuthApiRequest(self._api)
        auth_api_request.method('PUT')
        auth_api_request.url('devicetype/{deviceTypeId}', deviceTypeId=self._id)
        auth_api_request.action('devicetype/update')
        auth_api_request.set('deviceType', device_type, True)
        auth_api_request.execute('DeviceType save failure.')

    def remove(self, force=False):
        self._ensure_exists()

        auth_api_request = AuthApiRequest(self._api)