Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import devcycle_python_sdk
email='[email protected]',
country='CA'
)

value = dvc.variableValue(user, 'feature-key', 'default-value')
```

## Usage
Expand Down
11 changes: 11 additions & 0 deletions devcycle_python_sdk/api/dvc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ def all_features_with_http_info(self, body, **kwargs): # noqa: E501
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)


def variableValue(self, user, key, default_value, **kwargs):
"""Get variable value by key for user data # noqa: E501

:param UserData user: (required)
:param str key: Variable key (required)
:param any default_value
:return: any variable value
"""
return self.variable(user, key, default_value, **kwargs).value

def variable(self, user, key, default_value, **kwargs): # noqa: E501
"""Get variable by key for user data # noqa: E501

Expand Down
14 changes: 9 additions & 5 deletions example/example.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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():

def main():
configuration = Configuration()
configuration.api_key['Authorization'] = 'YOUR SERVER KEY HERE'
configuration.api_key['Authorization'] = '<DVC_SERVER_SDK_KEY>'
options = DVCOptions(enableEdgeDB=True)

# create an instance of the API class
Expand All @@ -15,9 +15,6 @@ def main():
email='[email protected]',
country='CA'
)
variable = Variable(value='test', is_defaulted=True, key='test')
print('test varia')
print(variable)
event = Event(
type="customEvent",
target="somevariable.key"
Expand All @@ -32,6 +29,13 @@ def main():

key = 'elliot-test' # str | Variable key

try:
# Get variable value by key for user data
value = dvc.variableValue(user, key, 'default-value')
print(value)
except ApiException as e:
print("Exception when calling DevcycleApi->varaible: %s\n" % e)

try:
# Get variable by key for user data
api_response = dvc.variable(user, key, 'default-value')
Expand Down