code: def create(self) -> Key:
      try:
          value = self.codec.encode(self.value)
      except Exception as ex:
          raise KeyValueCreateFailedError(
              "Unable to encode value"
          ) from ex
      entry = KeyValueEntry(
          resource=self.resource.value,
          value=value,
          created_on=datetime.now(),
          created_by_fk=get_user_id(),
          expires_on=self.expires_on,
      )
      if self.key is not None:
          try:
              if isinstance(self.key, UUID):
                  entry.uuid = self.key
              else:
                  entry.id = self.key
          except ValueError as ex:
              raise KeyValueCreateFailedError() from ex
      db.session.add(entry)
      db.session.commit()
      return Key(id=entry.id, uuid=entry.uuid)
  
file_path: superset/superset/commands/key_value/create.py
imports: import logging
  from datetime import datetime
  from typing import Any, Optional, Union
  from uuid import UUID
  from sqlalchemy.exc import SQLAlchemyError
  from superset import db
  from superset.commands.base import BaseCommand
  from superset.key_value.exceptions import KeyValueCreateFailedError
  from superset.key_value.models import KeyValueEntry
  from superset.key_value.types import Key, KeyValueCodec, KeyValueResource
  from superset.utils.core import get_user_id
label_desc: Use image node_id 4 for calling the CreateKeyValueCommand obj's underlying member method code with example usage: obj.create() and returns: Key