You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge pull request #34 from splitio/3.5.8-addprojectandorglevel
Features:
Added optional org_identifier and project_identifier support for Harness microclients
These parameters can be set at client initialization or passed to individual method calls
Parameters are only included in API request URLs when they are set (not None)
When not provided, they are completely omitted from URLs rather than being passed as empty strings
Applies to all Harness microclients: harness_project, harness_user, harness_group,
harness_apikey, service_account, token, role, resource_group, and role_assignment
Added filterType support to the group endpoint in order to allow fitlering by resourcegroups
Update the client instantiation to warn when using the legacy bearer auth along with the x-api-key auth
Copy file name to clipboardExpand all lines: README.md
+80-21Lines changed: 80 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,18 +8,17 @@ Full documentation on this Python wrapper is available in [this link](https://he
8
8
9
9
## Using in Harness Mode
10
10
11
-
Starting with version 3.5.0, the Split API client supports operating in "harness mode" to interact with both Split and Harness 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.
11
+
Starting with version 3.5.0, the Split API client supports operating in "harness mode" to interact with both Split and Harness APIs. This is required for usage in environments that have been migrated to Harness **and** want to use the new features. Operating not in harness mode will work as it did before with existing Split bearer tokens, but the deprecated endpoints mentioned below will not function.
12
12
13
13
For detailed information about Harness API endpoints, please refer to the [official Harness API documentation](https://apidocs.harness.io/).
14
14
15
15
### Authentication in Harness Mode
16
16
17
-
The client supports multiple authentication scenarios:
17
+
**Important:** Harness mode requires a `harness_token` (Harness API key). Split API keys (`apikey`) are **not supported** in harness mode.
18
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
19
+
If your account has been migrated to Harness, you should create a new Harness API key to use with this client. The `harness_token` is used for both Split API endpoints and Harness-specific endpoints via the `x-api-key` header.
20
+
21
+
For non-migrated accounts that need to use Split API keys with Bearer authentication, use the standard (non-harness) mode instead.
23
22
24
23
### Base URLs and Endpoints
25
24
@@ -44,19 +43,20 @@ To use the client in harness mode:
44
43
```python
45
44
from splitapiclient.main import get_client
46
45
47
-
#Option 1: Use harness_token for Harness endpoints and apikey for Split endpoints
46
+
#Basic harness mode setup with required harness_token
48
47
client = get_client({
49
48
'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
49
+
'harness_token': 'YOUR_HARNESS_TOKEN', # Required: Harness API key
52
50
'account_identifier': 'YOUR_HARNESS_ACCOUNT_ID'# Required for Harness operations
53
51
})
54
52
55
-
#Option 2: Use harness_token for all operations (if apikey is not provided)
53
+
#Include optional org_identifier and project_identifier
56
54
client = get_client({
57
55
'harness_mode': True,
58
-
'harness_token': 'YOUR_HARNESS_TOKEN', # Used for both Harness and Split endpoints
The `harness_group.list()` method supports an optional `filterType` parameter to filter groups:
151
+
152
+
```python
153
+
# List all groups (default behavior)
154
+
all_groups = client.harness_group.list()
155
+
156
+
# List groups with filterType to exclude inherited groups
157
+
groups = client.harness_group.list(filterType='EXCLUDE_INHERITED_GROUPS')
158
+
159
+
# List groups with filterType and other optional parameters
160
+
groups = client.harness_group.list(
161
+
account_identifier='YOUR_ACCOUNT_ID',
162
+
org_identifier='YOUR_ORG_ID',
163
+
project_identifier='YOUR_PROJECT_ID',
164
+
filterType='INCLUDE_INHERITED_GROUPS'
165
+
)
166
+
```
167
+
168
+
**Note:** The `filterType` parameter is optional. When not provided (or set to `None`), it will be omitted from the API request. Valid values depend on the Harness API specification.
169
+
133
170
134
171
For detailed examples and API specifications for each resource, please refer to the [Harness API documentation](https://apidocs.harness.io/).
135
172
136
-
### Setting Default Account Identifier
173
+
### Setting Default Identifiers
137
174
138
-
To avoid specifying the account identifier with every request:
175
+
To avoid specifying identifiers with every request, you can set default values when creating the client:
139
176
140
177
```python
141
-
# Set default account identifier when creating the client
178
+
# Set default identifiers when creating the client
# Now you can make calls without specifying account_identifier in each request
187
+
# Now you can make calls without specifying identifiers in each request
149
188
tokens = client.token.list() # account_identifier is automatically included
150
-
projects = client.harness_project.list() # account_identifier is automatically included
189
+
projects = client.harness_project.list() # account_identifier and org_identifier are automatically included (project_identifier is not used for projects endpoint)
190
+
```
191
+
192
+
**Note on Optional Identifiers:**
193
+
-`account_identifier` is **required** for all Harness operations
194
+
-`org_identifier` and `project_identifier` are **optional** and will be omitted from API requests if not provided
195
+
- If `org_identifier` or `project_identifier` are not set, they will not appear in the URL at all (not even as empty parameters)
196
+
-**Important:** The `harness_project` microclient does **not** support `project_identifier` as a query parameter. The projects endpoint only uses `org_identifier` (and `account_identifier`). Other microclients (service_account, token, role, etc.) do support `project_identifier`.
197
+
- You can override default identifiers by passing them as parameters to individual method calls:
198
+
199
+
```python
200
+
# Override default identifiers for a specific request
201
+
# Note: project_identifier is not used for harness_project endpoints
202
+
projects = client.harness_project.list(
203
+
account_identifier='DIFFERENT_ACCOUNT_ID',
204
+
org_identifier='DIFFERENT_ORG_ID'
205
+
)
206
+
207
+
# Use default identifiers but override only org_identifier
208
+
# Note: project_identifier is not used for harness_project endpoints
0 commit comments