MCPcopy Create free account
hub / github.com/StackStorm/st2 / to_model

Method to_model

st2common/st2common/models/api/auth.py:121–131  ·  view source on GitHub ↗
(cls, instance)

Source from the content-addressed store, hash-verified

119
120 @classmethod
121 def to_model(cls, instance):
122 # If PrimaryKey ID is provided, - we want to work with existing ST2 API key
123 id = getattr(instance, "id", None)
124 user = str(instance.user) if instance.user else None
125 key_hash = getattr(instance, "key_hash", None)
126 metadata = getattr(instance, "metadata", {})
127 enabled = bool(getattr(instance, "enabled", True))
128 model = cls.model(
129 id=id, user=user, key_hash=key_hash, metadata=metadata, enabled=enabled
130 )
131 return model
132
133
134class ApiKeyCreateResponseAPI(BaseAPI):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected