def edit(self, resource):
        """Edit a device.

        :param resource: :class:`devices.Device <devices.Device>` object
        :return: :class:`devices.Device <devices.Device>` object
        :rtype: devices.Device
        """
        schema = DeviceSchema(exclude=('id', 'created', 'updated', 'result_id', 'attachments_dir'))
        json = self.service.encode(schema, resource)

        schema = DeviceSchema()
        resp = self.service.edit(self.base, resource.id, json)
        return self.service.decode(schema, resp)