@@ -54,6 +54,10 @@ def __getattr__(self, item):
5454 from atomx .utils import get_attribute_model_name
5555 model_name = get_attribute_model_name (item )
5656 attr = self ._attributes .get (item )
57+
58+ # loading of extra data is only possible if model ID is known
59+ if 'id' not in self ._attributes :
60+ raise AttributeError ('Model needs at least an `id` value to load more attributes.' )
5761 # if requested attribute item is a valid model name and and int or
5862 # a list of integers, just delete the attribute so it gets
5963 # fetched from the api
@@ -161,11 +165,28 @@ def save(self, session=None):
161165 return self
162166
163167 def delete (self , session = None ):
164- """Delete is currently not supported by the api.
165- Set `state` to `INACTIVE` to deactivate it.
168+ """`DELETE` the model in the api.
169+ A `deleted` attribute is to ``True`` on ``self`` so you can check if a
170+ :class:`.AtomxModel` is deleted or not.
171+
172+ .. warning::
173+
174+ Calling this method will permanently remove this model from the API.
175+
176+ :param session: The :class:`atomx.Atomx` session to use for the api call.
177+ (Optional if you specified a `session` at initialization)
178+ :return: A ``dict`` of all models that the API removed.
179+ Keys are the model names and values are a list of IDs.
180+ :rtype: :class:`dict`
166181 """
167- raise NotImplementedError ("Delete is currently not supported by the api."
168- "Set `state` to `INACTIVE` to deactivate it." )
182+ session = session or self .session
183+ if not session :
184+ raise NoSessionError
185+ res = session .delete (self ._resource_name , self .id )
186+
187+ # set a deleted attribute
188+ self ._attributes ['deleted' ] = True
189+ return res
169190
170191 def reload (self , session = None ):
171192 """Reload the model from the api and update attributes with the response.
0 commit comments