(cls, instance)
| 173 | |
| 174 | @classmethod |
| 175 | def to_model(cls, instance): |
| 176 | values = {} |
| 177 | for attr, meta in six.iteritems(cls.schema.get("properties", dict())): |
| 178 | if not getattr(instance, attr, None): |
| 179 | continue |
| 180 | |
| 181 | default = fast_deepcopy_dict(meta.get("default", None)) |
| 182 | value = getattr(instance, attr, default) |
| 183 | |
| 184 | # pylint: disable=no-member |
| 185 | # TODO: Add plugin which lets pylint know each MongoEngine document has _fields |
| 186 | # attribute |
| 187 | attr_schema = cls.model._fields.get(attr, None) |
| 188 | if not value and (attr_schema and not attr_schema.required): |
| 189 | continue |
| 190 | if attr not in ActionExecutionAPI.SKIP: |
| 191 | values[attr] = value |
| 192 | |
| 193 | values["start_timestamp"] = isotime.parse(instance.start_timestamp) |
| 194 | values["end_timestamp"] = isotime.parse(instance.end_timestamp) |
| 195 | |
| 196 | model = cls.model(**values) |
| 197 | return model |
| 198 | |
| 199 | |
| 200 | class ActionExecutionOutputAPI(BaseAPI): |
nothing calls this directly
no test coverage detected