Module index
Module index#
- class pymosp.PyMOSP(url, key)#
Python API to access MOSP.
- Parameters
url (
str
) – URL of the MOSP instance you want to connect tokey (
str
) – API key of the user you want to use
- add_objects(objects, pythonify=False)#
Add one or several objects on a MOSP instance.
- Parameters
objects (
List
[MOSPObject
]) – list of objects to addpythonify (
bool
) – Returns a PyMOSP Object instead of the plain json output
>>> mosp = pymosp.PyMOSP(mosp_instance, token) >>> new_objects = [ { "name": "Possibility of installing correction programmes, etc.", "description": "Description of the new object.", "licenses": [{"license_id": "CC0-1.0"}], "schema_id": 3, "org_id": 1, "json_object": { "code": "10", "description": "Description of the new object.", "label": "Possibility of installing correction programmes, etc.", "type": "Primary", "version": 1, "language": "EN", "uuid": "69fbfe01-4591-11e9-9173-0800277f0572", } } ] >>> r = mosp.add_objects(new_objects)
- Return type
Union
[Dict
,List
[MOSPObject
]]
- delete_object(id)#
Delete an object from a MOSP instance. Returns the HTTP status code from the MOSP instance.
- Parameters
id (
int
) – The id of the object to delete.- Return type
int
- objects(params={}, pythonify=False)#
Get all the objects from the MOSP instance. Filters can be used with the
params
parameter.>>> params = {"organization": "MONARC", "schema": "Library objects"} >>> r = mosp.objects(params=params)
- Return type
Union
[Dict
,List
[MOSPObject
]]
- schemas(params={}, pythonify=False)#
Get all the schemas from the MOSP instance.
- Return type
Union
[Dict
,List
[MOSPObject
]]