glpi-api 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: glpi-api
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Wrap calls to GLPI REST API.
5
5
  Home-page: https://github.com/unistra/python-glpi-api
6
6
  Author: François Ménabé
7
- Author-email: francois.menabe@unistra.fr
7
+ Author-email: francois.menabe@gmail.fr
8
8
  License: GPLv3+
9
9
  Keywords: rest,api,glpi
10
10
  Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
@@ -0,0 +1,6 @@
1
+ glpi_api.py,sha256=5VhHjOPxBnobuGpTjFEeQwcnlaAL7QmemR74EYEXN10,36519
2
+ glpi_api-0.5.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
3
+ glpi_api-0.5.0.dist-info/METADATA,sha256=OBZNx2L3e9MEb6S36g6zkrbqaZCCbRSPh6CIPmhKgNo,660
4
+ glpi_api-0.5.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
5
+ glpi_api-0.5.0.dist-info/top_level.txt,sha256=YOkX5fKd6VWRx_-iMUfVJN15Xobw1VQ-mUF8HKWK2l0,9
6
+ glpi_api-0.5.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
glpi_api.py CHANGED
@@ -728,6 +728,35 @@ class GLPI:
728
728
  400: _glpi_error,
729
729
  401: _glpi_error
730
730
  }.get(response.status_code, _unknown_error)(response)
731
+
732
+ @_catch_errors
733
+ def add_sub_items(self, itemtype, item_id, sub_itemtype, *items):
734
+ """`API documentation
735
+ Same method used as get-sub-items, same parameter
736
+ <https://github.com/glpi-project/glpi/blob/master/apirest.md#get-sub-items>`__
737
+
738
+ Add a collection of rows of the ``sub_itemtype`` for the identified
739
+ item of type ``itemtype`` and id ``item_id``. ``kwargs`` contains
740
+ additional parameters allowed by the API.
741
+
742
+ .. code::
743
+
744
+ # Add a operatingsystem of a computer.
745
+ >>> In [241]: glpi.add_sub_items('Computer',1,'Item_OperatingSystem',{'items_id': 1 ,'itemtype':'Computer','operatingsystems_id':1 })
746
+ [{'id': 261,
747
+ 'itemtype': 'Computer',
748
+ 'items_id': 1,
749
+ ...
750
+ """
751
+ url = self._set_method(itemtype, item_id, sub_itemtype)
752
+ response = self.session.post(url,
753
+ json={'input': items})
754
+ return {
755
+ 201: lambda r: r.json(),
756
+ 207: lambda r: r.json()[1],
757
+ 400: _glpi_error,
758
+ 401: _glpi_error
759
+ }.get(response.status_code, _unknown_error)(response)
731
760
 
732
761
  @_catch_errors
733
762
  def update(self, itemtype, *items):
@@ -749,10 +778,41 @@ class GLPI:
749
778
  json={'input': items})
750
779
  return {
751
780
  200: lambda r: r.json(),
781
+ 201: lambda r: r.json(),
752
782
  207: lambda r: r.json()[1],
753
783
  400: _glpi_error,
754
784
  401: _glpi_error
755
785
  }.get(response.status_code, _unknown_error)(response)
786
+
787
+ @_catch_errors
788
+ def update_sub_items(self, itemtype, item_id, sub_itemtype, *items):
789
+ """`API documentation
790
+ Same method used as get-sub-items, same parameters
791
+ <https://github.com/glpi-project/glpi/blob/master/apirest.md#get-sub-items>`__
792
+
793
+ Updates a collection of rows of the ``sub_itemtype`` for the identified
794
+ item of type ``itemtype`` and id ``item_id``. ``kwargs`` contains
795
+ additional parameters allowed by the API.
796
+
797
+ .. code::
798
+
799
+ # update the operatingsystem a computer.
800
+ >>> In [241]: glpi.update_sub_items('Computer',1,'Item_OperatingSystem' {'id': 1 ,'itemtype':'Computer','operatingsystem_id':1 })
801
+ [{'id': 261,
802
+ 'itemtype': 'Computer',
803
+ 'items_id': 1,
804
+ ...
805
+ """
806
+ url = self._set_method(itemtype, item_id, sub_itemtype)
807
+ response = self.session.put(url,
808
+ json={'input': items})
809
+ return {
810
+ 200: lambda r: r.json(),
811
+ 201: lambda r: r.json(),
812
+ 207: lambda r: r.json(),
813
+ 400: _glpi_error,
814
+ 401: _glpi_error
815
+ }.get(response.status_code, _unknown_error)(response)
756
816
 
757
817
  @_catch_errors
758
818
  def delete(self, itemtype, *items, **kwargs):
@@ -783,6 +843,37 @@ class GLPI:
783
843
  400: lambda r: _glpi_error(r) if r.json()[0] != 'ERROR_GLPI_DELETE' else r.json()[1],
784
844
  401: _glpi_error
785
845
  }.get(response.status_code, _unknown_error)(response)
846
+
847
+ @_catch_errors
848
+ def delete_sub_items(self, itemtype, item_id, sub_itemtype, *items):
849
+ """`API documentation
850
+ Same method used as get-sub-items, same parameters
851
+ <https://github.com/glpi-project/glpi/blob/master/apirest.md#get-sub-items>`__
852
+
853
+ deletes a collection of rows of the ``sub_itemtype`` for the identified
854
+ item of type ``itemtype`` and id ``item_id``. ``kwargs`` contains
855
+ additional parameters allowed by the API.
856
+
857
+ .. code::
858
+
859
+ # delete the operatingsystem a computer.
860
+ >>> In [241]: glpi.delete_sub_items('Computer',1,'Item_OperatingSystem' {'id': 1 ,'itemtype':'Computer','operatingsystem_id':1 })
861
+ [{'id': 261,
862
+ 'itemtype': 'Computer',
863
+ 'items_id': 1,
864
+ ...
865
+ """
866
+ url = self._set_method(itemtype, item_id, sub_itemtype)
867
+ response = self.session.delete(url,
868
+ json={'input': items})
869
+ return {
870
+ 200: lambda r: r.json(),
871
+ 204: lambda r: r.json(),
872
+ 207: lambda r: r.json()[1],
873
+ 400: lambda r: _glpi_error(r) if r.json()[0] != 'ERROR_GLPI_DELETE' else r.json()[1],
874
+ 401: _glpi_error
875
+ }.get(response.status_code, _unknown_error)(response)
876
+
786
877
 
787
878
  @_catch_errors
788
879
  def upload_document(self, name, filepath):
@@ -1,6 +0,0 @@
1
- glpi_api.py,sha256=uVAwXRbXFF1rAH4DSppBS-wTorKQor7bjEDHbCLmcDg,32766
2
- glpi_api-0.4.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
3
- glpi_api-0.4.0.dist-info/METADATA,sha256=UmfIPEK9-3GWhUGqOdRDm86imuwe-4HTfJVwIyTooGY,662
4
- glpi_api-0.4.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
5
- glpi_api-0.4.0.dist-info/top_level.txt,sha256=YOkX5fKd6VWRx_-iMUfVJN15Xobw1VQ-mUF8HKWK2l0,9
6
- glpi_api-0.4.0.dist-info/RECORD,,