Skip to content

Commit 7594715

Browse files
committed
update readme
1 parent f84636a commit 7594715

1 file changed

Lines changed: 138 additions & 136 deletions

File tree

README.md

Lines changed: 138 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,144 @@ For specific instructions on how to use Split Admin REST API refer to our [offic
66

77
Full documentation on this Python wrapper is available in [this link](https://help.split.io/hc/en-us/articles/4412331052685-Python-PyPi-library-for-Split-REST-Admin-API).
88

9+
## Using in Harness Mode
10+
11+
Starting with version 3.5.0, the Split API client supports operating in "harness mode" to interact with both Split and Harness Feature Flags APIs. This is required for usage in environments that have been migrated to Harness and want to use the new features. Existing API keys will continue to work with the non-deprecated endpoints after migration, but new Harness Tokens will be required for Harness mode.
12+
13+
For detailed information about Harness API endpoints, please refer to the [official Harness API documentation](https://apidocs.harness.io/).
14+
15+
### Authentication in Harness Mode
16+
17+
The client supports multiple authentication scenarios:
18+
19+
1. Harness-specific endpoints always use the 'x-api-key' header format
20+
2. Split endpoints will use the 'x-api-key' header when using the harness_token
21+
3. Split endpoints will use the normal 'Authorization' header when using the apikey
22+
4. If both harness_token and apikey are provided, the client will use the harness_token for Harness endpoints and the apikey for Split endpoints
23+
24+
### Base URLs and Endpoints
25+
26+
- Existing, non-deprecated Split endpoints continue to use the Split base URLs
27+
- New Harness-specific endpoints use the Harness base URL (https://app.harness.io/)
28+
29+
### Deprecated Endpoints
30+
31+
The following Split endpoints are deprecated and cannot be used in harness mode:
32+
- `/workspaces`: POST, PATCH, DELETE, PUT verbs are deprecated
33+
- `/apiKeys`: POST verb for apiKeyType == 'admin' is deprecated
34+
- `/users`: all verbs are deprecated
35+
- `/groups`: all verbs are deprecated
36+
- `/restrictions`: all verbs are deprecated
37+
38+
Non-deprecated endpoints will continue to function as they did before the migration.
39+
40+
### Basic Usage
41+
42+
To use the client in harness mode:
43+
44+
```python
45+
from splitapiclient.main import get_client
46+
47+
# Option 1: Use harness_token for Harness endpoints and apikey for Split endpoints
48+
client = get_client({
49+
'harness_mode': True,
50+
'harness_token': 'YOUR_HARNESS_TOKEN', # Used for Harness-specific endpoints
51+
'apikey': 'YOUR_SPLIT_API_KEY', # Used for existing Split endpoints
52+
'account_identifier': 'YOUR_HARNESS_ACCOUNT_ID' # Required for Harness operations
53+
})
54+
55+
# Option 2: Use harness_token for all operations (if apikey is not provided)
56+
client = get_client({
57+
'harness_mode': True,
58+
'harness_token': 'YOUR_HARNESS_TOKEN', # Used for both Harness and Split endpoints
59+
'account_identifier': 'YOUR_HARNESS_ACCOUNT_ID'
60+
})
61+
```
62+
63+
### Working with Split Resources in Harness Mode
64+
65+
You can still access standard Split resources with some restrictions:
66+
67+
```python
68+
# List workspaces (read-only in harness mode)
69+
for ws in client.workspaces.list():
70+
print(f"Workspace: {ws.name}, Id: {ws.id}")
71+
72+
# Find a specific workspace
73+
ws = client.workspaces.find("Default")
74+
75+
# List environments in a workspace
76+
for env in client.environments.list(ws.id):
77+
print(f"Environment: {env.name}, Id: {env.id}")
78+
```
79+
80+
### Working with Harness-specific Resources
81+
82+
Harness mode provides access to several Harness-specific resources through dedicated microclients:
83+
84+
- token
85+
- harness_apikey
86+
- service_account
87+
- harness_user
88+
- harness_group
89+
- role
90+
- resource_group
91+
- role_assignment
92+
- harness_project
93+
94+
Basic example:
95+
96+
```python
97+
# Account identifier is required for all Harness operations
98+
account_id = 'YOUR_ACCOUNT_IDENTIFIER'
99+
100+
# List all tokens
101+
tokens = client.token.list(account_id)
102+
for token in tokens:
103+
print(f"Token: {token.name}, ID: {token.id}")
104+
105+
# List service accounts
106+
service_accounts = client.service_account.list(account_id)
107+
for sa in service_accounts:
108+
print(f"Service Account: {sa.name}, ID: {sa.id}")
109+
```
110+
111+
For most creation, update, and delete endpoints for harness specific resources, you will need to pass through the JSON body directly.
112+
113+
Example:
114+
```python
115+
# Create a new service account
116+
sa_data = {
117+
'name': sa_name,
118+
'identifier': sa_identifier,
119+
'email': "test@harness.io",
120+
'accountIdentifier': account_id,
121+
'description': 'Service account for test',
122+
'tags': {'test': 'test tag'}
123+
}
124+
125+
new_sa = client.service_account.create(sa_data, account_id)
126+
```
127+
128+
For detailed examples and API specifications for each resource, please refer to the [Harness API documentation](https://apidocs.harness.io/).
129+
130+
### Setting Default Account Identifier
131+
132+
To avoid specifying the account identifier with every request:
133+
134+
```python
135+
# Set default account identifier when creating the client
136+
client = get_client({
137+
'harness_mode': True,
138+
'harness_token': 'YOUR_HARNESS_TOKEN',
139+
'account_identifier': 'YOUR_ACCOUNT_IDENTIFIER'
140+
})
141+
142+
# Now you can make calls without specifying account_identifier in each request
143+
tokens = client.token.list() # account_identifier is automatically included
144+
projects = client.harness_project.list() # account_identifier is automatically included
145+
```
146+
9147
## Quick Setup
10148

11149
Install the splitapiclient:
@@ -231,142 +369,6 @@ data[0]['value']['id'] = group._id
231369
user.update_user_group(data)
232370
```
233371

234-
## Using in Harness Mode
235-
236-
Starting with version 3.5.0, the Split API client supports operating in "harness mode" to interact with both Split and Harness Feature Flags APIs.
237-
238-
For detailed information about Harness Feature Flags API endpoints, please refer to the [official Harness API documentation](https://apidocs.harness.io/).
239-
240-
### Authentication in Harness Mode
241-
242-
The client supports multiple authentication scenarios:
243-
244-
1. Harness-specific endpoints always use the 'x-api-key' header format
245-
2. Split endpoints will use the 'x-api-key' header when using the harness_token
246-
3. Split endpoints will use the normal 'Authorization' header when using the apikey
247-
4. If both harness_token and apikey are provided, the client will use the harness_token for Harness endpoints and the apikey for Split endpoints
248-
249-
### Base URLs and Endpoints
250-
251-
- Existing, non-deprecated Split endpoints continue to use the Split base URLs
252-
- New Harness-specific endpoints use the Harness base URL (https://app.harness.io/)
253-
254-
### Deprecated Endpoints
255-
256-
The following Split endpoints are deprecated and cannot be used in harness mode:
257-
- `/workspaces`: POST, PATCH, DELETE, PUT verbs are deprecated
258-
- `/apiKeys`: POST verb for apiKeyType == 'admin' is deprecated
259-
- `/users`: all verbs are deprecated
260-
- `/groups`: all verbs are deprecated
261-
- `/restrictions`: all verbs are deprecated
262-
263-
### Basic Usage
264-
265-
To use the client in harness mode:
266-
267-
```python
268-
from splitapiclient.main import get_client
269-
270-
# Option 1: Use harness_token for Harness endpoints and apikey for Split endpoints
271-
client = get_client({
272-
'harness_mode': True,
273-
'harness_token': 'YOUR_HARNESS_TOKEN', # Used for Harness-specific endpoints
274-
'apikey': 'YOUR_SPLIT_API_KEY', # Used for existing Split endpoints
275-
'account_identifier': 'YOUR_HARNESS_ACCOUNT_ID' # Required for Harness operations
276-
})
277-
278-
# Option 2: Use harness_token for all operations (if apikey is not provided)
279-
client = get_client({
280-
'harness_mode': True,
281-
'harness_token': 'YOUR_HARNESS_TOKEN', # Used for both Harness and Split endpoints
282-
'account_identifier': 'YOUR_HARNESS_ACCOUNT_ID'
283-
})
284-
```
285-
286-
### Working with Split Resources in Harness Mode
287-
288-
You can still access standard Split resources with some restrictions:
289-
290-
```python
291-
# List workspaces (read-only in harness mode)
292-
for ws in client.workspaces.list():
293-
print(f"Workspace: {ws.name}, Id: {ws.id}")
294-
295-
# Find a specific workspace
296-
ws = client.workspaces.find("Default")
297-
298-
# List environments in a workspace
299-
for env in client.environments.list(ws.id):
300-
print(f"Environment: {env.name}, Id: {env.id}")
301-
```
302-
303-
### Working with Harness-specific Resources
304-
305-
Harness mode provides access to several Harness-specific resources through dedicated microclients:
306-
307-
- token
308-
- harness_apikey
309-
- service_account
310-
- harness_user
311-
- harness_group
312-
- role
313-
- resource_group
314-
- role_assignment
315-
- harness_project
316-
317-
Basic example:
318-
319-
```python
320-
# Account identifier is required for all Harness operations
321-
account_id = 'YOUR_ACCOUNT_IDENTIFIER'
322-
323-
# List all tokens
324-
tokens = client.token.list(account_id)
325-
for token in tokens:
326-
print(f"Token: {token.name}, ID: {token.id}")
327-
328-
# List service accounts
329-
service_accounts = client.service_account.list(account_id)
330-
for sa in service_accounts:
331-
print(f"Service Account: {sa.name}, ID: {sa.id}")
332-
```
333-
334-
For most creation, update, and delete endpoints for harness specific resources, you will need to pass through the JSON body directly.
335-
336-
Example:
337-
```python
338-
# Create a new service account
339-
sa_data = {
340-
'name': sa_name,
341-
'identifier': sa_identifier,
342-
'email': "test@harness.io",
343-
'accountIdentifier': account_id,
344-
'description': 'Service account for test',
345-
'tags': {'test': 'test tag'}
346-
}
347-
348-
new_sa = client.service_account.create(sa_data, account_id)
349-
```
350-
351-
For detailed examples and API specifications for each resource, please refer to the [Harness API documentation](https://apidocs.harness.io/).
352-
353-
### Setting Default Account Identifier
354-
355-
To avoid specifying the account identifier with every request:
356-
357-
```python
358-
# Set default account identifier when creating the client
359-
client = get_client({
360-
'harness_mode': True,
361-
'harness_token': 'YOUR_HARNESS_TOKEN',
362-
'account_identifier': 'YOUR_ACCOUNT_IDENTIFIER'
363-
})
364-
365-
# Now you can make calls without specifying account_identifier in each request
366-
tokens = client.token.list() # account_identifier is automatically included
367-
projects = client.harness_project.list() # account_identifier is automatically included
368-
```
369-
370372
## About Split
371373

372374
### Commitment to Quality:

0 commit comments

Comments
 (0)