README.md 933 Bytes
Newer Older
Andreas Ellewsen's avatar
Andreas Ellewsen committed
1
2
# cim-client

3
4
5
Python client for accessing the CIM-API. 

```python
Trond Aasan's avatar
Trond Aasan committed
6
from cim_client import CimClient, CimEndpoints
7
from cim_client.models import Person, PersonList
Trond Aasan's avatar
Trond Aasan committed
8
9
10
11
12
c = CimClient(
    CimEndpoints(url='https://example.com',
                 update_person_url='/_webservices/?ws=contacts/upsert/1.0',
                 delete_person_url='/_webservices/?ws=contacts/delete/1.0'),
    tokens={'api_key': {'X-Gravitee-API-Key': 'c-d-a-b'},})
13

14
15
upd_schema = c.get_update_person_schema()
del_schema = c.get_delete_person_schema()
16
17
18
19
20
21
22
23
24
25
26

person = Person.from_dict({'username': 'foo', 'user_import_id': 'foo1'})
response1 = c.update_person(person)

person2 = Person.from_dict({'username': 'bar', 'user_import_id': 'bar1'})
persons = [person, person2] 
personlist = PersonList(persons=persons)
# Note that delete_person supports both PersonList and [Person, Person, ...]
response2 = c.delete_person(personlist)
response3 = c.delete_person(persons)
```