-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathapplications_example.py
60 lines (47 loc) · 1.45 KB
/
applications_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
60
# pylint: disable=redefined-outer-name
"""
Examples of using the typed custom applications API
"""
import logging
from examples.utils import pretty_print
from kentik_api import CustomApplication, KentikAPI
from kentik_api.utils import get_credentials
logging.basicConfig(level=logging.INFO)
def run_crud():
email, token = get_credentials()
client = KentikAPI(email, token)
print("### CREATE")
app = CustomApplication(
name="apitest-customapp-1",
description="Testing custom application api",
ip_range="192.168.0.1,192.168.0.2",
protocol="6,17",
port="9001,9002,9003",
asn="asn1,asn2,asn3",
)
created = client.custom_applications.create(app)
pretty_print(created)
print()
print("### UPDATE")
created.name = "apitest-customapp-ONE"
created.description = "Updated description"
created.port = "1023"
updated = client.custom_applications.update(created)
pretty_print(updated)
print()
# GET for single custom application item is not available in custom applications api
# print("### GET")
print("### DELETE")
deleted = client.custom_applications.delete(updated.id)
print(deleted)
print()
def run_list():
print("### GET ALL")
email, token = get_credentials()
client = KentikAPI(email, token)
apps = client.custom_applications.get_all()
pretty_print(apps)
print()
if __name__ == "__main__":
run_crud()
run_list()