<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def update( self, *, node_id: str, version: int, spec: Mapping[str, Any] ) -> Mapping[str, Any]: """ Update the spec of a node. Args: node_id: The ID or name of the node version: version number of the node being updated spec: fields to be updated """


        params = {"version": version}

        if "Role" in spec:
            assert spec["Role"] in {"worker", "manager"}

        if "Availability" in spec:
            assert spec["Availability"] in {"active", "pause", "drain"}

        response = await self.docker._query_json(
            "nodes/{node_id}/update".format(node_id=node_id),
            method="POST",
            params=params,
            data=spec,
        )
        return response