<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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)