@@ -6,60 +6,61 @@ This API wrapper is designed to work with [Split](https://www.split.io), the pla
66
77For specific instructions on how to use this API refer to our [ official API documentation] ( https://docs.split.io/reference ) .
88
9- Install the split-admin-api:
9+ Install the split-admin-api:\
1010` pip install split-admin-api `
1111
12- Import the client object and initialize connection using an Admin API Key:
13- `from splitapiclient.main import get_client
12+ Import the client object and initialize connection using an Admin API Key:\
13+ `from splitapiclient.main import get_client & nbsp ;
1414client = get_client({'apikey': 'ADMIN API KEY'})
1515`
1616
17- Enable optional logging:
17+ Enable optional logging:\
1818`import logging
1919logging.basicConfig(level=logging.DEBUG)
2020`
2121
22- ** Workspaces**
23- Fetch all workspaces:
22+ ** Workspaces** \
23+ Fetch all workspaces:\
2424`for ws in client.workspaces.list():
2525 print ("\nWorkspace:"+ws.name+", Id: "+ws.id)
2626`
2727
28- Find a specific workspaces:
28+ Find a specific workspaces:\
2929`ws = client.workspaces.find("Defaults")
3030print ("\nWorkspace:"+ws.name+", Id: "+ws.id)
3131`
3232
33- ** Environments**
34- Fetch all Environments:
33+ ** Environments** \
34+ Fetch all Environments:\
3535`ws = client.workspaces.find("Defaults")
3636for env in client.environments.list(ws.id):
3737 print ("\nEnvironment: "+env.name+", Id: "+env.id)
38- Add new environment:
38+ `
39+
40+ Add new environment:\
3941`ws = client.workspaces.find("Defaults")
4042env = ws.add_environment({'name':'new_environment', 'production': False })
4143`
4244
43- ** Splits**
44-
45- Fetch all Splits:
45+ ** Splits** \
46+ Fetch all Splits:\
4647`ws = client.workspaces.find("Defaults")
4748for split in client.splits.list(ws.id):
4849 print ("\nSplit: "+split.name+", "+split._ workspace_id)
4950`
5051
51- Add new Split:
52+ Add new Split:\
5253`
5354split = ws.add_split({'name':'split_name', 'description':'new UI feature'}, "user")
5455print(split.name)
5556`
5657
57- Add tags:
58+ Add tags:\
5859`
5960split.associate_tags([ 'my_new_tag', 'another_new_tag'] )
6061`
6162
62- Add Split to environment:
63+ Add Split to environment:\
6364`
6465ws = client.workspaces.find("Defaults")
6566split = client.splits.find("new_feature", ws.id)
@@ -76,28 +77,28 @@ data={"treatments":[tr1.export_dict() ,tr2.export_dict()],"defaultTreatment":"of
7677splitdef = split.add_to_environment(env.id, data)
7778`
7879
79- Kill Split:
80+ Kill Split:\
8081`
8182ws = client.workspaces.find("Defaults")
8283env = client.environments.find("Production", ws.id)
8384splitDef = client.split_definitions.find("new_feature", env.id, ws.id)
8485splitDef.kill()
8586`
8687
87- Restore Split:
88+ Restore Split:\
8889`
8990splitDef.restore()
9091`
9192
92- Fetch all Splits in an Environment:
93+ Fetch all Splits in an Environment:\
9394`
9495ws = client.workspaces.find("Defaults")
9596env = client.environments.find("Production", ws.id)
9697for spDef in client.split_definitions.list(env.id, ws.id):
9798 print(spDef.name+str(spDef._ default_rule))
9899`
99100
100- Submit a Change request to update a Split definition:
101+ Submit a Change request to update a Split definition:\
101102`
102103splitDef = client.split_definitions.find("new_feature", env.id, ws.id)
103104definition= {"treatments":[ {"name":"on"},{"name":"off"}] ,
@@ -108,7 +109,7 @@ definition= {"treatments":[ {"name":"on"},{"name":"off"}],
108109splitDef.submit_change_request(definition, 'UPDATE', 'updating default rule', 'comment', [ 'user@email.com '] , '')
109110`
110111
111- List all change requests:
112+ List all change requests:\
112113`
113114for cr in client.change_requests.list():
114115 if cr._ split is not None:
@@ -117,62 +118,61 @@ for cr in client.change_requests.list():
117118 print (cr._ id+", "+cr._ segment[ 'name'] +", "+cr._ title)
118119`
119120
120- Approve specific change request:
121+ Approve specific change request:\
121122`
122123for cr in client.change_requests.list():
123124 if cr._ split[ 'name'] =='new_feature':
124125 cr.update_status("APPROVED", "done")
125126`
126127
127- ** Users and Groups**
128-
129- Fetch all Active users:
128+ ** Users and Groups** \
129+ Fetch all Active users:\
130130`
131131for user in client.users.list('ACTIVE'):
132132 print(user.email+", "+user._ id)
133133`
134134
135- Invite new user:
135+ Invite new user:\
136136`
137137group = client.groups.find('Administrators')
138138userData = {'email':'user@email.com ', 'groups':[ {'id':'', 'type':'group'}] }
139139userData[ 'groups'] [ 0 ] [ 'id'] = group._ id
140140client.users.invite_user(userData)
141141`
142142
143- Delete a pending invite:
143+ Delete a pending invite:\
144144`
145145for user in client.users.list('PENDING'):
146146 print(user.email+", "+user._ id+", "+user._ status)
147147 if user.email == 'user@email.com ':
148148 client.users.delete(user._ id)
149149`
150150
151- Update user info:
151+ Update user info:\
152152`
153153data = {'name':'new_name', 'email':'user@email.com ', '2fa': False , 'status':'ACTIVE'}
154154user = client.users.find('user@email.com ')
155155user.update_user(user._ id, data)
156156`
157157
158- Fetch all Groups:
158+ Fetch all Groups:\
159159`
160160for group in client.groups.list():
161161 print (group._ id+", "+group._ name)
162162`
163163
164- Create Group:
164+ Create Group:\
165165`
166166client.groups.create_group({'name':'new_group', 'description':''})
167167`
168168
169- Delete Group:
169+ Delete Group:\
170170`
171171group = client.groups.find('new_group')
172172client.groups.delete_group(group._ id)
173173`
174174
175- Replace existing user group:
175+ Replace existing user group:\
176176`
177177user = client.users.find('user@email.com ')
178178group = client.groups.find('Administrators')
@@ -181,7 +181,7 @@ data[0]['value']['id'] = group._id
181181user.update_user_group(data)
182182`
183183
184- Add user to new group
184+ Add user to new group\
185185`
186186user = client.users.find('user@email.com ')
187187group = client.groups.find('Administrators')
0 commit comments