@@ -89,7 +89,7 @@ def __getattr__(self, name):
8989 item = self .items [name ]
9090 return item if not isinstance (item , dict ) else _DictWrapper (item )
9191
92- def has (self , name ):
92+ def has (self , name ) -> bool :
9393 """ Check whether a specific element is defined.
9494
9595 :param name: Name of the element
@@ -232,7 +232,7 @@ def from_json(cls, object_json):
232232 def _parse_references (cls , base_json ):
233233 return [NamedObject .from_json (j ['managedObject' ]) for j in base_json ['references' ]]
234234
235- def to_json (self ):
235+ def to_json (self ) -> dict :
236236 """ Convert the instance to JSON.
237237
238238 The JSON format produced by this function is what is used by the
@@ -245,7 +245,7 @@ def to_json(self):
245245 """
246246 return self ._parser .to_full_json (self )
247247
248- def to_diff_json (self ):
248+ def to_diff_json (self ) -> dict :
249249 """ Convert the changes made to this instance to a JSON representation.
250250
251251 The JSON format produced by this function is what is used by the
@@ -287,7 +287,8 @@ def create(self):
287287 See also function Inventory.create which doesn't parse the result.
288288 """
289289 super ()._assert_c8y ()
290- result_json = self .c8y .post (self .__RESOURCE , self .to_json ())
290+ result_json = self .c8y .post (self .__RESOURCE ,
291+ json = self .to_json (), accept = self .c8y .ACCEPT_MANAGED_OBJECT )
291292 result = ManagedObject .from_json (result_json )
292293 result .c8y = self .c8y
293294 return result
@@ -302,7 +303,8 @@ def update(self):
302303 """
303304 super ()._assert_c8y ()
304305 super ()._assert_id ()
305- result_json = self .c8y .put (self ._build_object_path (), self .to_diff_json ())
306+ result_json = self .c8y .put (self ._build_object_path (),
307+ json = self .to_diff_json (), accept = self .c8y .ACCEPT_MANAGED_OBJECT )
306308 result = ManagedObject .from_json (result_json )
307309 result .c8y = self .c8y
308310 return result
@@ -312,14 +314,15 @@ def apply_to(self, other_id):
312314 database.
313315
314316 :param other_id: Database ID of the event to update.
315- :returns : A fresh ManagedObject instance representing the updated
317+ :return : A fresh :class: ManagedObject instance representing the updated
316318 object within the database.
317319
318- See also function Inventory.apply_to which doesn't parse the result.
320+ See also function :class: Inventory.apply_to which doesn't parse the result.
319321 """
320322 self ._assert_c8y ()
321323 # put diff json to another object (by ID)
322- result_json = self .c8y .put (self .__RESOURCE + other_id , self .to_diff_json ())
324+ result_json = self .c8y .put (self .__RESOURCE + str (other_id ),
325+ json = self .to_diff_json (), accept = self .c8y .ACCEPT_MANAGED_OBJECT )
323326 result = ManagedObject .from_json (result_json )
324327 result .c8y = self .c8y
325328 return result
@@ -640,7 +643,7 @@ class Inventory(_Query):
640643 def __init__ (self , c8y ):
641644 super ().__init__ (c8y , 'inventory/managedObjects' )
642645
643- def get (self , id ): # noqa (id)
646+ def get (self , id ) -> ManagedObject : # noqa (id)
644647 """ Retrieve a specific managed object from the database.
645648
646649 :param id: ID of the managed object
@@ -651,7 +654,7 @@ def get(self, id): # noqa (id)
651654 managed_object .c8y = self .c8y # inject c8y connection into instance
652655 return managed_object
653656
654- def get_all (self , type = None , fragment = None , name = None , limit = None , page_size = 1000 ): # noqa (type)
657+ def get_all (self , type = None , fragment = None , name = None , owner = None , limit = None , page_size = 1000 ): # noqa (type)
655658 """ Query the database for managed objects and return the results
656659 as list.
657660
@@ -662,7 +665,7 @@ def get_all(self, type=None, fragment=None, name=None, limit=None, page_size=100
662665 """
663666 return [x for x in self .select (type = type , fragment = fragment , name = name , limit = limit , page_size = page_size )]
664667
665- def select (self , type = None , fragment = None , name = None , limit = None , page_size = 1000 ): # noqa (type)
668+ def select (self , type = None , fragment = None , name = None , owner = None , limit = None , page_size = 1000 ): # noqa (type)
666669 """ Query the database for managed objects and iterate over the
667670 results.
668671
@@ -680,7 +683,7 @@ def select(self, type=None, fragment=None, name=None, limit=None, page_size=1000
680683 :param page_size: Define the number of events which are read (and
681684 parsed in one chunk). This is a performance related setting.
682685
683- :returns: Generator of ManagedObject instances
686+ :yield: ManagedObject instances
684687 """
685688 query = None
686689 if name :
@@ -769,7 +772,7 @@ def select(self, type=None, name=None, limit=None, page_size=100): # noqa (type
769772 :param page_size: Define the number of events which are read (and
770773 parsed in one chunk). This is a performance related setting.
771774
772- :returns: Generator of Device objects
775+ :yield: Device objects
773776 """
774777 return super ().select (type = type , fragment = 'c8y_IsDevice' , name = name , limit = limit , page_size = page_size )
775778
@@ -828,7 +831,7 @@ def select(self, fragment=None, name=None, page_size=100): # noqa
828831 :param name: name string of the objects to select; no partial
829832 matching/patterns are supported
830833 :param page_size: number of objects to fetch per request
831- :return: Generator of ManagedObject instances
834+ :yield: ManagedObject instances
832835 """
833836 query = None
834837 if name :
0 commit comments