forked from DevCycleHQ/python-server-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
69 lines (58 loc) · 2.15 KB
/
Copy pathexample.py
File metadata and controls
69 lines (58 loc) · 2.15 KB
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
61
62
63
64
65
66
67
68
69
from __future__ import print_function
from devcycle_python_sdk import Configuration, DVCClient, DVCOptions, UserData, Event, Variable
from devcycle_python_sdk.rest import ApiException
def main():
configuration = Configuration()
configuration.api_key['Authorization'] = 'YOUR SERVER KEY HERE'
options = DVCOptions(enableEdgeDB=True)
# create an instance of the API class
dvc = DVCClient(configuration, options)
user = UserData(
user_id='test',
email='yo@yo.ca',
country='CA'
)
variable = Variable(value='test', is_defaulted=True, key='test')
print('test varia')
print(variable)
event = Event(
type="customEvent",
target="somevariable.key"
)
try:
# Get all features by key for user data
api_response = dvc.all_features(user)
print(api_response)
except ApiException as e:
print("Exception when calling DevcycleApi->all_features: %s\n" % e)
key = 'elliot-test' # str | Variable key
try:
# Get variable by key for user data
api_response = dvc.variable(user, key, 'default-value')
print(api_response)
if not api_response.is_defaulted:
print('NOT DEFAULTED')
except ApiException as e:
print("Exception when calling DevcycleApi->varaible: %s\n" % e)
try:
# Get variable by key for user data
api_response_default = dvc.variable(user, 'elliot-etakjhsd', 'default-value')
if api_response_default.is_defaulted:
print(api_response_default)
print('DEFAULTED')
except ApiException as e:
print("Exception when calling DevcycleApi->varaible: %s\n" % e)
try:
# Get all variables by key for user data
api_response = dvc.all_variables(user)
print(api_response)
except ApiException as e:
print("Exception when calling DevcycleApi->all_variables: %s\n" % e)
try:
# Post events to DevCycle for user
api_response = dvc.track(user, event)
print(api_response)
except ApiException as e:
print("Exception when calling DevcycleApi->track: %s\n" % e)
if __name__ == "__main__":
main()