Table of Contents
Description
We provide a dedicated client that wraps our API functionality, providing an easy way to interact with Split from within your application.
The Python client is instantiated using an admin API key, for more information on how to generate API Key, please click here
Get Started
- Download the Python Library from the following Github Link
- Once the library is downloaded, run the setup.py to install it
python setup.oy install
- Instantiate the Wrapper and Create a New Split API Client
from splitapiclient.main import get_client
# instantiate client
client = get_client({
'apikey': 'Admin',
})
Workspaces
- Structure
"id": "string", // Server populated identifier
"name": "string", // Display name
- Methods
list
Return list of existing Workspaces in the Organization as workspace object
for ws in client.workspaces.list():
print ws.name
Environments
- Structure
"id": "string", // Server populated identifier
"name": "string", // Display name
"production": "boolean" // Production environment or not
"workspace":"string" // workspace id
- Methods
list
Return list of existing Environments for given Workspace
Params: Workspace ID
for env in client.environments.list(workspaceId):
print env.name
TrafficTypes
- Structure
"id": "string", // Server populated identifier
"name": "string", // Display name
"workspace":"string" // workspace id
"displayAttributeId": "string" // (Optional) Attribute used for display name in UI
- Methods
list
Return list of all existing TestTypes in the organization
for tp in client.traffic_types.list():
print tp.name
Attributes
- Structure
"id": "string", // Attribute identifier, same as used in identity value map
"workspace":"string" // workspace id
"trafficTypeId": "string", // Traffic type this attribute is associated with
"displayName": "string", // (Optional) How the attribute will be displayed in the UI, defaults to the id
"description": "string", // (Optional) A description of the attribute
"dataType": "string", // (Optional) The data type of the attribute used for display formatting, defaults to displaying the raw string. Must be one of: null, "string", "datetime", "number", "set"
"isSearchable": boolean // (Optional) Deprecated, included for backward compatibility
- Methods
list
Return list of all existing Attributes for a given Workspace and TestType Ids
Params: Workspace Id, TestType Id
for at in client.attributes.list(workspaceId, testtypeId)
print at.display_name
save
Save an attribute for a traffic type ID. The attribute is created if it does not exist and is overwritten completely if it does.
Params: workspace Id, trafficType Id, display name, description, data type, isSearchable
new_attribute = client.attributes.save({
"workspaceId" : workspaceId,
"trafficTypeId": ttId,
"id": "attrib456",
"displayName": "Street",
"description": "St Address",
"dataType": "STRING",
"isSearchable": False
})
Customer Identities
- Structure
key: "string", // Key used for getTreatment() calls
trafficTypeId: "string", // Traffic Type Identifier
environmentId: "string", // Environment Identifier
values: { // Attribute Values (key: Attribute Id, value: value)
key: "string",...
- Methods
save
Create or overwrite a single customer ID for a given traffic type and environment.
Params: environment Id, trafficType Id, key, values
client.identities.save({
'trafficTypeId': ttId,
'environmentId': envId,
'key': 'user120',
'values': {attributeId: 'PM'}
})
save_all
Create or overwrite attributes for multiple customer ID(s) for a given traffic type and environment.
Params: array [ environment Id, trafficType Id, key, values]
client.identities.save_all([
{
'trafficTypeId': ttId,
'environmentId': envId,
'key': 'user120',
'values': {attributeId: 'PM'}
},
{'trafficTypeId': ttId,
'environmentId': envId,
'key': 'testing554',
'values': {attributeId: 'CEO'},
}
])
update
Update a single customer ID for a given traffic type and environment. Any provided attribute values will be overwritten, but existing values will otherwise remain.
Params: environment Id, trafficType Id, key, values
client.identities.update({
'trafficTypeId': ttId,
'environmentId': envId,
'key': 'user120',
'values': {attributeId: 'Director'}
})
Comments
0 comments
Please sign in to leave a comment.