-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathusers_example.py
59 lines (46 loc) · 1.19 KB
/
users_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# pylint: disable=redefined-outer-name
"""
Example of using the users API
"""
import logging
from examples.utils import pretty_print
from kentik_api import KentikAPI, User
from kentik_api.utils import get_credentials
logging.basicConfig(level=logging.INFO)
def run_crud() -> None:
"""
Runs example CRUD API calls and prints responses
"""
email, token = get_credentials()
client = KentikAPI(email, token)
print("### CREATE")
user = User.new(
username="testuser",
full_name="Test User",
user_email="test@user.example",
role="Member",
email_service=True,
email_product=True,
)
created = client.users.create(user)
pretty_print(created)
print()
print("### GET_ALL")
all_users = client.users.get_all()
pretty_print(all_users)
print()
print("### UPDATE")
created.full_name = "User Testing"
got = client.users.update(created)
pretty_print(got)
print()
print("### GET")
got = client.users.get(created.id)
pretty_print(got)
print()
print("### DELETE")
deleted = client.users.delete(created.id)
print(deleted)
print()
if __name__ == "__main__":
run_crud()