def _json_dict_(self) -> dict[str, Any]:
        """Magic method for the JSON serialization protocol."""
        utc_valid_until = (
            self.valid_until.replace(tzinfo=datetime.timezone.utc).timestamp()
            if self.valid_until is not None
            else None
        )
        return {
            'code': self.code,
            'error_message': self.error_message,
            'token': self.token,
            'utc_valid_until': utc_valid_until,
            'metrics': self.metrics,
        }
Magic method for the JSON serialization protocol.
cirq-google/cirq_google/engine/calibration_result.py