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

Method from_model

st2common/st2common/models/api/inquiry.py:160–179  ·  view source on GitHub ↗

Create InquiryResponseAPI instance from model Allows skipping the BaseAPI._from_model function if you already have a properly formed dict and just need to prune it :param skip_db: Skip the parent class' _from_model function call :rtype: InquiryResponseAPI

(cls, model, mask_secrets=False, skip_db=False)

Source from the content-addressed store, hash-verified

158
159 @classmethod
160 def from_model(cls, model, mask_secrets=False, skip_db=False):
161 """Create InquiryResponseAPI instance from model
162
163 Allows skipping the BaseAPI._from_model function if you already
164 have a properly formed dict and just need to prune it
165
166 :param skip_db: Skip the parent class' _from_model function call
167 :rtype: InquiryResponseAPI
168 """
169
170 if not skip_db:
171 doc = cls._from_model(model, mask_secrets=mask_secrets)
172 else:
173 doc = model
174
175 newdoc = {"id": doc["id"]}
176 for field in ["route", "ttl", "users", "roles", "schema"]:
177 newdoc[field] = doc["result"].get(field)
178
179 return cls(**newdoc)
180
181 @classmethod
182 def from_inquiry_api(cls, inquiry_api, mask_secrets=False):

Callers

nothing calls this directly

Calls 2

_from_modelMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected